Navigation: add a link to starred dashboards in the megamenu (#62685)

add a link to starred dashboards in the megamenu
This commit is contained in:
Ashley Harrison
2023-02-08 15:18:13 +00:00
committed by GitHub
parent 225c8dbba7
commit fc2f7f90f8
4 changed files with 8 additions and 2 deletions

View File

@@ -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",
})
}

View File

@@ -22,7 +22,7 @@ export function NavBarMenuItemWrapper({
if (link.emptyMessage && !linkHasChildren(link)) {
return (
<NavBarMenuSection link={link}>
<NavBarMenuSection onClose={onClose} link={link} activeItem={activeItem}>
<ul className={styles.children}>
<div className={styles.emptyMessage}>{link.emptyMessage}</div>
</ul>

View File

@@ -163,6 +163,11 @@ describe('getActiveItem', () => {
text: 'Base',
url: '/',
},
{
text: 'Starred',
url: '/dashboards?starred',
id: 'starred',
},
{
text: 'Dashboards',
url: '/dashboards',

View File

@@ -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;