Merge pull request #3588 from riking/patch-5

FEATURE: "Enabled" column in /admin/plugins
This commit is contained in:
Robin Ward 2015-07-02 14:11:41 -04:00
commit 2d2e2b9924
9 changed files with 84 additions and 10 deletions

View File

@ -1,6 +1,10 @@
export default Ember.ArrayController.extend({ export default Ember.ArrayController.extend({
adminRoutes: function() { adminRoutes: function() {
return this.get('model').map(p => p.admin_route).compact(); return this.get('model').map(function(p) {
if (p.get('enabled')) {
return p.admin_route;
}
}).compact();
}.property() }.property()
}); });

View File

@ -5,8 +5,7 @@ export default Ember.ArrayController.extend(Presence, {
onlyOverridden: false, onlyOverridden: false,
filtered: Ember.computed.notEmpty('filter'), filtered: Ember.computed.notEmpty('filter'),
filterContent: Discourse.debounce(function() { filterContentNow: function(category) {
// If we have no content, don't bother filtering anything // If we have no content, don't bother filtering anything
if (!this.present('allSiteSettings')) return; if (!this.present('allSiteSettings')) return;
@ -48,7 +47,15 @@ export default Ember.ArrayController.extend(Presence, {
}); });
this.set('model', matchesGroupedByCategory); this.set('model', matchesGroupedByCategory);
this.transitionToRoute("adminSiteSettingsCategory", "all_results"); return this.transitionToRoute("adminSiteSettingsCategory", category || "all_results");
},
filterContent: Discourse.debounce(function() {
if (this.get("_skipBounce")) {
this.set("_skipBounce", false);
} else {
this.filterContentNow();
}
}, 250).observes('filter', 'onlyOverridden'), }, 250).observes('filter', 'onlyOverridden'),
actions: { actions: {

View File

@ -4,8 +4,21 @@ export default Ember.Route.extend({
}, },
actions: { actions: {
showSettings() { showSettings(plugin) {
this.transitionTo('adminSiteSettingsCategory', 'plugins'); const controller = this.controllerFor('adminSiteSettings');
this.transitionTo('adminSiteSettingsCategory', 'plugins').then(function() {
if (plugin) {
const match = /^(.*)_enabled/.exec(plugin.get('enabled_setting'));
if (match[1]) {
// 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('_skipBounce', true);
controller.filterContentNow('plugins');
}
}
});
} }
} }
}); });

View File

@ -9,11 +9,13 @@
<br/> <br/>
<table> <table class="admin-plugins">
<thead> <thead>
<tr> <tr>
<th>{{i18n "admin.plugins.name"}}</th> <th>{{i18n "admin.plugins.name"}}</th>
<th>{{i18n "admin.plugins.version"}}</th> <th>{{i18n "admin.plugins.version"}}</th>
<th>{{i18n "admin.plugins.enabled"}}</th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -27,6 +29,25 @@
{{/if}} {{/if}}
</td> </td>
<td>{{plugin.version}}</td> <td>{{plugin.version}}</td>
<td class="col-enabled">
{{#if plugin.enabled_setting}}
{{#if plugin.enabled}}
{{i18n "admin.plugins.is_enabled"}}
{{else}}
{{i18n "admin.plugins.not_enabled"}}
{{/if}}
{{else}}
{{i18n "admin.plugins.cant_disable"}}
{{/if}}
</td>
<td>
{{#if plugin.enabled_setting}}
<button {{action "showSettings" plugin}} class="btn">
{{fa-icon "gear"}}
{{i18n "admin.plugins.change_settings_short"}}
</button>
{{/if}}
</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>

View File

@ -1240,6 +1240,10 @@ table.api-keys {
} }
} }
.admin-plugins .col-enabled {
width: 20px;
}
// Backups // Backups
// -------------------------------------------------- // --------------------------------------------------

View File

@ -3,7 +3,9 @@ class AdminPluginSerializer < ApplicationSerializer
:name, :name,
:version, :version,
:url, :url,
:admin_route :admin_route,
:enabled,
:enabled_setting
def id def id
object.metadata.name object.metadata.name
@ -21,6 +23,18 @@ class AdminPluginSerializer < ApplicationSerializer
object.metadata.url object.metadata.url
end end
def enabled
object.enabled?
end
def enabled_setting
object.enabled_site_setting
end
def include_enabled_setting?
enabled_setting.present?
end
def include_url? def include_url?
url.present? url.present?
end end

View File

@ -1825,7 +1825,12 @@ en:
name: "Name" name: "Name"
none_installed: "You don't have any plugins installed." none_installed: "You don't have any plugins installed."
version: "Version" version: "Version"
enabled: "Enabled?"
is_enabled: "Y"
not_enabled: "N"
cant_disable: "-"
change_settings: "Change Settings" change_settings: "Change Settings"
change_settings_short: "Settings"
howto: "How do I install plugins?" howto: "How do I install plugins?"
backups: backups:

View File

@ -299,8 +299,12 @@ class Plugin::Instance
end end
end end
def enabled_site_setting(setting) def enabled_site_setting(setting=nil)
@enabled_site_setting = setting if setting
@enabled_site_setting = setting
else
@enabled_site_setting
end
end end
protected protected

View File

@ -4,6 +4,8 @@
# authors: Vikhyat Korrapati (vikhyat), Régis Hanol (zogstrip) # authors: Vikhyat Korrapati (vikhyat), Régis Hanol (zogstrip)
# url: https://github.com/discourse/discourse/tree/master/plugins/poll # url: https://github.com/discourse/discourse/tree/master/plugins/poll
enabled_site_setting :poll_enabled
register_asset "stylesheets/common/poll.scss" register_asset "stylesheets/common/poll.scss"
register_asset "stylesheets/desktop/poll.scss", :desktop register_asset "stylesheets/desktop/poll.scss", :desktop
register_asset "stylesheets/mobile/poll.scss", :mobile register_asset "stylesheets/mobile/poll.scss", :mobile