Navtree: Make it possible to configure standalone plugin pages (#56393)
* feat: make it possible to register standalone app plugin pages under different sections * refactor(sample.ini): use "admin" instead of "starred" section in the INI Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * feat(defaults.ini): add app navigation settings to the defaults.ini as well * fix: use the correct key in the tests Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
co-authored by
Torkel Ödegaard
parent
b1df15c4b9
commit
55187ebc48
@@ -214,12 +214,13 @@ func (s *ServiceImpl) readNavigationSettings() {
|
||||
"/a/grafana-auth-app": {SectionID: navtree.NavIDCfg, SortWeight: 7},
|
||||
}
|
||||
|
||||
sec := s.cfg.Raw.Section("navigation.apps")
|
||||
appSections := s.cfg.Raw.Section("navigation.app_sections")
|
||||
appStandalonePages := s.cfg.Raw.Section("navigation.app_standalone_pages")
|
||||
|
||||
for _, key := range sec.Keys() {
|
||||
for _, key := range appSections.Keys() {
|
||||
pluginId := key.Name()
|
||||
// Support <id> <weight> value
|
||||
values := util.SplitString(sec.Key(key.Name()).MustString(""))
|
||||
values := util.SplitString(appSections.Key(key.Name()).MustString(""))
|
||||
|
||||
appCfg := &NavigationAppConfig{SectionID: values[0]}
|
||||
if len(values) > 1 {
|
||||
@@ -230,4 +231,19 @@ func (s *ServiceImpl) readNavigationSettings() {
|
||||
|
||||
s.navigationAppConfig[pluginId] = *appCfg
|
||||
}
|
||||
|
||||
for _, key := range appStandalonePages.Keys() {
|
||||
url := key.Name()
|
||||
// Support <id> <weight> value
|
||||
values := util.SplitString(appStandalonePages.Key(key.Name()).MustString(""))
|
||||
|
||||
appCfg := &NavigationAppConfig{SectionID: values[0]}
|
||||
if len(values) > 1 {
|
||||
if weight, err := strconv.ParseInt(values[1], 10, 64); err == nil {
|
||||
appCfg.SortWeight = weight
|
||||
}
|
||||
}
|
||||
|
||||
s.navigationAppPathConfig[url] = *appCfg
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user