From 58eb0d40e989e00966c651447772f8f3b746c4f9 Mon Sep 17 00:00:00 2001 From: Kyle Pollich Date: Wed, 9 Jun 2021 10:07:29 -0400 Subject: [PATCH] [Fleet] Fix routing issues with `getPath` and `history.push` (#101658) * Fix getPath usage in Fleet app * Fix pathname in failing test --- .../integrations/sections/epm/screens/detail/index.test.tsx | 4 +--- x-pack/plugins/fleet/public/hooks/use_link.ts | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx index 4063bc6371cbd..3477335321a2c 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx @@ -109,9 +109,7 @@ describe('when on integration detail', () => { pagePathGetters.integration_details_custom({ pkgkey: 'nginx-0.3.7' })[1] ); }); - expect(testRenderer.history.location.pathname).toEqual( - '/app/integrations/detail/nginx-0.3.7/overview' - ); + expect(testRenderer.history.location.pathname).toEqual('/detail/nginx-0.3.7/overview'); }); }); diff --git a/x-pack/plugins/fleet/public/hooks/use_link.ts b/x-pack/plugins/fleet/public/hooks/use_link.ts index df6f45af31d56..6917e0f5c3b8e 100644 --- a/x-pack/plugins/fleet/public/hooks/use_link.ts +++ b/x-pack/plugins/fleet/public/hooks/use_link.ts @@ -21,9 +21,7 @@ export const useLink = () => { const core = useStartServices(); return { getPath: (page: StaticPage | DynamicPage, values: DynamicPagePathValues = {}): string => { - const [basePath, path] = getSeparatePaths(page, values); - - return `${basePath}${path}`; + return getSeparatePaths(page, values)[1]; }, getAssetsPath: (path: string) => core.http.basePath.prepend(`/plugins/${PLUGIN_ID}/assets/${path}`),