2020-04-22 04:37:51 -04:00
|
|
|
import Controller, { inject as controller } from "@ember/controller";
|
2021-02-02 15:46:48 -05:00
|
|
|
import I18n from "I18n";
|
2020-04-22 04:37:51 -04:00
|
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
2021-02-01 05:07:11 -05:00
|
|
|
import { action, get } from "@ember/object";
|
2020-04-22 04:37:51 -04: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"),
|
|
|
|
|
|
|
|
onShow() {
|
|
|
|
this.set("targetUsername", null);
|
|
|
|
},
|
|
|
|
|
|
|
|
@discourseComputed("username", "targetUsername")
|
|
|
|
mergeDisabled(username, targetUsername) {
|
|
|
|
return !targetUsername || username === targetUsername;
|
|
|
|
},
|
|
|
|
|
2021-02-02 15:46:48 -05:00
|
|
|
@discourseComputed("username")
|
|
|
|
mergeButtonText(username) {
|
|
|
|
return I18n.t(`admin.user.merge.confirmation.transfer_and_delete`, {
|
|
|
|
username,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-04-30 11:29:33 -04:00
|
|
|
@action
|
|
|
|
showConfirmation() {
|
|
|
|
this.send("closeModal");
|
|
|
|
this.adminUserIndex.send("showMergeConfirmation", this.targetUsername);
|
|
|
|
},
|
2020-04-22 04:37:51 -04:00
|
|
|
|
2020-04-30 11:29:33 -04:00
|
|
|
@action
|
|
|
|
close() {
|
|
|
|
this.send("closeModal");
|
2020-04-22 04:37:51 -04:00
|
|
|
},
|
2021-02-01 05:07:11 -05:00
|
|
|
|
|
|
|
@action
|
|
|
|
updateUsername(selected) {
|
|
|
|
this.set("targetUsername", get(selected, "firstObject"));
|
|
|
|
},
|
2020-04-22 04:37:51 -04:00
|
|
|
});
|