Skip to content

Commit

Permalink
Fix breadcrumbs path reopens timeline when timeline modal is open (el…
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum authored Jun 23, 2021
1 parent 12895d8 commit 5b0d325
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5b0d325

Please sign in to comment.