From ff972c3f174fa01fe42271c26252d701063221e5 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Thu, 1 Aug 2024 16:16:51 -0700 Subject: [PATCH] [Backport 2.16] Fix direct url load for trace analytics (#2027) * fix direct url load for trace analytics Signed-off-by: Shenoy Pratik (cherry picked from commit 3c7c3883190ec9124a3b88b4418532a9be73fce5) * update side nav link Signed-off-by: Shenoy Pratik (cherry picked from commit 438c7c874e14dd060999bf616f1c3f006b54245e) --- public/components/trace_analytics/home.tsx | 8 +++++++- public/components/trace_analytics/trace_side_nav.tsx | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/components/trace_analytics/home.tsx b/public/components/trace_analytics/home.tsx index 5bb98bbea2..da691d9cf5 100644 --- a/public/components/trace_analytics/home.tsx +++ b/public/components/trace_analytics/home.tsx @@ -120,7 +120,13 @@ export const Home = (props: HomeProps) => { const [dataSourceMDSId, setDataSourceMDSId] = useState([{ id: '', label: '' }]); const [currentSelectedService, setCurrentSelectedService] = useState(''); - const { defaultRoute = '/services' } = props; + let defaultRoute = props.defaultRoute ?? '/services'; + const currentHash = window.location.hash.split('#')[1] || ''; + + if (currentHash === '/traces' || currentHash === '/services') { + defaultRoute = currentHash; + } + const { chrome } = props; const isNavGroupEnabled = chrome.navGroup.getNavGroupEnabled(); diff --git a/public/components/trace_analytics/trace_side_nav.tsx b/public/components/trace_analytics/trace_side_nav.tsx index de1a346d43..1691c5b51c 100644 --- a/public/components/trace_analytics/trace_side_nav.tsx +++ b/public/components/trace_analytics/trace_side_nav.tsx @@ -30,7 +30,7 @@ export function TraceSideBar(props: { children: React.ReactNode }) { { name: 'Trace analytics', id: 1, - href: '#/', + href: '#/services', items: [ { name: 'Services',