2020-04-22 16:37:51 +08:00
|
|
|
import Controller, { inject as controller } from "@ember/controller";
|
2020-05-14 04:23:41 +08:00
|
|
|
import I18n from "I18n";
|
2020-04-22 16:37:51 +08:00
|
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
2020-04-30 23:29:33 +08:00
|
|
|
import { action } from "@ember/object";
|
2020-04-22 16:37:51 +08:00
|
|
|
import { alias } from "@ember/object/computed";
|
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
|
|
|
|
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) {
|
2020-04-30 23:29:33 +08:00
|
|
|
return I18n.t(`admin.user.merge.confirmation.text`, {
|
|
|
|
username,
|
|
|
|
targetUsername,
|
|
|
|
});
|
2020-04-22 16:37:51 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
@discourseComputed("value", "text")
|
|
|
|
mergeDisabled(value, text) {
|
|
|
|
return !value || text !== value;
|
|
|
|
},
|
|
|
|
|
2020-04-30 23:29:33 +08:00
|
|
|
@action
|
|
|
|
confirm() {
|
|
|
|
this.adminUserIndex.send("merge", this.targetUsername);
|
|
|
|
this.send("closeModal");
|
|
|
|
},
|
2020-04-22 16:37:51 +08:00
|
|
|
|
2020-04-30 23:29:33 +08:00
|
|
|
@action
|
|
|
|
close() {
|
|
|
|
this.send("closeModal");
|
2020-04-22 16:37:51 +08:00
|
|
|
},
|
|
|
|
});
|