DEV: Convert `site-setting-default-categories` modal to component-based API (#22968)
This commit is contained in:
parent
e7dee94c5c
commit
c280c1c52b
|
@ -0,0 +1,23 @@
|
|||
<DModal
|
||||
class="incoming-emails"
|
||||
@title={{html-safe @model.siteSetting.key}}
|
||||
@closeModal={{this.cancel}}
|
||||
>
|
||||
<:body>
|
||||
{{i18n
|
||||
"admin.site_settings.default_categories.modal_description"
|
||||
count=@model.siteSetting.count
|
||||
}}
|
||||
</:body>
|
||||
<:footer>
|
||||
<DButton
|
||||
@action={{this.updateExistingUsers}}
|
||||
class="btn-primary"
|
||||
@label="admin.site_settings.default_categories.modal_yes"
|
||||
/>
|
||||
<DButton
|
||||
@action={{this.cancel}}
|
||||
@label="admin.site_settings.default_categories.modal_no"
|
||||
/>
|
||||
</:footer>
|
||||
</DModal>
|
|
@ -0,0 +1,16 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default class SiteSettingDefaultCategories extends Component {
|
||||
@action
|
||||
updateExistingUsers() {
|
||||
this.args.model.setUpdateExistingUsers(true);
|
||||
this.args.closeModal();
|
||||
}
|
||||
|
||||
@action
|
||||
cancel() {
|
||||
this.args.model.setUpdateExistingUsers(false);
|
||||
this.args.closeModal();
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
import Controller from "@ember/controller";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import ModalUpdateExistingUsers from "discourse/mixins/modal-update-existing-users";
|
||||
|
||||
export default class SiteSettingDefaultCategoriesController extends Controller.extend(
|
||||
ModalFunctionality,
|
||||
ModalUpdateExistingUsers
|
||||
) {}
|
|
@ -7,10 +7,11 @@ import { ajax } from "discourse/lib/ajax";
|
|||
import { categoryLinkHTML } from "discourse/helpers/category-link";
|
||||
import discourseComputed, { bind } from "discourse-common/utils/decorators";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import { warn } from "@ember/debug";
|
||||
import { action } from "@ember/object";
|
||||
import { splitString } from "discourse/lib/utilities";
|
||||
import { inject as service } from "@ember/service";
|
||||
import SiteSettingDefaultCategoriesModal from "../components/modal/site-setting-default-categories";
|
||||
|
||||
const CUSTOM_TYPES = [
|
||||
"bool",
|
||||
|
@ -74,6 +75,8 @@ const DEFAULT_USER_PREFERENCES = [
|
|||
];
|
||||
|
||||
export default Mixin.create({
|
||||
modal: service(),
|
||||
site: service(),
|
||||
attributeBindings: ["setting.setting:data-setting"],
|
||||
classNameBindings: [":row", ":setting", "overridden", "typeClass"],
|
||||
validationMessage: null,
|
||||
|
@ -190,22 +193,24 @@ export default Mixin.create({
|
|||
});
|
||||
|
||||
const count = result.user_count;
|
||||
|
||||
if (count > 0) {
|
||||
const controller = showModal("site-setting-default-categories", {
|
||||
model: { count, key: key.replaceAll("_", " ") },
|
||||
admin: true,
|
||||
});
|
||||
|
||||
controller.set("onClose", () => {
|
||||
this.updateExistingUsers = controller.updateExistingUsers;
|
||||
this.save();
|
||||
await this.modal.show(SiteSettingDefaultCategoriesModal, {
|
||||
model: {
|
||||
siteSetting: { count, key: key.replaceAll("_", " ") },
|
||||
setUpdateExistingUsers: this.setUpdateExistingUsers,
|
||||
},
|
||||
});
|
||||
this.save();
|
||||
} else {
|
||||
await this.save();
|
||||
}
|
||||
},
|
||||
|
||||
@action
|
||||
setUpdateExistingUsers(value) {
|
||||
this.updateExistingUsers = value;
|
||||
},
|
||||
|
||||
@action
|
||||
async save() {
|
||||
try {
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<DModalBody @class="incoming-emails" @rawTitle={{this.model.key}}>
|
||||
{{i18n
|
||||
"admin.site_settings.default_categories.modal_description"
|
||||
count=this.model.count
|
||||
}}
|
||||
</DModalBody>
|
||||
|
||||
<div class="modal-footer">
|
||||
<DButton
|
||||
@action={{action "updateExistingUsers"}}
|
||||
@class="btn-primary"
|
||||
@label="admin.site_settings.default_categories.modal_yes"
|
||||
/>
|
||||
<DButton
|
||||
@action={{action "cancel"}}
|
||||
@label="admin.site_settings.default_categories.modal_no"
|
||||
/>
|
||||
</div>
|
|
@ -1,19 +0,0 @@
|
|||
import Mixin from "@ember/object/mixin";
|
||||
|
||||
export default Mixin.create({
|
||||
onShow() {
|
||||
this.set("updateExistingUsers", null);
|
||||
},
|
||||
|
||||
actions: {
|
||||
updateExistingUsers() {
|
||||
this.set("updateExistingUsers", true);
|
||||
this.send("closeModal");
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.set("updateExistingUsers", false);
|
||||
this.send("closeModal");
|
||||
},
|
||||
},
|
||||
});
|
|
@ -48,7 +48,6 @@ const KNOWN_LEGACY_MODALS = [
|
|||
"topic-summary",
|
||||
"user-status",
|
||||
"admin-penalize-user",
|
||||
"site-setting-default-categories",
|
||||
"admin-badge-preview",
|
||||
"admin-edit-badge-groupings",
|
||||
"admin-reseed",
|
||||
|
|
Loading…
Reference in New Issue