Skip to content

Commit

Permalink
[ResponseOps][Serverless]Maintenance window page displays dead breadc…
Browse files Browse the repository at this point in the history
…rumb for management (elastic#201147)

Closes elastic#189318

## Summary

- the issue was resolved by using
useKibana.services.serverless.setBreadcrumbs instead of
chrome.setBreadcrumbs, this ensures that breadcrumb functionality is
correctly handled within serverless observability.

https://github.com/user-attachments/assets/d805b54f-74b4-424f-8304-dced09718ebb
(cherry picked from commit 5a67a03)
  • Loading branch information
georgianaonoleata1904 committed Dec 10, 2024
1 parent f676907 commit a31b06b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
17 changes: 5 additions & 12 deletions x-pack/plugins/alerting/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"type": "plugin",
"id": "@kbn/alerting-plugin",
"owner": [
"@elastic/response-ops"
],
"owner": ["@elastic/response-ops"],
"group": "platform",
"visibility": "shared",
"plugin": {
"id": "alerting",
"browser": true,
"server": true,
"configPath": [
"xpack",
"alerting"
],
"configPath": ["xpack", "alerting"],
"requiredPlugins": [
"actions",
"data",
Expand All @@ -35,11 +30,9 @@
"usageCollection",
"security",
"monitoringCollection",
"spaces"
"spaces",
"serverless"
],
"extraPublicDirs": [
"common",
"common/parse_duration"
]
"extraPublicDirs": ["common", "common/parse_duration"]
}
}
25 changes: 17 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,25 @@ 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(),
},
...(!serverless
? [
{
text: i18n.translate('xpack.alerting.breadcrumbs.stackManagementLinkText', {
defaultMessage: 'Stack Management',
}),
href: getAppUrl(),
},
]
: []),
...(topLevelBreadcrumb[pageDeepLink]
? [
{
Expand All @@ -98,11 +104,14 @@ export const useBreadcrumbs = (pageDeepLink: MaintenanceWindowDeepLinkIds) => {
},
];

if (setBreadcrumbs) {
if (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]);
};
2 changes: 2 additions & 0 deletions x-pack/plugins/alerting/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import { LicensingPluginStart } from '@kbn/licensing-plugin/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import type { ServerlessPluginStart } from '@kbn/serverless/public';

import { AlertNavigationRegistry, AlertNavigationHandler } from './alert_navigation_registry';
import { loadRule, loadRuleType } from './services/rule_api';
Expand Down Expand Up @@ -68,6 +69,7 @@ export interface AlertingPluginStart {
spaces: SpacesPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
data: DataPublicPluginStart;
serverless?: ServerlessPluginStart;
}

export interface AlertingUIConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,15 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'fleet' });
await svlCommonNavigation.breadcrumbs.expectBreadcrumbTexts(['Fleet', 'Agents']);
});

it('navigates to maintenance windows', async () => {
await svlCommonNavigation.sidenav.openSection('project_settings_project_nav');
await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'management' });
await testSubjects.click('app-card-maintenanceWindows');
await svlCommonNavigation.breadcrumbs.expectBreadcrumbTexts([
'Management',
'Maintenance Windows',
]);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,16 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
await testSubjects.existOrFail('cases-all-title');
});
});
it('navigates to maintenance windows', async () => {
await svlCommonPage.loginAsAdmin();
await svlSecNavigation.navigateToLandingPage();
await svlCommonNavigation.sidenav.openSection('category-management');
await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'management' });
await testSubjects.click('app-card-maintenanceWindows');
await svlCommonNavigation.breadcrumbs.expectBreadcrumbTexts([
'Stack Management',
'Maintenance Windows',
]);
});
});
}

0 comments on commit a31b06b

Please sign in to comment.