mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +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() {
|
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 });
|
||||||
});
|
});
|
||||||
|
@ -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
|
||||||
|
@ -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,
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user