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:
Levente Balogh
2022-10-06 12:57:03 +02:00
committed by GitHub
co-authored by Torkel Ödegaard
parent b1df15c4b9
commit 55187ebc48
4 changed files with 49 additions and 7 deletions
@@ -180,7 +180,7 @@ func TestReadingNavigationSettings(t *testing.T) {
cfg: setting.NewCfg(),
}
_, _ = service.cfg.Raw.NewSection("navigation.apps")
_, _ = service.cfg.Raw.NewSection("navigation.app_sections")
service.readNavigationSettings()
require.Equal(t, "monitoring", service.navigationAppConfig["grafana-k8s-app"].SectionID)
@@ -191,9 +191,11 @@ func TestReadingNavigationSettings(t *testing.T) {
cfg: setting.NewCfg(),
}
sec, _ := service.cfg.Raw.NewSection("navigation.apps")
_, _ = sec.NewKey("grafana-k8s-app", "dashboards")
_, _ = sec.NewKey("other-app", "admin 12")
appSections, _ := service.cfg.Raw.NewSection("navigation.app_sections")
appStandalonePages, _ := service.cfg.Raw.NewSection("navigation.app_standalone_pages")
_, _ = appSections.NewKey("grafana-k8s-app", "dashboards")
_, _ = appSections.NewKey("other-app", "admin 12")
_, _ = appStandalonePages.NewKey("/a/grafana-k8s-app/foo", "admin 30")
service.readNavigationSettings()
@@ -202,5 +204,8 @@ func TestReadingNavigationSettings(t *testing.T) {
require.Equal(t, int64(0), service.navigationAppConfig["grafana-k8s-app"].SortWeight)
require.Equal(t, int64(12), service.navigationAppConfig["other-app"].SortWeight)
require.Equal(t, "admin", service.navigationAppPathConfig["/a/grafana-k8s-app/foo"].SectionID)
require.Equal(t, int64(30), service.navigationAppPathConfig["/a/grafana-k8s-app/foo"].SortWeight)
})
}