mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Navigation: Landing pages behind feature toggles (#54576)
* super quick attempt * feature toggle everything * only construct alertNav if there are navChildren * fix toggle name * plugin landing pages poc * add apps route + put behind feature toggle * use toIconName * rename to NavLandingPage * feature toggle new routes * don't modify GetServerAdminNode * some fairly hacky code to check if the plugin has a root page * remove trailing slash
This commit is contained in:
@@ -99,12 +99,17 @@ func (hs *HTTPServer) getAppLinks(c *models.ReqContext) ([]*dtos.NavLink, error)
|
||||
appLink := &dtos.NavLink{
|
||||
Text: plugin.Name,
|
||||
Id: "plugin-page-" + plugin.ID,
|
||||
Url: path.Join(hs.Cfg.AppSubURL, plugin.DefaultNavURL),
|
||||
Img: plugin.Info.Logos.Small,
|
||||
Section: dtos.NavSectionPlugin,
|
||||
SortWeight: dtos.WeightPlugin,
|
||||
}
|
||||
|
||||
if hs.Features.IsEnabled(featuremgmt.FlagTopnav) {
|
||||
appLink.Url = path.Join(hs.Cfg.AppSubURL, "a", plugin.ID)
|
||||
} else {
|
||||
appLink.Url = path.Join(hs.Cfg.AppSubURL, plugin.DefaultNavURL)
|
||||
}
|
||||
|
||||
for _, include := range plugin.Includes {
|
||||
if !c.HasUserRole(include.Role) {
|
||||
continue
|
||||
@@ -117,7 +122,7 @@ func (hs *HTTPServer) getAppLinks(c *models.ReqContext) ([]*dtos.NavLink, error)
|
||||
Url: hs.Cfg.AppSubURL + include.Path,
|
||||
Text: include.Name,
|
||||
}
|
||||
if include.DefaultNav {
|
||||
if include.DefaultNav && !hs.Features.IsEnabled(featuremgmt.FlagTopnav) {
|
||||
appLink.Url = link.Url // Overwrite the hardcoded page logic
|
||||
}
|
||||
} else {
|
||||
@@ -298,6 +303,11 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool, prefs *
|
||||
SortWeight: dtos.WeightConfig,
|
||||
Children: configNodes,
|
||||
}
|
||||
if hs.Features.IsEnabled(featuremgmt.FlagTopnav) {
|
||||
configNode.Url = "/admin"
|
||||
} else {
|
||||
configNode.Url = configNodes[0].Url
|
||||
}
|
||||
navTree = append(navTree, configNode)
|
||||
}
|
||||
|
||||
@@ -312,6 +322,7 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool, prefs *
|
||||
// Move server admin into Configuration and rename to administration
|
||||
if configNode != nil && serverAdminNode != nil {
|
||||
configNode.Text = "Administration"
|
||||
serverAdminNode.Url = "/admin"
|
||||
configNode.Children = append(configNode.Children, serverAdminNode)
|
||||
adminNodeIndex := len(navTree) - 1
|
||||
navTree = navTree[:adminNodeIndex]
|
||||
@@ -412,7 +423,6 @@ func (hs *HTTPServer) setupConfigNodes(c *models.ReqContext) ([]*dtos.NavLink, e
|
||||
Url: hs.Cfg.AppSubURL + "/org/serviceaccounts",
|
||||
})
|
||||
}
|
||||
|
||||
return configNodes, nil
|
||||
}
|
||||
|
||||
@@ -570,18 +580,21 @@ func (hs *HTTPServer) buildLegacyAlertNavLinks(c *models.ReqContext) []*dtos.Nav
|
||||
})
|
||||
}
|
||||
|
||||
return []*dtos.NavLink{
|
||||
{
|
||||
Text: "Alerting",
|
||||
SubTitle: "Alert rules and notifications",
|
||||
Id: "alerting-legacy",
|
||||
Icon: "bell",
|
||||
Url: hs.Cfg.AppSubURL + "/alerting/list",
|
||||
Children: alertChildNavs,
|
||||
Section: dtos.NavSectionCore,
|
||||
SortWeight: dtos.WeightAlerting,
|
||||
},
|
||||
var alertNav = dtos.NavLink{
|
||||
Text: "Alerting",
|
||||
SubTitle: "Alert rules and notifications",
|
||||
Id: "alerting-legacy",
|
||||
Icon: "bell",
|
||||
Children: alertChildNavs,
|
||||
Section: dtos.NavSectionCore,
|
||||
SortWeight: dtos.WeightAlerting,
|
||||
}
|
||||
if hs.Features.IsEnabled(featuremgmt.FlagTopnav) {
|
||||
alertNav.Url = hs.Cfg.AppSubURL + "/alerting"
|
||||
} else {
|
||||
alertNav.Url = hs.Cfg.AppSubURL + "/alerting/list"
|
||||
}
|
||||
return []*dtos.NavLink{&alertNav}
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) buildAlertNavLinks(c *models.ReqContext) []*dtos.NavLink {
|
||||
@@ -626,18 +639,23 @@ func (hs *HTTPServer) buildAlertNavLinks(c *models.ReqContext) []*dtos.NavLink {
|
||||
}
|
||||
|
||||
if len(alertChildNavs) > 0 {
|
||||
return []*dtos.NavLink{
|
||||
{
|
||||
Text: "Alerting",
|
||||
SubTitle: "Alert rules and notifications",
|
||||
Id: "alerting",
|
||||
Icon: "bell",
|
||||
Url: hs.Cfg.AppSubURL + "/alerting/list",
|
||||
Children: alertChildNavs,
|
||||
Section: dtos.NavSectionCore,
|
||||
SortWeight: dtos.WeightAlerting,
|
||||
},
|
||||
var alertNav = dtos.NavLink{
|
||||
Text: "Alerting",
|
||||
SubTitle: "Alert rules and notifications",
|
||||
Id: "alerting",
|
||||
Icon: "bell",
|
||||
Children: alertChildNavs,
|
||||
Section: dtos.NavSectionCore,
|
||||
SortWeight: dtos.WeightAlerting,
|
||||
}
|
||||
|
||||
if hs.Features.IsEnabled(featuremgmt.FlagTopnav) {
|
||||
alertNav.Url = hs.Cfg.AppSubURL + "/alerting"
|
||||
} else {
|
||||
alertNav.Url = hs.Cfg.AppSubURL + "/alerting/list"
|
||||
}
|
||||
|
||||
return []*dtos.NavLink{&alertNav}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user