Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const useFormatUrl = (page: SecurityPageName) => {
return { formatUrl, search };
};

type GetSecuritySolutionUrl = (param: {
export type GetSecuritySolutionUrl = (param: {
deepLinkId: SecurityPageName;
path?: string;
absolute?: boolean;
Expand All @@ -63,6 +63,7 @@ export const useGetSecuritySolutionUrl = () => {
({ deepLinkId, path = '', absolute = false, skipSearch = false }) => {
const search = needsUrlState(deepLinkId) ? getUrlStateQueryString() : '';
const formattedPath = formatPath(path, search, skipSearch);

return getAppUrl({ deepLinkId, path: formattedPath, absolute });
},
[getAppUrl, getUrlStateQueryString]
Expand Down
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];
};
Loading