diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/nav.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/nav.tsx index 20bbfe38e5f39..c70971ebc6ece 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/nav.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/nav.tsx @@ -65,3 +65,20 @@ export const useAppSearchNav = () => { // to cause all our navItems to properly render as nav links. return [{ id: '', name: '', items: navItems }]; }; + +// Process App Search side nav items for use in the new Solution Nav +export const cleanAppSearchNavItems = ( + items: Array> +): Array> => { + const enginesItem = items.find((item) => item.id === 'engines'); + if (enginesItem && enginesItem.items && enginesItem.items.length > 0) { + const engineChildren = enginesItem.items; + const engineNameItem = engineChildren.find((item) => item.id === 'engineName'); + if (engineNameItem && engineNameItem.renderItem) { + delete engineNameItem.renderItem; + engineNameItem.items = engineChildren.filter((item) => item.id !== 'engineName'); + enginesItem.items = [engineNameItem]; + } + } + return items; +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/page_template.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/page_template.tsx index 7e4d72c232b33..35792e2d0cbf9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/page_template.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/page_template.tsx @@ -16,7 +16,7 @@ import { SetAppSearchChrome } from '../../../shared/kibana_chrome'; import { EnterpriseSearchPageTemplateWrapper, PageTemplateProps } from '../../../shared/layout'; import { SendAppSearchTelemetry } from '../../../shared/telemetry'; -import { useAppSearchNav } from './nav'; +import { useAppSearchNav, cleanAppSearchNavItems } from './nav'; export const AppSearchPageTemplate: React.FC< Omit @@ -27,14 +27,14 @@ export const AppSearchPageTemplate: React.FC< React.useEffect(() => { if (chromeStyle === 'classic') return; + const appSearch = cleanAppSearchNavItems(navItems?.[0]?.items); // We update the new side nav definition with the selected app items - updateSideNavDefinition({ appSearch: navItems?.[0]?.items }); - }, [chromeStyle, navItems, updateSideNavDefinition]); - React.useEffect(() => { + updateSideNavDefinition({ appSearch }); + return () => { updateSideNavDefinition({ appSearch: undefined }); }; - }, [updateSideNavDefinition]); + }, [chromeStyle, navItems, updateSideNavDefinition]); return (