diff --git a/app/assets/javascripts/admin/addon/components/modal/merge-users-confirmation.hbs b/app/assets/javascripts/admin/addon/components/modal/merge-users-confirmation.hbs
new file mode 100644
index 00000000000..a43371867b5
--- /dev/null
+++ b/app/assets/javascripts/admin/addon/components/modal/merge-users-confirmation.hbs
@@ -0,0 +1,36 @@
+
+ <:body>
+
+ {{html-safe
+ (i18n
+ "admin.user.merge.confirmation.description"
+ username=@model.username
+ targetUsername=@model.targetUsername
+ text=this.text
+ )
+ }}
+
+
+
+ <:footer>
+
+
+
+
\ No newline at end of file
diff --git a/app/assets/javascripts/admin/addon/components/modal/merge-users-confirmation.js b/app/assets/javascripts/admin/addon/components/modal/merge-users-confirmation.js
new file mode 100644
index 00000000000..3e3e3f995c6
--- /dev/null
+++ b/app/assets/javascripts/admin/addon/components/modal/merge-users-confirmation.js
@@ -0,0 +1,18 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import I18n from "I18n";
+
+export default class MergeUsersConfirmation extends Component {
+ @tracked value;
+
+ get mergeDisabled() {
+ return !this.value || this.text !== this.value;
+ }
+
+ get text() {
+ return I18n.t("admin.user.merge.confirmation.text", {
+ username: this.args.model.username,
+ targetUsername: this.args.model.targetUsername,
+ });
+ }
+}
diff --git a/app/assets/javascripts/admin/addon/components/modal/merge-users-progress.hbs b/app/assets/javascripts/admin/addon/components/modal/merge-users-progress.hbs
new file mode 100644
index 00000000000..73393291c7d
--- /dev/null
+++ b/app/assets/javascripts/admin/addon/components/modal/merge-users-progress.hbs
@@ -0,0 +1,9 @@
+
+ <:body>
+ {{this.message}}
+
+
\ No newline at end of file
diff --git a/app/assets/javascripts/admin/addon/components/modal/merge-users-progress.js b/app/assets/javascripts/admin/addon/components/modal/merge-users-progress.js
new file mode 100644
index 00000000000..ea174d115e2
--- /dev/null
+++ b/app/assets/javascripts/admin/addon/components/modal/merge-users-progress.js
@@ -0,0 +1,38 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { inject as service } from "@ember/service";
+import { bind } from "discourse-common/utils/decorators";
+import DiscourseURL from "discourse/lib/url";
+import I18n from "I18n";
+
+export default class MergeUsersProgress extends Component {
+ @service messageBus;
+
+ @tracked message = I18n.t("admin.user.merging_user");
+
+ constructor() {
+ super(...arguments);
+ this.messageBus.subscribe("/merge_user", this.onMessage);
+ }
+
+ willDestroy() {
+ this.messageBus.unsubscribe("/merge_user", this.onMessage);
+ }
+
+ @bind
+ onMessage(data) {
+ if (data.merged) {
+ if (/^\/admin\/users\/list\//.test(location.href)) {
+ DiscourseURL.redirectTo(location.href);
+ } else {
+ DiscourseURL.redirectTo(
+ `/admin/users/${data.user.id}/${data.user.username}`
+ );
+ }
+ } else if (data.message) {
+ this.message = data.message;
+ } else if (data.failed) {
+ this.message = I18n.t("admin.user.merge_failed");
+ }
+ }
+}
diff --git a/app/assets/javascripts/admin/addon/components/modal/merge-users-prompt.hbs b/app/assets/javascripts/admin/addon/components/modal/merge-users-prompt.hbs
new file mode 100644
index 00000000000..1ef1151795b
--- /dev/null
+++ b/app/assets/javascripts/admin/addon/components/modal/merge-users-prompt.hbs
@@ -0,0 +1,39 @@
+
+ <:body>
+
+ {{html-safe
+ (i18n
+ "admin.user.merge.prompt.description" username=@model.user.username
+ )
+ }}
+
+
+
+ <:footer>
+
+
+
+
\ No newline at end of file
diff --git a/app/assets/javascripts/admin/addon/components/modal/merge-users-prompt.js b/app/assets/javascripts/admin/addon/components/modal/merge-users-prompt.js
new file mode 100644
index 00000000000..6af710b41f3
--- /dev/null
+++ b/app/assets/javascripts/admin/addon/components/modal/merge-users-prompt.js
@@ -0,0 +1,13 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+
+export default class MergeUsersPrompt extends Component {
+ @tracked targetUsername;
+
+ get mergeDisabled() {
+ return (
+ !this.targetUsername ||
+ this.args.model.user.username === this.targetUsername[0]
+ );
+ }
+}
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-user-index.js b/app/assets/javascripts/admin/addon/controllers/admin-user-index.js
index b9cc4c247fc..b44ef8f8f3d 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-user-index.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-user-index.js
@@ -13,6 +13,9 @@ import getURL from "discourse-common/lib/get-url";
import { htmlSafe } from "@ember/template";
import { extractError, popupAjaxError } from "discourse/lib/ajax-error";
import showModal from "discourse/lib/show-modal";
+import MergeUsersConfirmationModal from "../components/modal/merge-users-confirmation";
+import MergeUsersPromptModal from "../components/modal/merge-users-prompt";
+import MergeUsersProgressModal from "../components/modal/merge-users-progress";
import DeletePostsConfirmationModal from "../components/modal/delete-posts-confirmation";
export default class AdminUserIndexController extends Controller.extend(
@@ -438,19 +441,21 @@ export default class AdminUserIndexController extends Controller.extend(
@action
promptTargetUser() {
- showModal("admin-merge-users-prompt", {
- admin: true,
- model: this.model,
+ this.modal.show(MergeUsersPromptModal, {
+ model: {
+ user: this.model,
+ showMergeConfirmation: this.showMergeConfirmation,
+ },
});
}
@action
showMergeConfirmation(targetUsername) {
- showModal("admin-merge-users-confirmation", {
- admin: true,
+ this.modal.show(MergeUsersConfirmationModal, {
model: {
username: this.model.username,
targetUsername,
+ merge: this.merge,
},
});
}
@@ -470,10 +475,7 @@ export default class AdminUserIndexController extends Controller.extend(
.merge(formData)
.then((response) => {
if (response.success) {
- showModal("admin-merge-users-progress", {
- admin: true,
- model: this.model,
- });
+ this.modal.show(MergeUsersProgressModal);
} else {
this.dialog.alert(I18n.t("admin.user.merge_failed"));
}
diff --git a/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-confirmation.js b/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-confirmation.js
deleted file mode 100644
index 24c23e8ed51..00000000000
--- a/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-confirmation.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import { alias } from "@ember/object/computed";
-import Controller, { inject as controller } from "@ember/controller";
-import I18n from "I18n";
-import ModalFunctionality from "discourse/mixins/modal-functionality";
-import { action } from "@ember/object";
-import discourseComputed from "discourse-common/utils/decorators";
-
-export default class AdminMergeUsersConfirmationController extends Controller.extend(
- ModalFunctionality
-) {
- @controller adminUserIndex;
-
- @alias("model.username") username;
- @alias("model.targetUsername") targetUsername;
-
- onShow() {
- this.set("value", null);
- }
-
- @discourseComputed("username", "targetUsername")
- text(username, targetUsername) {
- return I18n.t(`admin.user.merge.confirmation.text`, {
- username,
- targetUsername,
- });
- }
-
- @discourseComputed("username")
- mergeButtonText(username) {
- return I18n.t(`admin.user.merge.confirmation.transfer_and_delete`, {
- username,
- });
- }
-
- @discourseComputed("value", "text")
- mergeDisabled(value, text) {
- return !value || text !== value;
- }
-
- @action
- confirm() {
- this.adminUserIndex.send("merge", this.targetUsername);
- this.send("closeModal");
- }
-
- @action
- close() {
- this.send("closeModal");
- }
-}
diff --git a/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-progress.js b/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-progress.js
deleted file mode 100644
index 3c16b7539bd..00000000000
--- a/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-progress.js
+++ /dev/null
@@ -1,36 +0,0 @@
-import Controller from "@ember/controller";
-import DiscourseURL from "discourse/lib/url";
-import I18n from "I18n";
-import ModalFunctionality from "discourse/mixins/modal-functionality";
-import { bind } from "discourse-common/utils/decorators";
-
-export default class AdminMergeUsersProgressController extends Controller.extend(
- ModalFunctionality
-) {
- message = I18n.t("admin.user.merging_user");
-
- onShow() {
- this.messageBus.subscribe("/merge_user", this.onMessage);
- }
-
- onClose() {
- this.messageBus.unsubscribe("/merge_user", this.onMessage);
- }
-
- @bind
- onMessage(data) {
- if (data.merged) {
- if (/^\/admin\/users\/list\//.test(location)) {
- DiscourseURL.redirectTo(location);
- } else {
- DiscourseURL.redirectTo(
- `/admin/users/${data.user.id}/${data.user.username}`
- );
- }
- } else if (data.message) {
- this.set("message", data.message);
- } else if (data.failed) {
- this.set("message", I18n.t("admin.user.merge_failed"));
- }
- }
-}
diff --git a/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-prompt.js b/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-prompt.js
deleted file mode 100644
index 3b2b86bf4ff..00000000000
--- a/app/assets/javascripts/admin/addon/controllers/modals/admin-merge-users-prompt.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import { alias } from "@ember/object/computed";
-import Controller, { inject as controller } from "@ember/controller";
-import I18n from "I18n";
-import ModalFunctionality from "discourse/mixins/modal-functionality";
-import { action, get } from "@ember/object";
-import discourseComputed from "discourse-common/utils/decorators";
-
-export default class AdminMergeUsersPromptController extends Controller.extend(
- ModalFunctionality
-) {
- @controller adminUserIndex;
-
- @alias("model.username") username;
-
- onShow() {
- this.set("targetUsername", null);
- }
-
- @discourseComputed("username", "targetUsername")
- mergeDisabled(username, targetUsername) {
- return !targetUsername || username === targetUsername;
- }
-
- @discourseComputed("username")
- mergeButtonText(username) {
- return I18n.t(`admin.user.merge.confirmation.transfer_and_delete`, {
- username,
- });
- }
-
- @action
- showConfirmation() {
- this.send("closeModal");
- this.adminUserIndex.send("showMergeConfirmation", this.targetUsername);
- }
-
- @action
- close() {
- this.send("closeModal");
- }
-
- @action
- updateUsername(selected) {
- this.set("targetUsername", get(selected, "firstObject"));
- }
-}
diff --git a/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-confirmation.hbs b/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-confirmation.hbs
deleted file mode 100644
index 4a5b72bf7dc..00000000000
--- a/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-confirmation.hbs
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
- {{html-safe
- (i18n
- "admin.user.merge.confirmation.description"
- username=this.username
- targetUsername=this.targetUsername
- text=this.text
- )
- }}
-
-
-
-
-
\ No newline at end of file
diff --git a/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-progress.hbs b/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-progress.hbs
deleted file mode 100644
index 5cccf8d64ea..00000000000
--- a/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-progress.hbs
+++ /dev/null
@@ -1,3 +0,0 @@
-
- {{this.message}}
-
\ No newline at end of file
diff --git a/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-prompt.hbs b/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-prompt.hbs
deleted file mode 100644
index 919a6738106..00000000000
--- a/app/assets/javascripts/admin/addon/templates/modal/admin-merge-users-prompt.hbs
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
- {{html-safe
- (i18n "admin.user.merge.prompt.description" username=this.username)
- }}
-
-
-
-
-
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/services/modal.js b/app/assets/javascripts/discourse/app/services/modal.js
index f621a2bc266..5b6482ac52d 100644
--- a/app/assets/javascripts/discourse/app/services/modal.js
+++ b/app/assets/javascripts/discourse/app/services/modal.js
@@ -48,7 +48,6 @@ const KNOWN_LEGACY_MODALS = [
"tag-upload",
"topic-summary",
"user-status",
- "admin-merge-users-prompt",
"admin-watched-word-test",
"admin-api-key-urls",
"admin-delete-user-posts-progress",
@@ -58,12 +57,10 @@ const KNOWN_LEGACY_MODALS = [
"site-setting-default-categories",
"admin-badge-preview",
"admin-edit-badge-groupings",
- "admin-merge-users-confirmation",
"admin-reseed",
"admin-theme-item",
"admin-color-scheme-select-base",
"admin-form-template-validation-options",
- "admin-merge-users-progress",
"admin-staff-action-log-details",
"admin-uploaded-image-list",
];