From a31b06bf07afb2f0420bc1820d437faf41401d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georgiana-Andreea=20Onolea=C8=9B=C4=83?= Date: Tue, 10 Dec 2024 18:13:43 +0200 Subject: [PATCH] [ResponseOps][Serverless]Maintenance window page displays dead breadcrumb for management (#201147) Closes https://github.com/elastic/kibana/issues/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 5a67a033a3f29ea72028dc4e2f2b3c43b6d36551) --- x-pack/plugins/alerting/kibana.jsonc | 17 ++++--------- .../alerting/public/hooks/use_breadcrumbs.ts | 25 +++++++++++++------ x-pack/plugins/alerting/public/plugin.ts | 2 ++ .../test_suites/observability/navigation.ts | 10 ++++++++ .../test_suites/security/ftr/navigation.ts | 11 ++++++++ 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/x-pack/plugins/alerting/kibana.jsonc b/x-pack/plugins/alerting/kibana.jsonc index b99c0a26c901e..097ed2e5b464c 100644 --- a/x-pack/plugins/alerting/kibana.jsonc +++ b/x-pack/plugins/alerting/kibana.jsonc @@ -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", @@ -35,11 +30,9 @@ "usageCollection", "security", "monitoringCollection", - "spaces" + "spaces", + "serverless" ], - "extraPublicDirs": [ - "common", - "common/parse_duration" - ] + "extraPublicDirs": ["common", "common/parse_duration"] } } diff --git a/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts b/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts index 45d849be4d60f..d68e6f5816781 100644 --- a/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts +++ b/x-pack/plugins/alerting/public/hooks/use_breadcrumbs.ts @@ -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] ? [ { @@ -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]); }; diff --git a/x-pack/plugins/alerting/public/plugin.ts b/x-pack/plugins/alerting/public/plugin.ts index 71bae6b28c94c..66f93cfe124a8 100644 --- a/x-pack/plugins/alerting/public/plugin.ts +++ b/x-pack/plugins/alerting/public/plugin.ts @@ -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'; @@ -68,6 +69,7 @@ export interface AlertingPluginStart { spaces: SpacesPluginStart; unifiedSearch: UnifiedSearchPublicPluginStart; data: DataPublicPluginStart; + serverless?: ServerlessPluginStart; } export interface AlertingUIConfig { diff --git a/x-pack/test_serverless/functional/test_suites/observability/navigation.ts b/x-pack/test_serverless/functional/test_suites/observability/navigation.ts index 0f8df9e7bc780..428d346386b98 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/navigation.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/navigation.ts @@ -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', + ]); + }); }); } diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/navigation.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/navigation.ts index 9f9580c226c61..b7d7ef5c6dbbb 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/navigation.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/navigation.ts @@ -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', + ]); + }); }); }