forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solutions] Refactor breadcrumbs to support new menu structu…
…re (elastic#131624) * Refactor breadcrumbs to support new structure * Fix code style * Fix more code style * Fix unit test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
9649307
commit a3646eb
Showing
16 changed files
with
976 additions
and
735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...rity_solution/public/common/components/navigation/breadcrumbs/get_breadcrumbs_for_page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ChromeBreadcrumb } from '@kbn/core/public'; | ||
import { SecurityPageName } from '../../../../app/types'; | ||
import { APP_NAME } from '../../../../../common/constants'; | ||
import { getAppLandingUrl } from '../../link_to/redirect_to_landing'; | ||
|
||
import { GetSecuritySolutionUrl } from '../../link_to'; | ||
import { getAncestorLinksInfo } from '../../../links'; | ||
import { GenericNavRecord } from '../types'; | ||
|
||
export const getLeadingBreadcrumbsForSecurityPage = ( | ||
pageName: SecurityPageName, | ||
getSecuritySolutionUrl: GetSecuritySolutionUrl, | ||
navTabs: GenericNavRecord, | ||
isGroupedNavigationEnabled: boolean | ||
): [ChromeBreadcrumb, ...ChromeBreadcrumb[]] => { | ||
const landingPath = getSecuritySolutionUrl({ deepLinkId: SecurityPageName.landing }); | ||
|
||
const siemRootBreadcrumb: ChromeBreadcrumb = { | ||
text: APP_NAME, | ||
href: getAppLandingUrl(landingPath), | ||
}; | ||
|
||
const breadcrumbs: ChromeBreadcrumb[] = getAncestorLinksInfo(pageName).map(({ title, id }) => { | ||
const newTitle = title; | ||
// Get title from navTabs because pages title on the new structure might be different. | ||
const oldTitle = navTabs[id] ? navTabs[id].name : title; | ||
|
||
return { | ||
text: isGroupedNavigationEnabled ? newTitle : oldTitle, | ||
href: getSecuritySolutionUrl({ deepLinkId: id }), | ||
}; | ||
}); | ||
|
||
return [siemRootBreadcrumb, ...breadcrumbs]; | ||
}; |
Oops, something went wrong.