FEATURE: More flexible admin plugin config nav definition (#26254)

This commit changes the API for registering the plugin config
page nav configuration from a server-side to a JS one;
there is no need for it to be server-side.

It also makes some changes to allow for 2 different ways of displaying
navigation for plugin pages, depending on complexity:

* TOP - This is the best mode for simple plugins without a lot of different
  custom configuration pages, and it reuses the grey horizontal nav bar
  already used for admins.
* SIDEBAR - This is better for more complex plugins; likely this won't
  be used in the near future, but it's readily available if needed

There is a new AdminPluginConfigNavManager service too to manage which
plugin the admin is actively viewing, otherwise we would have trouble
hiding the main plugin nav for admins when viewing a single plugin.
This commit is contained in:
Martin Brennan
2024-03-21 13:42:06 +10:00
committed by GitHub
parent e5566b8519
commit 70f7c0ee6f
17 changed files with 268 additions and 120 deletions

View File

@ -999,30 +999,4 @@ TEXT
expect(sum).to eq(3)
end
end
describe "#register_admin_config_nav_routes" do
let(:plugin) { Plugin::Instance.new }
it "adds the specified plugin id as the 'model' for the route" do
plugin.register_admin_config_nav_routes(
"discourse-awesome",
[{ route: "adminPlugins.show", label: "some.i18n.label" }],
)
expect(plugin.admin_config_nav_routes).to eq(
[{ route: "adminPlugins.show", label: "some.i18n.label", model: "discourse-awesome" }],
)
end
it "errors if the route or label is not provided" do
expect {
plugin.register_admin_config_nav_routes("discourse-awesome", [{ label: "some.i18n.label" }])
}.to raise_error(ArgumentError)
expect {
plugin.register_admin_config_nav_routes(
"discourse-awesome",
[{ route: "adminPlugins.show" }],
)
}.to raise_error(ArgumentError)
end
end
end