diff --git a/app/assets/javascripts/discourse/app/components/modal/ignore-duration-with-username.hbs b/app/assets/javascripts/discourse/app/components/modal/ignore-duration-with-username.hbs
index b5149a12a80..592fce9a578 100644
--- a/app/assets/javascripts/discourse/app/components/modal/ignore-duration-with-username.hbs
+++ b/app/assets/javascripts/discourse/app/components/modal/ignore-duration-with-username.hbs
@@ -6,15 +6,17 @@
class="ignore-duration-with-username-modal"
>
<:body>
-
-
-
-
+ {{#if this.enableSelection}}
+
+
+
+
+ {{/if}}
{
- this.args.model.onUserIgnored(this.ignoredUsername);
+ this.args.model.onUserIgnored?.(this.ignoredUsername);
this.args.closeModal();
})
.catch(popupAjaxError)
diff --git a/app/assets/javascripts/discourse/app/controllers/ignore-duration.js b/app/assets/javascripts/discourse/app/controllers/ignore-duration.js
deleted file mode 100644
index 6522d58b010..00000000000
--- a/app/assets/javascripts/discourse/app/controllers/ignore-duration.js
+++ /dev/null
@@ -1,60 +0,0 @@
-import Controller from "@ember/controller";
-import I18n from "I18n";
-import ModalFunctionality from "discourse/mixins/modal-functionality";
-import { popupAjaxError } from "discourse/lib/ajax-error";
-import { timeShortcuts } from "discourse/lib/time-shortcut";
-import discourseComputed from "discourse-common/utils/decorators";
-
-export default Controller.extend(ModalFunctionality, {
- loading: false,
- ignoredUntil: null,
-
- @discourseComputed
- timeShortcuts() {
- const timezone = this.currentUser.user_option.timezone;
- const shortcuts = timeShortcuts(timezone);
- return [
- shortcuts.laterToday(),
- shortcuts.tomorrow(),
- shortcuts.laterThisWeek(),
- shortcuts.thisWeekend(),
- shortcuts.monday(),
- shortcuts.twoWeeks(),
- shortcuts.nextMonth(),
- shortcuts.twoMonths(),
- shortcuts.threeMonths(),
- shortcuts.fourMonths(),
- shortcuts.sixMonths(),
- shortcuts.oneYear(),
- shortcuts.forever(),
- ];
- },
-
- actions: {
- ignore() {
- if (!this.ignoredUntil) {
- this.flash(
- I18n.t("user.user_notifications.ignore_duration_time_frame_required"),
- "error"
- );
- return;
- }
- this.set("loading", true);
- this.model
- .updateNotificationLevel({
- level: "ignore",
- expiringAt: this.ignoredUntil,
- })
- .then(() => {
- this.set("model.ignored", true);
- this.set("model.muted", false);
- if (this.onSuccess) {
- this.onSuccess();
- }
- this.send("closeModal");
- })
- .catch(popupAjaxError)
- .finally(() => this.set("loading", false));
- },
- },
-});
diff --git a/app/assets/javascripts/discourse/app/templates/modal/ignore-duration.hbs b/app/assets/javascripts/discourse/app/templates/modal/ignore-duration.hbs
deleted file mode 100644
index be525f4089e..00000000000
--- a/app/assets/javascripts/discourse/app/templates/modal/ignore-duration.hbs
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
- {{i18n "user.user_notifications.ignore_duration_note"}}
-
-
-
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-test.js
index 93da629c29a..784883f7c65 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-test.js
@@ -318,14 +318,14 @@ acceptance(
);
await notificationLevelDropdown.selectRowByValue("changeToIgnored");
- assert.ok(exists(".ignore-duration-modal"));
+ assert.ok(exists(".ignore-duration-with-username-modal"));
const durationDropdown = selectKit(
- ".ignore-duration-modal .future-date-input-selector"
+ ".ignore-duration-with-username-modal .future-date-input-selector"
);
await durationDropdown.expand();
await durationDropdown.selectRowByIndex(0);
- await click(".modal-footer .ignore-duration-save");
+ await click(".modal-footer .btn-primary");
await notificationLevelDropdown.expand();
assert.strictEqual(
notificationLevelDropdown.selectedRow().value(),
diff --git a/app/assets/javascripts/select-kit/addon/components/user-notifications-dropdown.js b/app/assets/javascripts/select-kit/addon/components/user-notifications-dropdown.js
index e249f49f6fa..daf8436725e 100644
--- a/app/assets/javascripts/select-kit/addon/components/user-notifications-dropdown.js
+++ b/app/assets/javascripts/select-kit/addon/components/user-notifications-dropdown.js
@@ -1,10 +1,13 @@
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
+import { inject as service } from "@ember/service";
import I18n from "I18n";
import { computed } from "@ember/object";
import { popupAjaxError } from "discourse/lib/ajax-error";
-import showModal from "discourse/lib/show-modal";
+import IgnoreDurationModal from "discourse/components/modal/ignore-duration-with-username";
export default DropdownSelectBox.extend({
+ modal: service(),
+
classNames: ["user-notifications", "user-notifications-dropdown"],
selectKitOptions: {
@@ -55,8 +58,11 @@ export default DropdownSelectBox.extend({
this.updateNotificationLevel({ level: "mute" }).catch(popupAjaxError);
},
changeToIgnored() {
- showModal("ignore-duration", {
- model: this.user,
+ this.modal.show(IgnoreDurationModal, {
+ model: {
+ ignoredUsername: this.user.username,
+ enableSelection: false,
+ },
});
},