2023-03-16 01:39:33 +08:00
|
|
|
import { alias } from "@ember/object/computed";
|
2020-04-22 16:37:51 +08:00
|
|
|
import Controller, { inject as controller } from "@ember/controller";
|
2021-02-03 04:46:48 +08:00
|
|
|
import I18n from "I18n";
|
2020-04-22 16:37:51 +08:00
|
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
2021-02-01 18:07:11 +08:00
|
|
|
import { action, get } from "@ember/object";
|
2020-04-22 16:37:51 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
|
2023-03-16 01:39:33 +08:00
|
|
|
export default class AdminMergeUsersPromptController extends Controller.extend(
|
|
|
|
ModalFunctionality
|
|
|
|
) {
|
|
|
|
@controller adminUserIndex;
|
|
|
|
|
|
|
|
@alias("model.username") username;
|
2020-04-22 16:37:51 +08:00
|
|
|
|
|
|
|
onShow() {
|
|
|
|
this.set("targetUsername", null);
|
2023-03-16 01:39:33 +08:00
|
|
|
}
|
2020-04-22 16:37:51 +08:00
|
|
|
|
|
|
|
@discourseComputed("username", "targetUsername")
|
|
|
|
mergeDisabled(username, targetUsername) {
|
|
|
|
return !targetUsername || username === targetUsername;
|
2023-03-16 01:39:33 +08:00
|
|
|
}
|
2020-04-22 16:37:51 +08:00
|
|
|
|
2021-02-03 04:46:48 +08:00
|
|
|
@discourseComputed("username")
|
|
|
|
mergeButtonText(username) {
|
|
|
|
return I18n.t(`admin.user.merge.confirmation.transfer_and_delete`, {
|
|
|
|
username,
|
|
|
|
});
|
2023-03-16 01:39:33 +08:00
|
|
|
}
|
2021-02-03 04:46:48 +08:00
|
|
|
|
2020-04-30 23:29:33 +08:00
|
|
|
@action
|
|
|
|
showConfirmation() {
|
|
|
|
this.send("closeModal");
|
|
|
|
this.adminUserIndex.send("showMergeConfirmation", this.targetUsername);
|
2023-03-16 01:39:33 +08:00
|
|
|
}
|
2020-04-22 16:37:51 +08:00
|
|
|
|
2020-04-30 23:29:33 +08:00
|
|
|
@action
|
|
|
|
close() {
|
|
|
|
this.send("closeModal");
|
2023-03-16 01:39:33 +08:00
|
|
|
}
|
2021-02-01 18:07:11 +08:00
|
|
|
|
|
|
|
@action
|
|
|
|
updateUsername(selected) {
|
|
|
|
this.set("targetUsername", get(selected, "firstObject"));
|
2023-03-16 01:39:33 +08:00
|
|
|
}
|
|
|
|
}
|