Navigation: move connections + integrations to be a top level item (#58902)
* move connections + integrations to be a top level item * add a test to check we can move apps to the root * split out movePlugin logic into a separate function * fix linting * rename movePlugin -> addPluginToSection
This commit is contained in:
@@ -170,6 +170,12 @@ func (s *ServiceImpl) processAppPlugin(plugin plugins.PluginDTO, c *models.ReqCo
|
||||
}
|
||||
appLink.Children = childrenWithoutDefault
|
||||
|
||||
s.addPluginToSection(c, treeRoot, plugin, appLink)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServiceImpl) addPluginToSection(c *models.ReqContext, treeRoot *navtree.NavTreeRoot, plugin plugins.PluginDTO, appLink *navtree.NavLink) {
|
||||
// Handle moving apps into specific navtree sections
|
||||
alertingNode := treeRoot.FindById(navtree.NavIDAlerting)
|
||||
sectionID := navtree.NavIDApps
|
||||
@@ -183,7 +189,9 @@ func (s *ServiceImpl) processAppPlugin(plugin plugins.PluginDTO, c *models.ReqCo
|
||||
}
|
||||
}
|
||||
|
||||
if navNode := treeRoot.FindById(sectionID); navNode != nil {
|
||||
if sectionID == navtree.NavIDRoot {
|
||||
treeRoot.AddSection(appLink)
|
||||
} else if navNode := treeRoot.FindById(sectionID); navNode != nil {
|
||||
navNode.Children = append(navNode.Children, appLink)
|
||||
} else {
|
||||
switch sectionID {
|
||||
@@ -227,8 +235,6 @@ func (s *ServiceImpl) processAppPlugin(plugin plugins.PluginDTO, c *models.ReqCo
|
||||
s.log.Error("Plugin app nav id not found", "pluginId", plugin.ID, "navId", sectionID)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServiceImpl) hasAccessToInclude(c *models.ReqContext, pluginID string) func(include *plugins.Includes) bool {
|
||||
@@ -256,6 +262,7 @@ func (s *ServiceImpl) readNavigationSettings() {
|
||||
"grafana-incident-app": {SectionID: navtree.NavIDAlertsAndIncidents, SortWeight: 2, Text: "Incident"},
|
||||
"grafana-ml-app": {SectionID: navtree.NavIDAlertsAndIncidents, SortWeight: 3, Text: "Machine Learning"},
|
||||
"grafana-cloud-link-app": {SectionID: navtree.NavIDCfg},
|
||||
"grafana-easystart-app": {SectionID: navtree.NavIDRoot, SortWeight: navtree.WeightSavedItems + 1, Text: "Connections"},
|
||||
}
|
||||
|
||||
s.navigationAppPathConfig = map[string]NavigationAppConfig{
|
||||
|
||||
Reference in New Issue
Block a user