From fc2f7f90f8059a1bd2496c30c15e038a3d0742c3 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Wed, 8 Feb 2023 15:18:13 +0000 Subject: [PATCH] Navigation: add a link to starred dashboards in the megamenu (#62685) add a link to starred dashboards in the megamenu --- pkg/services/navtree/navtreeimpl/navtree.go | 1 + .../app/core/components/MegaMenu/NavBarMenuItemWrapper.tsx | 2 +- public/app/core/components/NavBar/utils.test.ts | 5 +++++ public/app/core/components/NavBar/utils.ts | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/services/navtree/navtreeimpl/navtree.go b/pkg/services/navtree/navtreeimpl/navtree.go index d1a69e780a0..728fda30336 100644 --- a/pkg/services/navtree/navtreeimpl/navtree.go +++ b/pkg/services/navtree/navtreeimpl/navtree.go @@ -92,6 +92,7 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, hasEditPerm bool, p Section: navtree.NavSectionCore, Children: starredItemsLinks, EmptyMessageId: "starred-empty", + Url: s.cfg.AppSubURL + "/dashboards?starred", }) } diff --git a/public/app/core/components/MegaMenu/NavBarMenuItemWrapper.tsx b/public/app/core/components/MegaMenu/NavBarMenuItemWrapper.tsx index 7d76bb6be4c..2501c0341d7 100644 --- a/public/app/core/components/MegaMenu/NavBarMenuItemWrapper.tsx +++ b/public/app/core/components/MegaMenu/NavBarMenuItemWrapper.tsx @@ -22,7 +22,7 @@ export function NavBarMenuItemWrapper({ if (link.emptyMessage && !linkHasChildren(link)) { return ( - +
    {link.emptyMessage}
diff --git a/public/app/core/components/NavBar/utils.test.ts b/public/app/core/components/NavBar/utils.test.ts index 988bc973903..3bce87818c9 100644 --- a/public/app/core/components/NavBar/utils.test.ts +++ b/public/app/core/components/NavBar/utils.test.ts @@ -163,6 +163,11 @@ describe('getActiveItem', () => { text: 'Base', url: '/', }, + { + text: 'Starred', + url: '/dashboards?starred', + id: 'starred', + }, { text: 'Dashboards', url: '/dashboards', diff --git a/public/app/core/components/NavBar/utils.ts b/public/app/core/components/NavBar/utils.ts index df94b105376..ca7eb890ee5 100644 --- a/public/app/core/components/NavBar/utils.ts +++ b/public/app/core/components/NavBar/utils.ts @@ -129,7 +129,7 @@ export const getActiveItem = ( for (const link of navTree) { const linkWithoutParams = stripQueryParams(link.url); const linkPathname = locationUtil.stripBaseFromUrl(linkWithoutParams); - if (linkPathname) { + if (linkPathname && link.id !== 'starred') { if (linkPathname === pathname) { // exact match currentBestMatch = link;