diff --git a/app/assets/javascripts/discourse/app/templates/modal/user-status.hbs b/app/assets/javascripts/discourse/app/components/modal/user-status.hbs similarity index 58% rename from app/assets/javascripts/discourse/app/templates/modal/user-status.hbs rename to app/assets/javascripts/discourse/app/components/modal/user-status.hbs index 06b3426a5ac..bb039c6d04b 100644 --- a/app/assets/javascripts/discourse/app/templates/modal/user-status.hbs +++ b/app/assets/javascripts/discourse/app/components/modal/user-status.hbs @@ -1,5 +1,9 @@ - - + + <:body>
@@ -15,30 +19,31 @@ + - -
-
\ No newline at end of file + {{/if}} + + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/controllers/user-status.js b/app/assets/javascripts/discourse/app/components/modal/user-status.js similarity index 82% rename from app/assets/javascripts/discourse/app/controllers/user-status.js rename to app/assets/javascripts/discourse/app/components/modal/user-status.js index 5627f93ead2..90ac997efc0 100644 --- a/app/assets/javascripts/discourse/app/controllers/user-status.js +++ b/app/assets/javascripts/discourse/app/components/modal/user-status.js @@ -1,5 +1,3 @@ -import Controller from "@ember/controller"; -import ModalFunctionality from "discourse/mixins/modal-functionality"; import { action } from "@ember/object"; import { popupAjaxError } from "discourse/lib/ajax-error"; import discourseComputed from "discourse-common/utils/decorators"; @@ -8,14 +6,17 @@ import { TIME_SHORTCUT_TYPES, timeShortcuts, } from "discourse/lib/time-shortcut"; +import Component from "@ember/component"; -export default Controller.extend(ModalFunctionality, { - showDeleteButton: false, - prefilledDateTime: null, - timeShortcuts: null, - _itsatrap: null, +export default class ModalUserStatus extends Component { + showDeleteButton = false; + prefilledDateTime = null; + timeShortcuts = null; + _itsatrap = null; + + init() { + super.init(...arguments); - onShow() { const currentStatus = { ...this.model.status }; this.setProperties({ status: currentStatus, @@ -27,42 +28,42 @@ export default Controller.extend(ModalFunctionality, { }); this.set("_itsatrap", new ItsATrap()); - }, + } - onClose() { + willDestroy() { this._itsatrap.destroy(); this.set("_itsatrap", null); this.set("timeShortcuts", null); - }, + } @discourseComputed("status.emoji", "status.description") statusIsSet(emoji, description) { return !!emoji && !!description; - }, + } @discourseComputed customTimeShortcutLabels() { const labels = {}; labels[TIME_SHORTCUT_TYPES.NONE] = "time_shortcut.never"; return labels; - }, + } @discourseComputed hiddenTimeShortcutOptions() { return [TIME_SHORTCUT_TYPES.LAST_CUSTOM]; - }, + } @action delete() { Promise.resolve(this.model.deleteAction()) - .then(() => this.send("closeModal")) + .then(() => this.closeModal()) .catch((e) => this._handleError(e)); - }, + } @action onTimeSelected(_, time) { this.set("status.endsAt", time); - }, + } @action saveAndClose() { @@ -73,9 +74,9 @@ export default Controller.extend(ModalFunctionality, { }; Promise.resolve(this.model.saveAction(newStatus, this.pauseNotifications)) - .then(() => this.send("closeModal")) + .then(() => this.closeModal()) .catch((e) => this._handleError(e)); - }, + } _handleError(e) { if (typeof e === "string") { @@ -83,11 +84,11 @@ export default Controller.extend(ModalFunctionality, { } else { popupAjaxError(e); } - }, + } _buildTimeShortcuts() { const timezone = this.currentUser.user_option.timezone; const shortcuts = timeShortcuts(timezone); return [shortcuts.oneHour(), shortcuts.twoHours(), shortcuts.tomorrow()]; - }, -}); + } +} diff --git a/app/assets/javascripts/discourse/app/components/user-menu/profile-tab-content.js b/app/assets/javascripts/discourse/app/components/user-menu/profile-tab-content.js index 451bd15b53a..3f32e413cc9 100644 --- a/app/assets/javascripts/discourse/app/components/user-menu/profile-tab-content.js +++ b/app/assets/javascripts/discourse/app/components/user-menu/profile-tab-content.js @@ -1,9 +1,9 @@ import Component from "@glimmer/component"; import { inject as service } from "@ember/service"; import { action } from "@ember/object"; -import showModal from "discourse/lib/show-modal"; import DoNotDisturb from "discourse/lib/do-not-disturb"; import DoNotDisturbModal from "discourse/components/modal/do-not-disturb"; +import UserStatusModal from "discourse/components/modal/user-status"; const _extraItems = []; @@ -81,9 +81,8 @@ export default class UserMenuProfileTabContent extends Component { @action setUserStatusClick() { this.args.closeUserMenu(); - showModal("user-status", { - title: "user_status.set_custom_status", - modalClass: "user-status", + + this.modal.show(UserStatusModal, { model: { status: this.currentUser.status, pauseNotifications: this.currentUser.isInDoNotDisturb(), diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/account.js b/app/assets/javascripts/discourse/app/controllers/preferences/account.js index 8131d5dea74..da2c5a7cf6c 100644 --- a/app/assets/javascripts/discourse/app/controllers/preferences/account.js +++ b/app/assets/javascripts/discourse/app/controllers/preferences/account.js @@ -11,11 +11,12 @@ import getURL from "discourse-common/lib/get-url"; import { popupAjaxError } from "discourse/lib/ajax-error"; import { inject as service } from "@ember/service"; import { next } from "@ember/runloop"; -import showModal from "discourse/lib/show-modal"; import { exportUserArchive } from "discourse/lib/export-csv"; +import UserStatusModal from "discourse/components/modal/user-status"; export default Controller.extend(CanCheckEmails, { dialog: service(), + modal: service(), user: controller(), canDownloadPosts: alias("user.viewingSelf"), @@ -164,9 +165,7 @@ export default Controller.extend(CanCheckEmails, { @action showUserStatusModal(status) { - showModal("user-status", { - title: "user_status.set_custom_status", - modalClass: "user-status", + this.modal.show(UserStatusModal, { model: { status, hidePauseNotifications: true, diff --git a/app/assets/stylesheets/common/modal/user-status.scss b/app/assets/stylesheets/common/modal/user-status.scss index d18d0d939a8..ee89ac54796 100644 --- a/app/assets/stylesheets/common/modal/user-status.scss +++ b/app/assets/stylesheets/common/modal/user-status.scss @@ -5,10 +5,6 @@ } .modal-footer { - margin: 0; - border-top: 0; - padding: 10px 0; - .delete-status { margin-left: auto; margin-right: 0; @@ -34,5 +30,9 @@ .control-label { font-weight: 700; } + + .tap-tile:last-child { + border: 0; + } } }