FEATURE: admin UI to merge two users. (#9509)
This commit is contained in:
@@ -9,6 +9,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { fmt } from "discourse/lib/computed";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
|
||||
export default Controller.extend(CanCheckEmails, {
|
||||
adminTools: service(),
|
||||
@@ -207,6 +208,27 @@ export default Controller.extend(CanCheckEmails, {
|
||||
}
|
||||
},
|
||||
|
||||
promptTargetUser() {
|
||||
showModal("admin-merge-users-prompt", {
|
||||
admin: true,
|
||||
model: this.model
|
||||
});
|
||||
},
|
||||
|
||||
showMergeConfirmation(targetUsername) {
|
||||
showModal("admin-merge-users-confirmation", {
|
||||
admin: true,
|
||||
model: {
|
||||
username: this.model.username,
|
||||
targetUsername: targetUsername
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
merge(targetUsername) {
|
||||
return this.model.merge({ targetUsername: targetUsername });
|
||||
},
|
||||
|
||||
viewActionLogs() {
|
||||
this.adminTools.showActionLogs(this, {
|
||||
target_user: this.get("model.username")
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
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";
|
||||
|
||||
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 `transfer @${username} to @${targetUsername}`;
|
||||
},
|
||||
|
||||
@discourseComputed("value", "text")
|
||||
mergeDisabled(value, text) {
|
||||
return !value || text !== value;
|
||||
},
|
||||
|
||||
actions: {
|
||||
merge() {
|
||||
this.adminUserIndex.send("merge", this.targetUsername);
|
||||
this.send("closeModal");
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.send("closeModal");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
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";
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
actions: {
|
||||
merge() {
|
||||
this.send("closeModal");
|
||||
this.adminUserIndex.send("showMergeConfirmation", this.targetUsername);
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.send("closeModal");
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user