From fed7218deba108f6ab7d261f26fcfcfda18c20d4 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 9 Jan 2017 13:56:15 +0800 Subject: [PATCH] UX: Observe changes to plugin to hide/show plugin admin link without refresh. --- .../admin/controllers/admin-plugins.js.es6 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin-plugins.js.es6 b/app/assets/javascripts/admin/controllers/admin-plugins.js.es6 index 5393a27c8f6..6d6dadc4ced 100644 --- a/app/assets/javascripts/admin/controllers/admin-plugins.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-plugins.js.es6 @@ -1,9 +1,16 @@ +import computed from 'ember-addons/ember-computed-decorators'; + export default Ember.Controller.extend({ - adminRoutes: function() { - return this.get('model').map(p => { - if (p.get('enabled')) { - return p.admin_route; + @computed('model.@each.enabled_setting') + adminRoutes() { + let routes = [] + + this.get('model').forEach(p => { + if (this.siteSettings[p.get('enabled_setting')] && p.get('admin_route')) { + routes.push(p.get('admin_route')); } - }).compact(); - }.property() + }); + + return routes; + } });