discourse/app/assets/javascripts/admin/addon/controllers/modals/admin-delete-posts-confirmation.js
David Taylor c190994046
DEV: Update admin modal controllers to native class syntax (#20685)
This commit was generated using the ember-native-class-codemod along with a handful of manual updates
2023-03-15 17:39:33 +00:00

50 lines
1.2 KiB
JavaScript

import { alias } from "@ember/object/computed";
import Controller, { inject as controller } from "@ember/controller";
import I18n from "I18n";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { action } from "@ember/object";
import discourseComputed from "discourse-common/utils/decorators";
export default class AdminDeletePostsConfirmationController extends Controller.extend(
ModalFunctionality
) {
@controller adminUserIndex;
@alias("model.username") username;
@alias("model.post_count") postCount;
onShow() {
this.set("value", null);
}
@discourseComputed("username", "postCount")
text(username, postCount) {
return I18n.t(`admin.user.delete_posts.confirmation.text`, {
username,
postCount,
});
}
@discourseComputed("username")
deleteButtonText(username) {
return I18n.t(`admin.user.delete_posts.confirmation.delete`, {
username,
});
}
@discourseComputed("value", "text")
deleteDisabled(value, text) {
return !value || text !== value;
}
@action
confirm() {
this.adminUserIndex.send("deleteAllPosts");
}
@action
close() {
this.send("closeModal");
}
}