Files
discourse/app/assets/javascripts/admin/controllers/modals/admin-merge-users-confirmation.js
Vinoth Kannan 71241a50f7 DEV: improve code readability & add tests for user guardian.
a511bea4cc3f50bd1e067a46bdbf5cd19eb335a3
2020-04-30 20:59:33 +05:30

40 lines
1004 B
JavaScript

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