DEV: Add configurable? helper to Plugin::Instance (#21472)

This reapplies commit 3073e5cfb0721b3b8009963c5fc7f61d414db317, with
a fix that makes sure that plugins can be looked up both by the name
present in metadata and directory name.
This commit is contained in:
Bianca Nenciu
2023-05-10 15:21:48 +02:00
committed by GitHub
parent b713ae166f
commit d3a5a493fa
6 changed files with 107 additions and 15 deletions

View File

@ -103,7 +103,16 @@ class Plugin::Instance
@admin_route = { label: label, location: location }
end
def configurable?
true
end
def visible?
configurable? && !@hidden
end
def enabled?
return false if !configurable?
@enabled_site_setting ? SiteSetting.get(@enabled_site_setting) : true
end
@ -825,11 +834,7 @@ class Plugin::Instance
end
def hide_plugin
Discourse.hidden_plugins << self
end
def enabled_site_setting_filter(filter = nil)
STDERR.puts("`enabled_site_setting_filter` is deprecated")
@hidden = true
end
def enabled_site_setting(setting = nil)