mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 23:31:21 +08:00
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:
@ -35,7 +35,12 @@ export default class AdminPluginsIndexController extends Controller {
|
||||
|
||||
get allAdminRoutes() {
|
||||
return this.model
|
||||
.filter((plugin) => plugin?.enabled && plugin?.adminRoute)
|
||||
.filter(
|
||||
(plugin) =>
|
||||
plugin?.enabled &&
|
||||
plugin?.adminRoute &&
|
||||
!plugin?.adminRoute?.auto_generated
|
||||
)
|
||||
.map((plugin) => {
|
||||
return Object.assign(plugin.adminRoute, { plugin_id: plugin.id });
|
||||
});
|
||||
|
@ -115,6 +115,7 @@ class Plugin::Instance
|
||||
label: label,
|
||||
location: location,
|
||||
use_new_show_route: opts.fetch(:use_new_show_route, false),
|
||||
auto_generated: false,
|
||||
}
|
||||
end
|
||||
|
||||
@ -128,7 +129,7 @@ class Plugin::Instance
|
||||
end
|
||||
|
||||
route
|
||||
.slice(:location, :label, :use_new_show_route)
|
||||
.slice(:location, :label, :use_new_show_route, :auto_generated)
|
||||
.tap do |admin_route|
|
||||
path = admin_route[:use_new_show_route] ? "show" : admin_route[:location]
|
||||
admin_route[:full_location] = "adminPlugins.#{path}"
|
||||
@ -1495,6 +1496,11 @@ class Plugin::Instance
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -28,6 +28,7 @@ RSpec.describe ApplicationController do
|
||||
"location" => "chat",
|
||||
"full_location" => "adminPlugins.show",
|
||||
"use_new_show_route" => true,
|
||||
"auto_generated" => false,
|
||||
},
|
||||
"enabled" => true,
|
||||
},
|
||||
|
Reference in New Issue
Block a user