From 7a264217f20220d8735bacff9bd2dc4ecb9ee671 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Thu, 31 Oct 2019 05:45:57 +0530 Subject: [PATCH] FIX: default user preferenced categories are not updating in admin site setting UI. --- .../admin/components/site-setting.js.es6 | 58 +++++++++++-------- .../templates/components/site-setting.hbs | 2 +- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/admin/components/site-setting.js.es6 b/app/assets/javascripts/admin/components/site-setting.js.es6 index 0b717f7223c..3c3e394b9f9 100644 --- a/app/assets/javascripts/admin/components/site-setting.js.es6 +++ b/app/assets/javascripts/admin/components/site-setting.js.es6 @@ -6,37 +6,45 @@ import showModal from "discourse/lib/show-modal"; import AboutRoute from "discourse/routes/about"; export default Component.extend(BufferedContent, SettingComponent, { + updateExistingUsers: null, + _save() { - const defaultCategoriesSettings = [ - "default_categories_watching", - "default_categories_tracking", - "default_categories_muted", - "default_categories_watching_first_post" - ]; const setting = this.buffered; - const key = setting.get("setting"); - const value = setting.get("value"); + return SiteSetting.update(setting.get("setting"), setting.get("value"), { + updateExistingUsers: this.updateExistingUsers + }); + }, - if (defaultCategoriesSettings.includes(key)) { - AboutRoute.create() - .model() - .then(result => { - const controller = showModal("site-setting-default-categories", { - model: { - count: result.stats.user_count, - key: key.replace(/_/g, " ") - }, - admin: true - }); + actions: { + update() { + const defaultCategoriesSettings = [ + "default_categories_watching", + "default_categories_tracking", + "default_categories_muted", + "default_categories_watching_first_post" + ]; + const key = this.buffered.get("setting"); - controller.set("onClose", () => { - return SiteSetting.update(key, value, { - updateExistingUsers: controller.updateExistingUsers + if (defaultCategoriesSettings.includes(key)) { + AboutRoute.create() + .model() + .then(result => { + const controller = showModal("site-setting-default-categories", { + model: { + count: result.stats.user_count, + key: key.replace(/_/g, " ") + }, + admin: true + }); + + controller.set("onClose", () => { + this.updateExistingUsers = controller.updateExistingUsers; + this.send("save"); }); }); - }); - } else { - return SiteSetting.update(key, value); + } else { + this.send("save"); + } } } }); diff --git a/app/assets/javascripts/admin/templates/components/site-setting.hbs b/app/assets/javascripts/admin/templates/components/site-setting.hbs index 50fb7d413e4..980c30986cd 100644 --- a/app/assets/javascripts/admin/templates/components/site-setting.hbs +++ b/app/assets/javascripts/admin/templates/components/site-setting.hbs @@ -6,7 +6,7 @@ {{#if dirty}}
- {{d-button class="ok" action=(action "save") icon="check"}} + {{d-button class="ok" action=(action "update") icon="check"}} {{d-button class="cancel" action=(action "cancel") icon="times"}}
{{else if setting.overridden}}