Fix breadcrumbs path reopens timeline when timeline modal is open (#101568)

This commit is contained in:
Pablo Machado 2021-06-23 18:27:55 +02:00 committed by GitHub
parent 12895d8bd0
commit 5b0d325d7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 2 deletions

View file

@ -306,6 +306,29 @@ describe('Navigation Breadcrumbs', () => {
},
]);
});
test('should set "timeline.isOpen" to false when timeline is open', () => {
const breadcrumbs = getBreadcrumbsForRoute(
{
...getMockObject('timelines', '/', undefined),
timeline: {
activeTab: TimelineTabs.query,
id: 'TIMELINE_ID',
isOpen: true,
graphEventId: 'GRAPH_EVENT_ID',
},
},
getUrlForAppMock
);
expect(breadcrumbs).toEqual([
{ text: 'Security', href: 'securitySolutionoverview' },
{
text: 'Timelines',
href:
"securitySolution:timelines?sourcerer=()&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-05-16T23:10:43.696Z',fromStr:now-24h,kind:relative,to:'2019-05-17T23:10:43.697Z',toStr:now)),timeline:(linkTo:!(global),timerange:(from:'2019-05-16T23:10:43.696Z',fromStr:now-24h,kind:relative,to:'2019-05-17T23:10:43.697Z',toStr:now)))&timeline=(activeTab:query,graphEventId:GRAPH_EVENT_ID,id:TIMELINE_ID,isOpen:!f)",
},
]);
});
});
describe('setBreadcrumbs()', () => {

View file

@ -61,10 +61,14 @@ const isAdminRoutes = (spyState: RouteSpyState): spyState is AdministrationRoute
// eslint-disable-next-line complexity
export const getBreadcrumbsForRoute = (
object: RouteSpyState & TabNavigationProps,
objectParam: RouteSpyState & TabNavigationProps,
getUrlForApp: GetUrlForApp
): ChromeBreadcrumb[] | null => {
const spyState: RouteSpyState = omit('navTabs', object);
const spyState: RouteSpyState = omit('navTabs', objectParam);
// Sets `timeline.isOpen` to false in the state to avoid reopening the timeline on breadcrumb click. https://github.com/elastic/kibana/issues/100322
const object = { ...objectParam, timeline: { ...objectParam.timeline, isOpen: false } };
const overviewPath = getUrlForApp(APP_ID, { path: SecurityPageName.overview });
const siemRootBreadcrumb: ChromeBreadcrumb = {
text: APP_NAME,