FIX: update action should be in setting-component mixin (#8287)
This was causing an exception on some component (eg: value-list in a theme-component setting) which couldn't find an action named update.
This commit is contained in:
parent
2cb805a683
commit
8d69944b4e
|
@ -2,8 +2,6 @@ import Component from "@ember/component";
|
|||
import BufferedContent from "discourse/mixins/buffered-content";
|
||||
import SiteSetting from "admin/models/site-setting";
|
||||
import SettingComponent from "admin/mixins/setting-component";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import AboutRoute from "discourse/routes/about";
|
||||
|
||||
export default Component.extend(BufferedContent, SettingComponent, {
|
||||
updateExistingUsers: null,
|
||||
|
@ -13,62 +11,5 @@ export default Component.extend(BufferedContent, SettingComponent, {
|
|||
return SiteSetting.update(setting.get("setting"), setting.get("value"), {
|
||||
updateExistingUsers: this.updateExistingUsers
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
update() {
|
||||
const defaultUserPreferences = [
|
||||
"default_email_digest_frequency",
|
||||
"default_include_tl0_in_digests",
|
||||
"default_email_level",
|
||||
"default_email_messages_level",
|
||||
"default_email_mailing_list_mode",
|
||||
"default_email_mailing_list_mode_frequency",
|
||||
"disable_mailing_list_mode",
|
||||
"default_email_previous_replies",
|
||||
"default_email_in_reply_to",
|
||||
"default_other_new_topic_duration_minutes",
|
||||
"default_other_auto_track_topics_after_msecs",
|
||||
"default_other_notification_level_when_replying",
|
||||
"default_other_external_links_in_new_tab",
|
||||
"default_other_enable_quoting",
|
||||
"default_other_enable_defer",
|
||||
"default_other_dynamic_favicon",
|
||||
"default_other_like_notification_frequency",
|
||||
"default_topics_automatic_unpin",
|
||||
"default_categories_watching",
|
||||
"default_categories_tracking",
|
||||
"default_categories_muted",
|
||||
"default_categories_watching_first_post",
|
||||
"default_tags_watching",
|
||||
"default_tags_tracking",
|
||||
"default_tags_muted",
|
||||
"default_tags_watching_first_post",
|
||||
"default_text_size",
|
||||
"default_title_count_mode"
|
||||
];
|
||||
const key = this.buffered.get("setting");
|
||||
|
||||
if (defaultUserPreferences.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 {
|
||||
this.send("save");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,6 +3,8 @@ import computed from "ember-addons/ember-computed-decorators";
|
|||
import { categoryLinkHTML } from "discourse/helpers/category-link";
|
||||
import { on } from "@ember/object/evented";
|
||||
import Mixin from "@ember/object/mixin";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import AboutRoute from "discourse/routes/about";
|
||||
|
||||
const CUSTOM_TYPES = [
|
||||
"bool",
|
||||
|
@ -114,6 +116,61 @@ export default Mixin.create({
|
|||
},
|
||||
|
||||
actions: {
|
||||
update() {
|
||||
const defaultUserPreferences = [
|
||||
"default_email_digest_frequency",
|
||||
"default_include_tl0_in_digests",
|
||||
"default_email_level",
|
||||
"default_email_messages_level",
|
||||
"default_email_mailing_list_mode",
|
||||
"default_email_mailing_list_mode_frequency",
|
||||
"disable_mailing_list_mode",
|
||||
"default_email_previous_replies",
|
||||
"default_email_in_reply_to",
|
||||
"default_other_new_topic_duration_minutes",
|
||||
"default_other_auto_track_topics_after_msecs",
|
||||
"default_other_notification_level_when_replying",
|
||||
"default_other_external_links_in_new_tab",
|
||||
"default_other_enable_quoting",
|
||||
"default_other_enable_defer",
|
||||
"default_other_dynamic_favicon",
|
||||
"default_other_like_notification_frequency",
|
||||
"default_topics_automatic_unpin",
|
||||
"default_categories_watching",
|
||||
"default_categories_tracking",
|
||||
"default_categories_muted",
|
||||
"default_categories_watching_first_post",
|
||||
"default_tags_watching",
|
||||
"default_tags_tracking",
|
||||
"default_tags_muted",
|
||||
"default_tags_watching_first_post",
|
||||
"default_text_size",
|
||||
"default_title_count_mode"
|
||||
];
|
||||
const key = this.buffered.get("setting");
|
||||
|
||||
if (defaultUserPreferences.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 {
|
||||
this.send("save");
|
||||
}
|
||||
},
|
||||
|
||||
save() {
|
||||
this._save()
|
||||
.then(() => {
|
||||
|
|
Loading…
Reference in New Issue