From 8045cfa9bc0f294258d0456814e2cb324b094d6c Mon Sep 17 00:00:00 2001 From: Georgiana-Andreea Onoleata Date: Thu, 21 Nov 2024 14:18:28 +0200 Subject: [PATCH] Maintenance window page displays dead breadcrumb for management --- .../alerting/public/hooks/use_breadcrumbs.test.tsx | 7 +------ .../alerting/public/hooks/use_breadcrumbs.ts | 14 ++++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.test.tsx b/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.test.tsx index 9eb5970e86a9f..5e3958e3cf2e2 100644 --- a/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.test.tsx +++ b/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.test.tsx @@ -51,10 +51,7 @@ describe('useBreadcrumbs', () => { renderHook(() => useBreadcrumbs(MAINTENANCE_WINDOW_DEEP_LINK_IDS.maintenanceWindows), { wrapper: appMockRenderer.AppWrapper, }); - expect(mockSetBreadcrumbs).toHaveBeenCalledWith([ - { href: '/test', onClick: expect.any(Function), text: 'Stack Management' }, - { text: 'Maintenance Windows' }, - ]); + expect(mockSetBreadcrumbs).toHaveBeenCalledWith([{ text: 'Maintenance Windows' }]); }); test('set create maintenance windows breadcrumbs', () => { @@ -62,7 +59,6 @@ describe('useBreadcrumbs', () => { wrapper: appMockRenderer.AppWrapper, }); expect(mockSetBreadcrumbs).toHaveBeenCalledWith([ - { href: '/test', onClick: expect.any(Function), text: 'Stack Management' }, { href: MAINTENANCE_WINDOW_DEEP_LINK_IDS.maintenanceWindows, onClick: expect.any(Function), @@ -77,7 +73,6 @@ describe('useBreadcrumbs', () => { wrapper: appMockRenderer.AppWrapper, }); expect(mockSetBreadcrumbs).toHaveBeenCalledWith([ - { href: '/test', onClick: expect.any(Function), text: 'Stack Management' }, { href: MAINTENANCE_WINDOW_DEEP_LINK_IDS.maintenanceWindows, onClick: expect.any(Function), diff --git a/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts b/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts index 45d849be4d60f..a3fd16b819d35 100644 --- a/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts +++ b/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts @@ -72,6 +72,7 @@ export const useBreadcrumbs = (pageDeepLink: MaintenanceWindowDeepLinkIds) => { services: { chrome: { docTitle, setBreadcrumbs }, application: { navigateToUrl }, + serverless, }, } = useKibana(); const setTitle = docTitle.change; @@ -79,12 +80,6 @@ export const useBreadcrumbs = (pageDeepLink: MaintenanceWindowDeepLinkIds) => { useEffect(() => { const breadcrumbs = [ - { - text: i18n.translate('xpack.alerting.breadcrumbs.stackManagementLinkText', { - defaultMessage: 'Stack Management', - }), - href: getAppUrl(), - }, ...(topLevelBreadcrumb[pageDeepLink] ? [ { @@ -98,11 +93,14 @@ export const useBreadcrumbs = (pageDeepLink: MaintenanceWindowDeepLinkIds) => { }, ]; - if (setBreadcrumbs) { + if (serverless && serverless.setBreadcrumbs) { + serverless.setBreadcrumbs(breadcrumbs); + } else { setBreadcrumbs(addClickHandlers(breadcrumbs, navigateToUrl)); } + if (setTitle) { setTitle(getTitleFromBreadCrumbs(breadcrumbs)); } - }, [pageDeepLink, getAppUrl, navigateToUrl, setBreadcrumbs, setTitle]); + }, [pageDeepLink, getAppUrl, navigateToUrl, setBreadcrumbs, setTitle, serverless]); };