Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: update action should be in setting-component mixin #8287

Merged
merged 1 commit into from Nov 2, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -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(() => {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.