Skip to content

Commit

Permalink
Maintenance window page displays dead breadcrumb for management
Browse files Browse the repository at this point in the history
  • Loading branch information
georgianaonoleata1904 committed Nov 21, 2024
1 parent 7e65cde commit 8045cfa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,14 @@ 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', () => {
renderHook(() => useBreadcrumbs(MAINTENANCE_WINDOW_DEEP_LINK_IDS.maintenanceWindowsCreate), {
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),
Expand All @@ -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),
Expand Down
14 changes: 6 additions & 8 deletions x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,14 @@ export const useBreadcrumbs = (pageDeepLink: MaintenanceWindowDeepLinkIds) => {
services: {
chrome: { docTitle, setBreadcrumbs },
application: { navigateToUrl },
serverless,
},
} = useKibana();
const setTitle = docTitle.change;
const { getAppUrl } = useNavigation(MANAGEMENT_APP_ID);

useEffect(() => {
const breadcrumbs = [
{
text: i18n.translate('xpack.alerting.breadcrumbs.stackManagementLinkText', {
defaultMessage: 'Stack Management',
}),
href: getAppUrl(),
},
...(topLevelBreadcrumb[pageDeepLink]
? [
{
Expand All @@ -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]);
};

0 comments on commit 8045cfa

Please sign in to comment.