NavTree: Make it possible to configure where in nav tree plugins live (#55484)

* NewIA: Plugin nav config

* progress

* Progress

* Things are working

* Add monitoring node

* Add alerts and incidents

* added experiment with standalone page

* Refactoring by adding a type for navtree root

* First test working

* More tests

* more tests

* Progress on richer config and sorting

* Sort weight working

* Path config

* Improving logic for not including admin or cfg nodes, making it the last step so that enterprise can add admin nodes without having to worry about the section not existing

* fixed index routes

* removed file

* Fixes

* Fixing tests

* Fixing more tests and adding support for weight config

* Updates

* Remove unused fake

* More fixes

* Minor tweak

* Minor fix

* Can now control position using sortweight even when existing items have no sortweight

* Added tests for frontend standalone page logic

* more tests

* Remove unused fake and fixed lint issue

* Moving reading settings to navtree impl package

* remove nav_id setting prefix

* Remove old test file

* Fix trailing newline

* Fixed bug with adding nil node

* fixing lint issue

* remove some code we have to rethink

* move read settings to PrivideService and switch to util.SplitString
This commit is contained in:
Torkel Ödegaard
2022-09-28 08:29:35 +02:00
committed by GitHub
parent 202dce66ff
commit e31cb93ec0
33 changed files with 1064 additions and 586 deletions

View File

@@ -19,10 +19,11 @@ func TestPluginUpdateChecker_HasUpdate(t *testing.T) {
availableUpdates: map[string]string{
"test-ds": "1.0.0",
},
pluginStore: fakePluginStore{
plugins: map[string]plugins.PluginDTO{
"test-ds": {
pluginStore: plugins.FakePluginStore{
PluginList: []plugins.PluginDTO{
{
JSONData: plugins.JSONData{
ID: "test-ds",
Info: plugins.Info{Version: "0.9.0"},
},
},
@@ -41,20 +42,23 @@ func TestPluginUpdateChecker_HasUpdate(t *testing.T) {
"test-panel": "0.9.0",
"test-app": "0.0.1",
},
pluginStore: fakePluginStore{
plugins: map[string]plugins.PluginDTO{
"test-ds": {
pluginStore: plugins.FakePluginStore{
PluginList: []plugins.PluginDTO{
{
JSONData: plugins.JSONData{
ID: "test-ds",
Info: plugins.Info{Version: "0.9.0"},
},
},
"test-panel": {
{
JSONData: plugins.JSONData{
ID: "test-panel",
Info: plugins.Info{Version: "0.9.0"},
},
},
"test-app": {
{
JSONData: plugins.JSONData{
ID: "test-app",
Info: plugins.Info{Version: "0.9.0"},
},
},
@@ -80,10 +84,11 @@ func TestPluginUpdateChecker_HasUpdate(t *testing.T) {
availableUpdates: map[string]string{
"test-panel": "0.9.0",
},
pluginStore: fakePluginStore{
plugins: map[string]plugins.PluginDTO{
"test-ds": {
pluginStore: plugins.FakePluginStore{
PluginList: []plugins.PluginDTO{
{
JSONData: plugins.JSONData{
ID: "test-ds",
Info: plugins.Info{Version: "1.0.0"},
},
},
@@ -122,31 +127,35 @@ func TestPluginUpdateChecker_checkForUpdates(t *testing.T) {
availableUpdates: map[string]string{
"test-app": "1.0.0",
},
pluginStore: fakePluginStore{
plugins: map[string]plugins.PluginDTO{
"test-ds": {
pluginStore: plugins.FakePluginStore{
PluginList: []plugins.PluginDTO{
{
JSONData: plugins.JSONData{
ID: "test-ds",
Info: plugins.Info{Version: "0.9.0"},
Type: plugins.DataSource,
},
},
"test-app": {
{
JSONData: plugins.JSONData{
ID: "test-app",
Info: plugins.Info{Version: "0.5.0"},
Type: plugins.App,
},
},
"test-panel": {
{
JSONData: plugins.JSONData{
ID: "test-panel",
Info: plugins.Info{Version: "2.5.7"},
Type: plugins.Panel,
},
},
"test-core-panel": {
{
Class: plugins.Core,
JSONData: plugins.JSONData{
ID: "test-core-panel",
Info: plugins.Info{Version: "0.0.1"},
Type: plugins.Panel,
},
},
},
@@ -195,23 +204,3 @@ func (c *fakeHTTPClient) Get(url string) (*http.Response, error) {
return resp, nil
}
type fakePluginStore struct {
plugins.Store
plugins map[string]plugins.PluginDTO
}
func (pr fakePluginStore) Plugin(_ context.Context, pluginID string) (plugins.PluginDTO, bool) {
p, exists := pr.plugins[pluginID]
return p, exists
}
func (pr fakePluginStore) Plugins(_ context.Context, _ ...plugins.Type) []plugins.PluginDTO {
var result []plugins.PluginDTO
for _, p := range pr.plugins {
result = append(result, p)
}
return result
}