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