make Browse the root item of Dashboards when topnav is enabled (#54782)

This commit is contained in:
Ashley Harrison 2022-09-07 09:24:10 +01:00 committed by GitHub
parent ebf24da028
commit 66ce33bc5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -197,7 +197,7 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool, prefs *
dashboardsUrl := "/dashboards" dashboardsUrl := "/dashboards"
navTree = append(navTree, &dtos.NavLink{ dashboardLink := &dtos.NavLink{
Text: "Dashboards", Text: "Dashboards",
Id: "dashboards", Id: "dashboards",
SubTitle: "Manage dashboards and folders", SubTitle: "Manage dashboards and folders",
@ -206,7 +206,13 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool, prefs *
SortWeight: dtos.WeightDashboard, SortWeight: dtos.WeightDashboard,
Section: dtos.NavSectionCore, Section: dtos.NavSectionCore,
Children: dashboardChildLinks, Children: dashboardChildLinks,
}) }
if hs.Features.IsEnabled(featuremgmt.FlagTopnav) {
dashboardLink.Id = "dashboards/browse"
}
navTree = append(navTree, dashboardLink)
} }
canExplore := func(context *models.ReqContext) bool { canExplore := func(context *models.ReqContext) bool {
@ -507,9 +513,11 @@ func (hs *HTTPServer) buildDashboardNavLinks(c *models.ReqContext, hasEditPerm b
} }
dashboardChildNavs := []*dtos.NavLink{} dashboardChildNavs := []*dtos.NavLink{}
dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ if !hs.Features.IsEnabled(featuremgmt.FlagTopnav) {
Text: "Browse", Id: "dashboards/browse", Url: hs.Cfg.AppSubURL + "/dashboards", Icon: "sitemap", dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{
}) Text: "Browse", Id: "dashboards/browse", Url: hs.Cfg.AppSubURL + "/dashboards", Icon: "sitemap",
})
}
dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{
Text: "Playlists", Id: "dashboards/playlists", Url: hs.Cfg.AppSubURL + "/playlists", Icon: "presentation-play", Text: "Playlists", Id: "dashboards/playlists", Url: hs.Cfg.AppSubURL + "/playlists", Icon: "presentation-play",
}) })

View File

@ -8,6 +8,7 @@ import { locationService } from '@grafana/runtime';
import { Themeable2, withTheme2 } from '@grafana/ui'; import { Themeable2, withTheme2 } from '@grafana/ui';
import { notifyApp } from 'app/core/actions'; import { notifyApp } from 'app/core/actions';
import { Page } from 'app/core/components/Page/Page'; import { Page } from 'app/core/components/Page/Page';
import { config } from 'app/core/config';
import { createErrorNotification } from 'app/core/copy/appNotification'; import { createErrorNotification } from 'app/core/copy/appNotification';
import { getKioskMode } from 'app/core/navigation/kiosk'; import { getKioskMode } from 'app/core/navigation/kiosk';
import { GrafanaRouteComponentProps } from 'app/core/navigation/types'; import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
@ -425,7 +426,7 @@ function updateStatePageNavFromProps(props: Props, state: State): State {
pageNav.parentItem = pageNav.parentItem; pageNav.parentItem = pageNav.parentItem;
} }
} else { } else {
sectionNav = getNavModel(props.navIndex, 'dashboards'); sectionNav = getNavModel(props.navIndex, config.featureToggles.topnav ? 'dashboards/browse' : 'dashboards');
} }
if (state.pageNav === pageNav && state.sectionNav === sectionNav) { if (state.pageNav === pageNav && state.sectionNav === sectionNav) {