From 66ce33bc5ba494cf071c7c2e0a13cb97a8a99768 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Wed, 7 Sep 2022 09:24:10 +0100 Subject: [PATCH] make Browse the root item of Dashboards when topnav is enabled (#54782) --- pkg/api/index.go | 18 +++++++++++++----- .../dashboard/containers/DashboardPage.tsx | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/api/index.go b/pkg/api/index.go index df01315501a..a2eb513aabe 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -197,7 +197,7 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool, prefs * dashboardsUrl := "/dashboards" - navTree = append(navTree, &dtos.NavLink{ + dashboardLink := &dtos.NavLink{ Text: "Dashboards", Id: "dashboards", SubTitle: "Manage dashboards and folders", @@ -206,7 +206,13 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool, prefs * SortWeight: dtos.WeightDashboard, Section: dtos.NavSectionCore, Children: dashboardChildLinks, - }) + } + + if hs.Features.IsEnabled(featuremgmt.FlagTopnav) { + dashboardLink.Id = "dashboards/browse" + } + + navTree = append(navTree, dashboardLink) } canExplore := func(context *models.ReqContext) bool { @@ -507,9 +513,11 @@ func (hs *HTTPServer) buildDashboardNavLinks(c *models.ReqContext, hasEditPerm b } dashboardChildNavs := []*dtos.NavLink{} - dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ - Text: "Browse", Id: "dashboards/browse", Url: hs.Cfg.AppSubURL + "/dashboards", Icon: "sitemap", - }) + if !hs.Features.IsEnabled(featuremgmt.FlagTopnav) { + dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ + Text: "Browse", Id: "dashboards/browse", Url: hs.Cfg.AppSubURL + "/dashboards", Icon: "sitemap", + }) + } dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ Text: "Playlists", Id: "dashboards/playlists", Url: hs.Cfg.AppSubURL + "/playlists", Icon: "presentation-play", }) diff --git a/public/app/features/dashboard/containers/DashboardPage.tsx b/public/app/features/dashboard/containers/DashboardPage.tsx index a745b9e3e14..b540ec24127 100644 --- a/public/app/features/dashboard/containers/DashboardPage.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.tsx @@ -8,6 +8,7 @@ import { locationService } from '@grafana/runtime'; import { Themeable2, withTheme2 } from '@grafana/ui'; import { notifyApp } from 'app/core/actions'; import { Page } from 'app/core/components/Page/Page'; +import { config } from 'app/core/config'; import { createErrorNotification } from 'app/core/copy/appNotification'; import { getKioskMode } from 'app/core/navigation/kiosk'; import { GrafanaRouteComponentProps } from 'app/core/navigation/types'; @@ -425,7 +426,7 @@ function updateStatePageNavFromProps(props: Props, state: State): State { pageNav.parentItem = pageNav.parentItem; } } else { - sectionNav = getNavModel(props.navIndex, 'dashboards'); + sectionNav = getNavModel(props.navIndex, config.featureToggles.topnav ? 'dashboards/browse' : 'dashboards'); } if (state.pageNav === pageNav && state.sectionNav === sectionNav) {