mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:02:46 +08:00
UX: Display site settings shortcut for poll
and discourse-nginx-performance-report
.
https://meta.discourse.org/t/improving-admin-plugins/84585/29?u=tgxworld
This commit is contained in:
parent
2002a7c4ef
commit
8cf0f51eb2
|
@ -8,12 +8,15 @@ export default Ember.Route.extend({
|
|||
const controller = this.controllerFor('adminSiteSettings');
|
||||
this.transitionTo('adminSiteSettingsCategory', 'plugins').then(() => {
|
||||
if (plugin) {
|
||||
const siteSettingFilter = plugin.get('enabled_setting_filter');
|
||||
const match = /^(.*)_enabled/.exec(plugin.get('enabled_setting'));
|
||||
if (match[1]) {
|
||||
const filter = siteSettingFilter || match[1];
|
||||
|
||||
if (filter) {
|
||||
// filterContent() is normally on a debounce from typing.
|
||||
// Because we don't want the default of "All Results", we tell it
|
||||
// to skip the next debounce.
|
||||
controller.set('filter', match[1]);
|
||||
controller.set('filter', filter);
|
||||
controller.set('_skipBounce', true);
|
||||
controller.filterContentNow('plugins');
|
||||
}
|
||||
|
@ -22,4 +25,3 @@ export default Ember.Route.extend({
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ class AdminPluginSerializer < ApplicationSerializer
|
|||
:admin_route,
|
||||
:enabled,
|
||||
:enabled_setting,
|
||||
:is_official
|
||||
:is_official,
|
||||
:enabled_setting_filter
|
||||
|
||||
def id
|
||||
object.metadata.name
|
||||
|
@ -28,12 +29,20 @@ class AdminPluginSerializer < ApplicationSerializer
|
|||
object.enabled?
|
||||
end
|
||||
|
||||
def enabled_setting
|
||||
def include_enabled_setting?
|
||||
object.enabled_site_setting
|
||||
end
|
||||
|
||||
def include_enabled_setting?
|
||||
enabled_setting.present?
|
||||
def enabled_setting
|
||||
true
|
||||
end
|
||||
|
||||
def include_enabled_setting_filter?
|
||||
object.enabled_site_setting_filter.present?
|
||||
end
|
||||
|
||||
def enabled_setting_filter
|
||||
object.enabled_site_setting_filter
|
||||
end
|
||||
|
||||
def include_url?
|
||||
|
|
|
@ -493,6 +493,14 @@ JS
|
|||
PluginGem.load(path, name, version, opts)
|
||||
end
|
||||
|
||||
def enabled_site_setting_filter(filter = nil)
|
||||
if filter
|
||||
@enabled_setting_filter = filter
|
||||
else
|
||||
@enabled_setting_filter
|
||||
end
|
||||
end
|
||||
|
||||
def enabled_site_setting(setting = nil)
|
||||
if setting
|
||||
@enabled_site_setting = setting
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
# version: 0.1
|
||||
# url: https://github.com/discourse/discourse/tree/master/plugins/discourse-nginx-performance-report
|
||||
|
||||
enabled_site_setting :daily_performance_report
|
||||
enabled_site_setting_filter "daily_performance_report"
|
||||
|
||||
after_initialize do
|
||||
load File.expand_path("../app/jobs/scheduled/daily_performance_report.rb", __FILE__)
|
||||
end
|
||||
|
|
|
@ -9,6 +9,8 @@ register_asset "stylesheets/common/poll-ui-builder.scss"
|
|||
register_asset "stylesheets/desktop/poll.scss", :desktop
|
||||
register_asset "stylesheets/mobile/poll.scss", :mobile
|
||||
|
||||
enabled_site_setting :poll_enabled
|
||||
|
||||
PLUGIN_NAME ||= "discourse_poll".freeze
|
||||
DATA_PREFIX ||= "data-poll-".freeze
|
||||
|
||||
|
|
|
@ -381,4 +381,19 @@ describe Plugin::Instance do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#enabled_site_setting_filter' do
|
||||
describe 'when filter is blank' do
|
||||
it 'should return the right value' do
|
||||
expect(Plugin::Instance.new.enabled_site_setting_filter).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should set the right value' do
|
||||
instance = Plugin::Instance.new
|
||||
instance.enabled_site_setting_filter('test')
|
||||
|
||||
expect(instance.enabled_site_setting_filter).to eq('test')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user