mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
FIX: Sort plugins by their setting category name (#25128)
Some plugins have names (e.g. discourse-x-yz) that are totally different from what they are actually called, and that causes issues when showing them in a sorted way in the admin plugin list. Now, we should use the setting category name from client.en.yml if it exists, otherwise fall back to the name, for sorting. This is what we do on the client to determine what text to show for the plugin name as well.
This commit is contained in:
@ -122,7 +122,11 @@ class Plugin::Instance
|
||||
@enabled_site_setting ? SiteSetting.get(@enabled_site_setting) : true
|
||||
end
|
||||
|
||||
delegate :name, :name_without_prefix, to: :metadata
|
||||
delegate :name, to: :metadata
|
||||
|
||||
def humanized_name
|
||||
(setting_category_name || name).delete_prefix("Discourse ").delete_prefix("discourse-")
|
||||
end
|
||||
|
||||
def add_to_serializer(
|
||||
serializer,
|
||||
@ -1369,6 +1373,16 @@ class Plugin::Instance
|
||||
|
||||
private
|
||||
|
||||
def setting_category
|
||||
return if @enabled_site_setting.blank?
|
||||
SiteSetting.categories[enabled_site_setting]
|
||||
end
|
||||
|
||||
def setting_category_name
|
||||
return if setting_category.blank? || setting_category == "plugins"
|
||||
I18n.t("admin_js.admin.site_settings.categories.#{setting_category}")
|
||||
end
|
||||
|
||||
def validate_directory_column_name(column_name)
|
||||
match = /\A[_a-z]+\z/.match(column_name)
|
||||
unless match
|
||||
|
Reference in New Issue
Block a user