From a8f538d15cc40be82bf5abf697a94ee2a5f0466f Mon Sep 17 00:00:00 2001 From: Angela Chuang <6295984+angorayc@users.noreply.github.com> Date: Thu, 25 Jan 2024 20:39:12 +0800 Subject: [PATCH] [Security Solution] Fix misaligned top nav (#175516) ## Summary Issue and steps to reproduce: https://github.com/elastic/kibana/issues/171682 Before: misaligned After: https://github.com/elastic/kibana/assets/6295984/58d3e5bc-0a9a-475b-99dd-00e061b8c4b1 ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --- .../security_solution/public/helpers.test.tsx | 21 +++++++++++++++++++ .../security_solution/public/helpers.tsx | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/helpers.test.tsx b/x-pack/plugins/security_solution/public/helpers.test.tsx index a305434a1ff11..1e053c84ba91d 100644 --- a/x-pack/plugins/security_solution/public/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/helpers.test.tsx @@ -15,6 +15,7 @@ import { isSubPluginAvailable, getSubPluginRoutesByCapabilities, getField, + isDashboardViewPath, } from './helpers'; import type { StartedSubPlugins } from './types'; import { @@ -257,3 +258,23 @@ describe('public helpers getField', () => { expect(signalQuery).toEqual(aadQuery); }); }); + +describe('isDashboardViewPath', () => { + it('returns true for dashboard view path', () => { + expect(isDashboardViewPath('/dashboards/59c085c3-394d-49ab-a83a-56a63f38aa5f')).toEqual(true); + }); + + it('returns true for dashboard edit path', () => { + expect(isDashboardViewPath('/dashboards/59c085c3-394d-49ab-a83a-56a63f38aa5f/edit')).toEqual( + true + ); + }); + + it('returns true for dashboard creation path', () => { + expect(isDashboardViewPath('/dashboards/create')).toEqual(true); + }); + + it('returns false for dashboard listing path', () => { + expect(isDashboardViewPath('/dashboards')).toEqual(false); + }); +}); diff --git a/x-pack/plugins/security_solution/public/helpers.tsx b/x-pack/plugins/security_solution/public/helpers.tsx index 09ad6612bdb06..5794263282fec 100644 --- a/x-pack/plugins/security_solution/public/helpers.tsx +++ b/x-pack/plugins/security_solution/public/helpers.tsx @@ -176,7 +176,7 @@ export const isDetectionsPath = (pathname: string): boolean => { export const isDashboardViewPath = (pathname: string): boolean => matchPath(pathname, { - path: `/${DASHBOARDS_PATH}/:id`, + path: `${DASHBOARDS_PATH}/:detailName`, exact: false, strict: false, }) != null;