DEV: Only include custom admin UIs in the plugins index tabs (#31192)

In the current admin index page, all plugins show up as tabs. This includes plugins with auto-generated config routes.

This changes the tabs to include only plugins with custom UIs.
This commit is contained in:
Ted Johansson
2025-02-05 15:02:46 +08:00
committed by GitHub
parent 5eb7d6d9c0
commit bb12f8275d
3 changed files with 15 additions and 3 deletions

View File

@ -35,7 +35,12 @@ export default class AdminPluginsIndexController extends Controller {
get allAdminRoutes() { get allAdminRoutes() {
return this.model return this.model
.filter((plugin) => plugin?.enabled && plugin?.adminRoute) .filter(
(plugin) =>
plugin?.enabled &&
plugin?.adminRoute &&
!plugin?.adminRoute?.auto_generated
)
.map((plugin) => { .map((plugin) => {
return Object.assign(plugin.adminRoute, { plugin_id: plugin.id }); return Object.assign(plugin.adminRoute, { plugin_id: plugin.id });
}); });

View File

@ -115,6 +115,7 @@ class Plugin::Instance
label: label, label: label,
location: location, location: location,
use_new_show_route: opts.fetch(:use_new_show_route, false), use_new_show_route: opts.fetch(:use_new_show_route, false),
auto_generated: false,
} }
end end
@ -128,7 +129,7 @@ class Plugin::Instance
end end
route route
.slice(:location, :label, :use_new_show_route) .slice(:location, :label, :use_new_show_route, :auto_generated)
.tap do |admin_route| .tap do |admin_route|
path = admin_route[:use_new_show_route] ? "show" : admin_route[:location] path = admin_route[:use_new_show_route] ? "show" : admin_route[:location]
admin_route[:full_location] = "adminPlugins.#{path}" admin_route[:full_location] = "adminPlugins.#{path}"
@ -1495,6 +1496,11 @@ class Plugin::Instance
end end
def default_admin_route def default_admin_route
{ label: "#{name.underscore}.title", location: name, use_new_show_route: true } {
label: "#{name.underscore}.title",
location: name,
use_new_show_route: true,
auto_generated: true,
}
end end
end end

View File

@ -28,6 +28,7 @@ RSpec.describe ApplicationController do
"location" => "chat", "location" => "chat",
"full_location" => "adminPlugins.show", "full_location" => "adminPlugins.show",
"use_new_show_route" => true, "use_new_show_route" => true,
"auto_generated" => false,
}, },
"enabled" => true, "enabled" => true,
}, },