[Serverless] fix breadcrumbs for alerts and slo (#169778)

## Summary

Close https://github.com/elastic/kibana/issues/161447

This fixes deeper context breadcrumbs in serverless observability
project for alerts and slos apps.
This builds on top of https://github.com/elastic/kibana/pull/169513
where we added merging of navigational project breadcrumbs with deeper
context breadcrumbs set by `chrome.setBreadcrumbs`. The merging is based
on deepLinkId, so we're adding it to base breadcrumbs. The deepLinkId is
type checked.

![Screenshot 2023-10-25 at 12 28
07](947f59b3-b338-4bd1-96b9-7414bf396fae)
![Screenshot 2023-10-25 at 12 28
16](5e73e902-3397-4b3e-9202-5c1e2c49358f)
This commit is contained in:
Anton Dosov 2023-10-27 09:58:17 +02:00 committed by GitHub
parent ef68ba981b
commit cb2a6e5348
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 3 deletions

View file

@ -75,6 +75,7 @@ export function AlertDetails() {
text: i18n.translate('xpack.observability.breadcrumbs.alertsLinkText', {
defaultMessage: 'Alerts',
}),
deepLinkId: 'observability-overview:alerts',
},
{
text: alert ? pageTitleContent(alert.fields[ALERT_RULE_CATEGORY]) : defaultBreadcrumb,

View file

@ -85,6 +85,7 @@ export function RuleDetailsPage() {
defaultMessage: 'Alerts',
}),
href: basePath.prepend(paths.observability.alerts),
deepLinkId: 'observability-overview:alerts',
},
{
href: basePath.prepend(paths.observability.rules),

View file

@ -46,6 +46,7 @@ export function RulesPage({ activeTab = RULES_TAB_NAME }: RulesPageProps) {
defaultMessage: 'Alerts',
}),
href: http.basePath.prepend('/app/observability/alerts'),
deepLinkId: 'observability-overview:alerts',
},
{
text: i18n.translate('xpack.observability.breadcrumbs.rulesLinkText', {

View file

@ -8,10 +8,10 @@
import React, { useState } from 'react';
import { useParams } from 'react-router-dom';
import { useIsMutating } from '@tanstack/react-query';
import { EuiBreadcrumbProps } from '@elastic/eui/src/components/breadcrumbs/breadcrumb';
import { EuiLoadingSpinner } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { IBasePath } from '@kbn/core-http-browser';
import type { ChromeBreadcrumb } from '@kbn/core-chrome-browser';
import type { SLOWithSummaryResponse } from '@kbn/slo-schema';
import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public';
@ -97,13 +97,14 @@ export function SloDetailsPage() {
function getBreadcrumbs(
basePath: IBasePath,
slo: SLOWithSummaryResponse | undefined
): EuiBreadcrumbProps[] {
): ChromeBreadcrumb[] {
return [
{
href: basePath.prepend(paths.observability.slos),
text: i18n.translate('xpack.observability.breadcrumbs.slosLinkText', {
defaultMessage: 'SLOs',
}),
deepLinkId: 'observability-overview:slos',
},
{
text:

View file

@ -41,6 +41,7 @@ export function SloEditPage() {
text: i18n.translate('xpack.observability.breadcrumbs.sloLabel', {
defaultMessage: 'SLOs',
}),
deepLinkId: 'observability-overview:slos',
},
...(!!slo
? [

View file

@ -44,6 +44,7 @@ export function SlosPage() {
text: i18n.translate('xpack.observability.breadcrumbs.slosLinkText', {
defaultMessage: 'SLOs',
}),
deepLinkId: 'observability-overview:slos',
},
]);

View file

@ -91,7 +91,8 @@
"@kbn/core-application-common",
"@kbn/react-kibana-mount",
"@kbn/react-kibana-context-theme",
"@kbn/shared-ux-link-redirect-app"
"@kbn/shared-ux-link-redirect-app",
"@kbn/core-chrome-browser"
],
"exclude": [
"target/**/*"

View file

@ -127,6 +127,18 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
await svlCommonNavigation.breadcrumbs.expectBreadcrumbTexts(['Cases', 'Settings']);
});
it('navigates to alerts app', async () => {
await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'observability-overview:alerts' });
await svlCommonNavigation.sidenav.expectLinkActive({
deepLinkId: 'observability-overview:alerts',
});
await testSubjects.click('manageRulesPageButton');
await svlCommonNavigation.breadcrumbs.expectBreadcrumbTexts(['Alerts', 'Rules']);
await svlCommonNavigation.sidenav.expectLinkActive({
deepLinkId: 'observability-overview:alerts',
});
});
it('navigates to integrations', async () => {
await svlCommonNavigation.sidenav.openSection('project_settings_project_nav');
await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'integrations' });