From 0b6359b7266047273a936d97806856e0788635d7 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 9 Oct 2024 04:45:50 +1100 Subject: [PATCH] [8.x] [SecuritySolution] Allow custom sorting on integration cards (#195397) (#195428) # Backport This will backport the following commits from `main` to `8.x`: - [[SecuritySolution] Allow custom sorting on integration cards (#195397)](https://github.com/elastic/kibana/pull/195397) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Angela Chuang <6295984+angorayc@users.noreply.github.com> --- .../epm/components/package_list_grid/grid.tsx | 1 - .../epm/components/package_list_grid/index.tsx | 15 +++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid/grid.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid/grid.tsx index 4338cfb2bc918..80cb14dcfb16c 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid/grid.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid/grid.tsx @@ -68,7 +68,6 @@ export const GridColumn = ({ }: GridColumnProps) => { const itemsSizeRefs = useRef(new Map()); const listRef = useRef(null); - const onHeightChange = useCallback((index: number, size: number) => { itemsSizeRefs.current.set(index, size); if (listRef.current) { diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid/index.tsx index be2b873c317db..ba90ed6509f95 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid/index.tsx @@ -61,6 +61,8 @@ export interface PackageListGridProps { setUrlandReplaceHistory: (params: IntegrationsURLParameters) => void; setUrlandPushHistory: (params: IntegrationsURLParameters) => void; callout?: JSX.Element | null; + // Props to decide the size of the spacer above callout. Security Solution uses this prop to customize the size of the spacer + calloutTopSpacerSize?: 's' | 'm' | 'xs' | 'l' | 'xl' | 'xxl'; // Props used only in AvailablePackages component: showCardLabels?: boolean; title?: string; @@ -70,6 +72,8 @@ export interface PackageListGridProps { showMissingIntegrationMessage?: boolean; showControls?: boolean; showSearchTools?: boolean; + // Customizing whether to sort by the default featured integrations' categories. Security Solution has custom sorting logic + sortByFeaturedIntegrations?: boolean; spacer?: boolean; // Security Solution sends the id to determine which element to scroll when the user interacting with the package list scrollElementId?: string; @@ -92,7 +96,9 @@ export const PackageListGrid: FunctionComponent = ({ setUrlandReplaceHistory, setUrlandPushHistory, showMissingIntegrationMessage = false, + sortByFeaturedIntegrations = true, callout, + calloutTopSpacerSize = 'l', // Default EUI spacer size showCardLabels = true, showControls = true, showSearchTools = true, @@ -141,9 +147,10 @@ export const PackageListGrid: FunctionComponent = ({ ) : list; - return promoteFeaturedIntegrations(filteredList, selectedCategory); - }, [isLoading, list, localSearchRef, searchTerm, selectedCategory]); - + return sortByFeaturedIntegrations + ? promoteFeaturedIntegrations(filteredList, selectedCategory) + : filteredList; + }, [isLoading, list, localSearchRef, searchTerm, selectedCategory, sortByFeaturedIntegrations]); const splitSubcategories = ( subcategories: CategoryFacet[] | undefined ): { visibleSubCategories?: CategoryFacet[]; hiddenSubCategories?: CategoryFacet[] } => { @@ -270,7 +277,7 @@ export const PackageListGrid: FunctionComponent = ({ ) : null} {callout ? ( <> - + {callout} ) : null}