Expose an API for plugins to be hidden on the admin plugin page.

This commit is contained in:
Guo Xiang Tan 2018-05-08 13:24:58 +08:00
parent 086cb0f849
commit c6f45fcfdb
3 changed files with 13 additions and 1 deletions

View File

@ -1,7 +1,7 @@
class Admin::PluginsController < Admin::AdminController class Admin::PluginsController < Admin::AdminController
def index def index
render_serialized(Discourse.plugins, AdminPluginSerializer, root: 'plugins') render_serialized(Discourse.display_plugins, AdminPluginSerializer, root: 'plugins')
end end
end end

View File

@ -164,6 +164,14 @@ module Discourse
@plugins ||= [] @plugins ||= []
end end
def self.hidden_plugins
@hidden_plugins ||= []
end
def self.display_plugins
self.plugins - self.hidden_plugins
end
def self.plugin_themes def self.plugin_themes
@plugin_themes ||= plugins.map(&:themes).flatten @plugin_themes ||= plugins.map(&:themes).flatten
end end

View File

@ -493,6 +493,10 @@ JS
PluginGem.load(path, name, version, opts) PluginGem.load(path, name, version, opts)
end end
def hide_plugin
Discourse.hidden_plugins << self
end
def enabled_site_setting_filter(filter = nil) def enabled_site_setting_filter(filter = nil)
if filter if filter
@enabled_setting_filter = filter @enabled_setting_filter = filter