A platform for community discussion. Free, open, simple.
DEV: makes chat modals use the new <DModal /> component (#22495)
Joffrey JAFFEUX9830c4038696
diff --git a/app/assets/javascripts/discourse/app/components/d-modal-cancel.hbs b/app/assets/javascripts/discourse/app/components/d-modal-cancel.hbsindex f66de85d829..f409a846791 100644--- a/app/assets/javascripts/discourse/app/components/d-modal-cancel.hbs+++ b/app/assets/javascripts/discourse/app/components/d-modal-cancel.hbs@@ -1,5 +1,5 @@<DButton@class="btn-flat d-modal-cancel"- @action={{action this.close}}+ @action={{@close}}@translatedLabel={{i18n "cancel"}}/>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/d-modal-cancel.js b/app/assets/javascripts/discourse/app/components/d-modal-cancel.jsdeleted file mode 100644index 0e6d50b17d4..00000000000--- a/app/assets/javascripts/discourse/app/components/d-modal-cancel.js+++ /dev/null@@ -1,4 +0,0 @@-import Component from "@ember/component";-export default Component.extend({- tagName: "",-});diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.jsindex 299e1038ad7..165303a677d 100644--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js@@ -490,4 +490,20 @@ module("Integration | Component | select-kit/single-select", function (hooks) {assert.dom(".single-select.is-expanded").exists();});++ test("options.formName", async function (assert) {+ setDefaultState(this);+ await render(hbs`+ <SingleSelect+ @value={{this.value}}+ @content={{this.content}}+ @options={{hash formName="foo"}}+ />+ `);++ assert+ .dom('input[name="foo"]')+ .hasAttribute("type", "hidden")+ .hasAttribute("value", "1");+ });});diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.jsindex fa2d49b1367..8a9ed97ee68 100644--- a/app/assets/javascripts/select-kit/addon/components/select-kit.js+++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js@@ -311,6 +311,7 @@ export default Component.extend(hiddenValues: null,disabled: false,expandedOnInsert: false,+ formName: null,},autoFilterable: computed("content.[]", "selectKit.filter", function () {diff --git a/app/assets/javascripts/select-kit/addon/components/selected-name.hbs b/app/assets/javascripts/select-kit/addon/components/selected-name.hbsindex 1b823e8ba48..1273b32751e 100644--- a/app/assets/javascripts/select-kit/addon/components/selected-name.hbs+++ b/app/assets/javascripts/select-kit/addon/components/selected-name.hbs@@ -6,6 +6,14 @@data-name={{this.name}}class="select-kit-selected-name selected-name choice">+ {{#if this.selectKit.options.formName}}+ <input+ type="hidden"+ name={{this.selectKit.options.formName}}+ value={{this.value}}+ />+ {{/if}}+{{#if this.item.icon}}{{d-icon this.item.icon}}{{/if}}diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-summary.hbs b/plugins/chat/assets/javascripts/discourse/components/channel-summary.hbsdeleted file mode 100644index eed8d85a0c9..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/channel-summary.hbs+++ /dev/null@@ -1,22 +0,0 @@-<DModalBody @title="chat.summarization.title">- <span>{{i18n "chat.summarization.description"}}</span>- <ComboBox- @value={{this.sinceHours}}- @content={{this.sinceOptions}}- @onChange={{action this.summarize}}- @valueProperty="value"- @class="summarization-since"- />- <div class="channel-summary">- <ConditionalLoadingSpinner @condition={{this.loading}} />-- {{#unless this.loading}}- <p class="summary-area">{{this.summary}}</p>- {{/unless}}- </div>--</DModalBody>--<div class="modal-footer">- <DModalCancel @close={{route-action "closeModal"}} />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/channel-summary.js b/plugins/chat/assets/javascripts/discourse/components/channel-summary.jsdeleted file mode 100644index 881ded2750a..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/channel-summary.js+++ /dev/null@@ -1,65 +0,0 @@-import Component from "@glimmer/component";-import { tracked } from "@glimmer/tracking";-import { ajax } from "discourse/lib/ajax";-import { popupAjaxError } from "discourse/lib/ajax-error";-import { action } from "@ember/object";-import I18n from "I18n";--export default class ChannelSumarry extends Component {- @tracked sinceHours = null;- @tracked loading = false;- @tracked availableSummaries = {};- @tracked summary = null;- sinceOptions = [- {- name: I18n.t("chat.summarization.since", { count: 1 }),- value: 1,- },- {- name: I18n.t("chat.summarization.since", { count: 3 }),- value: 3,- },- {- name: I18n.t("chat.summarization.since", { count: 6 }),- value: 6,- },- {- name: I18n.t("chat.summarization.since", { count: 12 }),- value: 12,- },- {- name: I18n.t("chat.summarization.since", { count: 24 }),- value: 24,- },- {- name: I18n.t("chat.summarization.since", { count: 72 }),- value: 72,- },- {- name: I18n.t("chat.summarization.since", { count: 168 }),- value: 168,- },- ];-- @action- summarize(value) {- this.loading = true;-- if (this.availableSummaries[value]) {- this.summary = this.availableSummaries[value];- this.loading = false;- return;- }-- ajax(`/chat/api/channels/${this.args.channelId}/summarize`, {- method: "GET",- data: { since: value },- })- .then((data) => {- this.availableSummaries[this.sinceHours] = data.summary;- this.summary = this.availableSummaries[this.sinceHours];- })- .catch(popupAjaxError)- .finally(() => (this.loading = false));- }-}diff --git a/plugins/chat/assets/javascripts/discourse/components/channels-list.js b/plugins/chat/assets/javascripts/discourse/components/channels-list.jsindex d25d157e0aa..9f6e96e87c0 100644--- a/plugins/chat/assets/javascripts/discourse/components/channels-list.js+++ b/plugins/chat/assets/javascripts/discourse/components/channels-list.js@@ -4,7 +4,7 @@ import { action } from "@ember/object";import { schedule } from "@ember/runloop";import { inject as service } from "@ember/service";import { tracked } from "@glimmer/tracking";-import ChatNewMessageModal from "discourse/plugins/chat/discourse/components/modal/chat-new-message";+import ChatModalNewMessage from "discourse/plugins/chat/discourse/components/chat/modal/new-message";export default class ChannelsList extends Component {@service chat;@@ -30,7 +30,7 @@ export default class ChannelsList extends Component {@actionopenNewMessageModal() {- this.modal.show(ChatNewMessageModal);+ this.modal.show(ChatModalNewMessage);}get showMobileDirectMessageButton() {diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-browse-view.js b/plugins/chat/assets/javascripts/discourse/components/chat-browse-view.jsindex 2f3547b6146..70c584587a1 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-browse-view.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-browse-view.js@@ -4,13 +4,15 @@ import { action, computed } from "@ember/object";import { schedule } from "@ember/runloop";import { inject as service } from "@ember/service";import discourseDebounce from "discourse-common/lib/debounce";-import showModal from "discourse/lib/show-modal";-import ChatNewMessageModal from "discourse/plugins/chat/discourse/components/modal/chat-new-message";+import ChatModalNewMessage from "discourse/plugins/chat/discourse/components/chat/modal/new-message";+import ChatModalCreateChannel from "discourse/plugins/chat/discourse/components/chat/modal/create-channel";const TABS = ["all", "open", "closed", "archived"];export default class ChatBrowseView extends Component {@service chatApi;+ @service modal;+tagName = "";didReceiveAttrs() {@@ -41,7 +43,7 @@ export default class ChatBrowseView extends Component {@actionshowChatNewMessageModal() {- this.modal.show(ChatNewMessageModal);+ this.modal.show(ChatModalNewMessage);}@action@@ -66,7 +68,7 @@ export default class ChatBrowseView extends Component {@actioncreateChannel() {- showModal("create-channel");+ this.modal.show(ChatModalCreateChannel);}@actiondiff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-archive-modal-inner.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-archive-modal-inner.hbsdeleted file mode 100644index d4da56380ae..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-archive-modal-inner.hbs+++ /dev/null@@ -1,30 +0,0 @@-<DModalBody @title="chat.channel_archive.title">- <div- id="chat-channel-archive-modal-inner"- class="chat-channel-archive-modal-inner"- >- <p- class="chat-channel-archive-modal-instructions"- >{{this.instructionsText}}</p>-- <ChatToTopicSelector- @selection={{this.selection}}- @topicTitle={{this.topicTitle}}- @categoryId={{this.categoryId}}- @tags={{this.tags}}- @selectedTopicId={{this.selectedTopicId}}- @instructionLabels={{this.instructionLabels}}- @allowNewMessage={{false}}- />- </div>-</DModalBody>--<div class="modal-footer">- <DButton- @class="btn-primary"- @disabled={{this.buttonDisabled}}- @action={{action "archiveChannel"}}- @label="chat.channel_archive.title"- @id="chat-confirm-archive-channel"- />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-archive-modal-inner.js b/plugins/chat/assets/javascripts/discourse/components/chat-channel-archive-modal-inner.jsdeleted file mode 100644index 17d9420f1d1..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-archive-modal-inner.js+++ /dev/null@@ -1,108 +0,0 @@-import Component from "@ember/component";-import I18n from "I18n";-import discourseLater from "discourse-common/lib/later";-import { isEmpty } from "@ember/utils";-import discourseComputed from "discourse-common/utils/decorators";-import { action } from "@ember/object";-import { equal } from "@ember/object/computed";-import { inject as service } from "@ember/service";-import { popupAjaxError } from "discourse/lib/ajax-error";-import {- EXISTING_TOPIC_SELECTION,- NEW_TOPIC_SELECTION,-} from "discourse/plugins/chat/discourse/components/chat-to-topic-selector";-import { CHANNEL_STATUSES } from "discourse/plugins/chat/discourse/models/chat-channel";-import { htmlSafe } from "@ember/template";-import ModalFunctionality from "discourse/mixins/modal-functionality";--export default Component.extend(ModalFunctionality, {- chat: service(),- chatApi: service(),- tagName: "",- chatChannel: null,-- selection: NEW_TOPIC_SELECTION,- newTopic: equal("selection", NEW_TOPIC_SELECTION),- existingTopic: equal("selection", EXISTING_TOPIC_SELECTION),-- saving: false,-- topicTitle: null,- categoryId: null,- tags: null,- selectedTopicId: null,-- @action- archiveChannel() {- this.set("saving", true);-- return this.chatApi- .createChannelArchive(this.chatChannel.id, this._data())- .then(() => {- this.flash(I18n.t("chat.channel_archive.process_started"), "success");- this.chatChannel.status = CHANNEL_STATUSES.archived;-- discourseLater(() => {- this.closeModal();- }, 3000);- })- .catch(popupAjaxError)- .finally(() => this.set("saving", false));- },-- _data() {- const data = {- type: this.selection,- };- if (this.newTopic) {- data.title = this.topicTitle;- data.category_id = this.categoryId;- data.tags = this.tags;- }- if (this.existingTopic) {- data.topic_id = this.selectedTopicId;- }- return data;- },-- @discourseComputed("saving", "selectedTopicId", "topicTitle", "selection")- buttonDisabled(saving, selectedTopicId, topicTitle) {- if (saving) {- return true;- }- if (- this.newTopic &&- (!topicTitle ||- topicTitle.length < this.siteSettings.min_topic_title_length ||- topicTitle.length > this.siteSettings.max_topic_title_length)- ) {- return true;- }-- if (this.existingTopic && isEmpty(selectedTopicId)) {- return true;- }- return false;- },-- @discourseComputed()- instructionLabels() {- const labels = {};- labels[NEW_TOPIC_SELECTION] = I18n.t(- "chat.selection.new_topic.instructions_channel_archive"- );- labels[EXISTING_TOPIC_SELECTION] = I18n.t(- "chat.selection.existing_topic.instructions_channel_archive"- );- return labels;- },-- @discourseComputed()- instructionsText() {- return htmlSafe(- I18n.t("chat.channel_archive.instructions", {- channelTitle: this.chatChannel.escapedTitle,- })- );- },-});diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-delete-modal-inner.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-delete-modal-inner.hbsdeleted file mode 100644index faf2829c557..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-delete-modal-inner.hbs+++ /dev/null@@ -1,30 +0,0 @@-<DModalBody @title="chat.channel_delete.title">- <div- id="chat-channel-delete-modal-inner"- class="chat-channel-delete-modal-inner"- >- <p class="chat-channel-delete-modal-instructions">- {{this.instructionsText}}- </p>- </div>-- <TextField- @value={{this.channelNameConfirmation}}- @id="channel-delete-confirm-name"- @placeholderKey="chat.channel_delete.confirm_channel_name"- @autocorrect="off"- @autocapitalize="off"- />-</DModalBody>--<div class="modal-footer">- <DButton- @disabled={{this.buttonDisabled}}- @class="btn-danger"- @action={{action "deleteChannel"}}- @label="chat.channel_delete.confirm"- @id="chat-confirm-delete-channel"- />-- <DButton @label="cancel" @class="btn-flat" @action={{this.closeModal}} />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-delete-modal-inner.js b/plugins/chat/assets/javascripts/discourse/components/chat-channel-delete-modal-inner.jsdeleted file mode 100644index 9a34dd80e53..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-delete-modal-inner.js+++ /dev/null@@ -1,65 +0,0 @@-import Component from "@ember/component";-import { isEmpty } from "@ember/utils";-import I18n from "I18n";-import discourseComputed from "discourse-common/utils/decorators";-import { action } from "@ember/object";-import { inject as service } from "@ember/service";-import { popupAjaxError } from "discourse/lib/ajax-error";-import discourseLater from "discourse-common/lib/later";-import { htmlSafe } from "@ember/template";-import ModalFunctionality from "discourse/mixins/modal-functionality";--export default Component.extend(ModalFunctionality, {- chat: service(),- chatApi: service(),- router: service(),- tagName: "",- chatChannel: null,- channelNameConfirmation: null,- deleting: false,- confirmed: false,-- @discourseComputed("deleting", "channelNameConfirmation", "confirmed")- buttonDisabled(deleting, channelNameConfirmation, confirmed) {- if (deleting || confirmed) {- return true;- }-- if (- isEmpty(channelNameConfirmation) ||- channelNameConfirmation.toLowerCase() !==- this.chatChannel.title.toLowerCase()- ) {- return true;- }- return false;- },-- @action- deleteChannel() {- this.set("deleting", true);-- return this.chatApi- .destroyChannel(this.chatChannel.id, this.channelNameConfirmation)- .then(() => {- this.set("confirmed", true);- this.flash(I18n.t("chat.channel_delete.process_started"), "success");-- discourseLater(() => {- this.closeModal();- this.router.transitionTo("chat");- }, 3000);- })- .catch(popupAjaxError)- .finally(() => this.set("deleting", false));- },-- @discourseComputed()- instructionsText() {- return htmlSafe(- I18n.t("chat.channel_delete.instructions", {- name: this.chatChannel.escapedTitle,- })- );- },-});diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-settings-view.js b/plugins/chat/assets/javascripts/discourse/components/chat-channel-settings-view.jsindex 2c1398bc0f1..dc5560886ef 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-settings-view.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-settings-view.js@@ -1,8 +1,10 @@import Component from "@glimmer/component";import { action } from "@ember/object";import { inject as service } from "@ember/service";-import showModal from "discourse/lib/show-modal";import I18n from "I18n";+import ChatModalArchiveChannel from "discourse/plugins/chat/discourse/components/chat/modal/archive-channel";+import ChatModalDeleteChannel from "discourse/plugins/chat/discourse/components/chat/modal/delete-channel";+import ChatModalToggleChannelStatus from "discourse/plugins/chat/discourse/components/chat/modal/toggle-channel-status";const NOTIFICATION_LEVELS = [{ name: I18n.t("chat.notification_levels.never"), value: "never" },@@ -41,6 +43,7 @@ export default class ChatChannelSettingsView extends Component {@service siteSettings;@service router;@service dialog;+ @service modal;notificationLevels = NOTIFICATION_LEVELS;mutedOptions = MUTED_OPTIONS;@@ -107,20 +110,21 @@ export default class ChatChannelSettingsView extends Component {@actiononArchiveChannel() {- const controller = showModal("chat-channel-archive-modal");- controller.set("chatChannel", this.args.channel);+ return this.modal.show(ChatModalArchiveChannel, {+ model: { channel: this.args.channel },+ });}@actiononDeleteChannel() {- const controller = showModal("chat-channel-delete-modal");- controller.set("chatChannel", this.args.channel);+ return this.modal.show(ChatModalDeleteChannel, {+ model: { channel: this.args.channel },+ });}@actiononToggleChannelState() {- const controller = showModal("chat-channel-toggle");- controller.set("chatChannel", this.args.channel);+ this.modal.show(ChatModalToggleChannelStatus, { model: this.args.channel });}@actiondiff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-toggle-view.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-toggle-view.hbsdeleted file mode 100644index 237017a1864..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-toggle-view.hbs+++ /dev/null@@ -1,14 +0,0 @@-<DModalBody @title={{this.modalTitle}}>- <div id="chat-channel-toggle" class="chat-channel-toggle">- <p>{{this.instructions}}</p>- </div>-</DModalBody>--<div class="modal-footer">- <DButton- @class="btn-primary"- @action={{action "changeChannelStatus"}}- @label={{this.buttonLabel}}- @id="chat-channel-toggle-btn"- />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js b/plugins/chat/assets/javascripts/discourse/components/chat-composer.jsindex e5a1740ca5b..304cd235719 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.js@@ -25,6 +25,7 @@ import {initUserStatusHtml,renderUserStatusHtml,} from "discourse/lib/user-status-on-autocomplete";+import ChatModalChannelSummary from "discourse/plugins/chat/discourse/components/chat/modal/channel-summary";export default class ChatComposer extends Component {@service capabilities;@@ -39,6 +40,7 @@ export default class ChatComposer extends Component {@service currentUser;@service chatApi;@service chatDraftsManager;+ @service modal;@tracked isFocused = false;@tracked inProgressUploadsCount = 0;@@ -377,8 +379,8 @@ export default class ChatComposer extends Component {@actionshowChannelSummaryModal() {- showModal("channel-summary").setProperties({- channelId: this.args.channel.id,+ this.modal.show(ChatModalChannelSummary, {+ model: { channelId: this.args.channel.id },});}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-move-to-channel-modal-inner.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-move-to-channel-modal-inner.hbsdeleted file mode 100644index c89b7fe5c36..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/chat-message-move-to-channel-modal-inner.hbs+++ /dev/null@@ -1,28 +0,0 @@-<DModalBody @title="chat.move_to_channel.title">- <div- id="chat-message-move-to-channel-modal-inner"- class="chat-message-move-to-channel-modal-inner"- >- <p>{{this.instructionsText}}</p>- </div>-- <ChatChannelChooser- @class="chat-move-message-channel-chooser"- @content={{this.availableChannels}}- @value={{this.destinationChannelId}}- @nameProperty="title"- />-</DModalBody>--<div class="modal-footer">- <DButton- @class="btn-primary"- @icon="sign-out-alt"- @disabled={{this.disableMoveButton}}- @action={{this.moveMessages}}- @label="chat.move_to_channel.confirm_move"- @id="chat-confirm-move-messages-to-channel"- />-- <DButton @label="cancel" @class="btn-flat" @action={{this.closeModal}} />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-separator-date.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-separator-date.hbsindex 2249396840e..9b5361dcd2c 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-message-separator-date.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-separator-date.hbs@@ -5,11 +5,7 @@(if @message.newest "with-last-visit")}}role="button"- {{on- "click"- (fn @fetchMessagesByDate @message.firstMessageOfTheDayAt)- passive=true- }}+ {{on "click" this.onDateClick passive=true}}><divclass="chat-message-separator__text-container"diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-separator-date.js b/plugins/chat/assets/javascripts/discourse/components/chat-message-separator-date.jsnew file mode 100644index 00000000000..411dfcdaecb--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-separator-date.js@@ -0,0 +1,11 @@+import Component from "@glimmer/component";+import { action } from "@ember/object";++export default class ChatMessageSeparatorDate extends Component {+ @action+ onDateClick() {+ return this.args.fetchMessagesByDate?.(+ this.args.message.firstMessageOfTheDayAt+ );+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator.js b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator.jsindex 87730b296a7..28a81bd9750 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator.js@@ -281,6 +281,7 @@ export default class ChatMessageCreator extends Component {return;} else if (this.query?.length === 0) {this.openChannel(this.selection);+ event.preventDefault();return;}}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/archive-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/archive-channel.hbsnew file mode 100644index 00000000000..e73ec9fc469--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/archive-channel.hbs@@ -0,0 +1,32 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-archive-channel"+ @inline={{@inline}}+ @title={{i18n "chat.channel_archive.title"}}+ @flash={{this.flash}}+ @flashType={{this.flashType}}+>+ <:body>+ <p class="chat-modal-archive-channel__instructions">+ {{this.instructionsText}}+ </p>+ <ChatToTopicSelector+ @selection={{this.selection}}+ @topicTitle={{this.topicTitle}}+ @categoryId={{this.categoryId}}+ @tags={{this.tags}}+ @selectedTopicId={{this.selectedTopicId}}+ @instructionLabels={{this.instructionLabels}}+ @allowNewMessage={{false}}+ />+ </:body>+ <:footer>+ <DButton+ @class="btn-primary"+ @disabled={{this.buttonDisabled}}+ @action={{this.archiveChannel}}+ @label="chat.channel_archive.title"+ @id="chat-confirm-archive-channel"+ />+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/archive-channel.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/archive-channel.jsnew file mode 100644index 00000000000..f8f5b11b4e6--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/archive-channel.js@@ -0,0 +1,112 @@+import Component from "@glimmer/component";+import { action } from "@ember/object";+import { inject as service } from "@ember/service";+import { tracked } from "@glimmer/tracking";+import { popupAjaxError } from "discourse/lib/ajax-error";+import { htmlSafe } from "@ember/template";+import I18n from "I18n";+import discourseLater from "discourse-common/lib/later";+import {+ EXISTING_TOPIC_SELECTION,+ NEW_TOPIC_SELECTION,+} from "discourse/plugins/chat/discourse/components/chat-to-topic-selector";+import { CHANNEL_STATUSES } from "discourse/plugins/chat/discourse/models/chat-channel";+import { isEmpty } from "@ember/utils";++export default class ChatModalArchiveChannel extends Component {+ @service chatApi;+ @service siteSettings;++ @tracked selection = NEW_TOPIC_SELECTION;+ @tracked saving = false;+ @tracked topicTitle = null;+ @tracked categoryId = null;+ @tracked tags = null;+ @tracked selectedTopicId = null;+ @tracked flash;+ @tracked flashType;++ get channel() {+ return this.args.model.channel;+ }++ get newTopic() {+ return this.selection === NEW_TOPIC_SELECTION;+ }++ get existingTopic() {+ return this.selection === EXISTING_TOPIC_SELECTION;+ }++ get buttonDisabled() {+ if (this.saving) {+ return true;+ }++ if (+ this.newTopic &&+ (!this.topicTitle ||+ this.topicTitle.length < this.siteSettings.min_topic_title_length ||+ this.topicTitle.length > this.siteSettings.max_topic_title_length)+ ) {+ return true;+ }++ if (this.existingTopic && isEmpty(this.selectedTopicId)) {+ return true;+ }++ return false;+ }++ get instructionLabels() {+ const labels = {};+ labels[NEW_TOPIC_SELECTION] = I18n.t(+ "chat.selection.new_topic.instructions_channel_archive"+ );+ labels[EXISTING_TOPIC_SELECTION] = I18n.t(+ "chat.selection.existing_topic.instructions_channel_archive"+ );+ return labels;+ }++ get instructionsText() {+ return htmlSafe(+ I18n.t("chat.channel_archive.instructions", {+ channelTitle: this.channel.escapedTitle,+ })+ );+ }++ @action+ archiveChannel() {+ this.saving = true;++ return this.chatApi+ .createChannelArchive(this.channel.id, this.#data())+ .then(() => {+ this.flash = I18n.t("chat.channel_archive.process_started");+ this.flashType = "success";+ this.channel.status = CHANNEL_STATUSES.archived;++ discourseLater(() => {+ this.args.closeModal();+ }, 3000);+ })+ .catch(popupAjaxError)+ .finally(() => (this.saving = false));+ }++ #data() {+ const data = { type: this.selection };+ if (this.newTopic) {+ data.title = this.topicTitle;+ data.category_id = this.categoryId;+ data.tags = this.tags;+ }+ if (this.existingTopic) {+ data.topic_id = this.selectedTopicId;+ }+ return data;+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/channel-summary.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/channel-summary.hbsnew file mode 100644index 00000000000..0e16015ae21--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/channel-summary.hbs@@ -0,0 +1,22 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-channel-summary"+ @title={{i18n "chat.summarization.title"}}+>+ <:body>+ <span>{{i18n "chat.summarization.description"}}</span>+ <ComboBox+ @value={{this.sinceHours}}+ @content={{this.sinceOptions}}+ @onChange={{this.summarize}}+ @valueProperty="value"+ @class="summarization-since"+ />+ <ConditionalLoadingSection @isLoading={{this.loading}}>+ <p class="summary-area">{{this.summary}}</p>+ </ConditionalLoadingSection>+ </:body>+ <:footer>+ <DModalCancel @close={{@closeModal}} />+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/channel-summary.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/channel-summary.jsnew file mode 100644index 00000000000..199118729d4--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/channel-summary.js@@ -0,0 +1,47 @@+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";+import { popupAjaxError } from "discourse/lib/ajax-error";+import { action } from "@ember/object";+import I18n from "I18n";+import { inject as service } from "@ember/service";++export default class ChatModalChannelSummary extends Component {+ @service chatApi;++ @tracked sinceHours = null;+ @tracked loading = false;+ @tracked summary = null;++ availableSummaries = {};++ sinceOptions = [1, 3, 6, 12, 24, 72, 168].map((hours) => {+ return {+ name: I18n.t("chat.summarization.since", { count: hours }),+ value: hours,+ };+ });++ get channelId() {+ return this.args.model.channelId;+ }++ @action+ summarize(since) {+ this.loading = true;++ if (this.availableSummaries[since]) {+ this.summary = this.availableSummaries[since];+ this.loading = false;+ return;+ }++ return this.chatApi+ .summarize(this.channelId, { since })+ .then((data) => {+ this.availableSummaries[this.sinceHours] = data.summary;+ this.summary = this.availableSummaries[this.sinceHours];+ })+ .catch(popupAjaxError)+ .finally(() => (this.loading = false));+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.hbsnew file mode 100644index 00000000000..06e8213a245--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.hbs@@ -0,0 +1,136 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-create-channel"+ @inline={{@inline}}+ @title={{i18n "chat.create_channel.title"}}+ @flash={{this.flash}}+ @tagName="form"+ {{on "submit" this.onSave}}+>+ <:body>+ <div class="chat-modal-create-channel__control -name">+ <label for="name" class="chat-modal-create-channel__label">+ {{i18n "chat.create_channel.name"}}+ </label>+ <Input+ name="name"+ class="chat-modal-create-channel__input"+ @type="text"+ @value={{this.name}}+ {{on "input" (action this.onNameChange value="target.value")}}+ />+ </div>++ <div class="chat-modal-create-channel__control -slug">+ <label for="slug" class="chat-modal-create-channel__label">+ {{i18n "chat.create_channel.slug"}} + <span>+ {{d-icon "info-circle"}}+ <DTooltip>+ {{i18n "chat.channel_edit_name_slug_modal.slug_description"}}+ </DTooltip>+ </span>+ </label>+ <Input+ name="slug"+ class="chat-modal-create-channel__input"+ @type="text"+ @value={{this.slug}}+ placeholder={{this.autoGeneratedSlug}}+ />+ </div>++ <div class="chat-modal-create-channel__control -description">+ <label for="description" class="chat-modal-create-channel__label">+ {{i18n "chat.create_channel.description"}}+ </label>+ <Input+ name="description"+ class="chat-modal-create-channel__input"+ @type="textarea"+ @value={{this.description}}+ />+ </div>++ <div class="chat-modal-create-channel__control">+ <label class="chat-modal-create-channel__label">+ {{i18n "chat.create_channel.choose_category.label"}}+ </label>+ <CategoryChooser+ @value={{this.categoryId}}+ @onChange={{action this.onCategoryChange}}+ @options={{hash+ formName="chatable_id"+ none="chat.create_channel.choose_category.none"+ }}+ />++ {{#if this.categoryPermissionsHint}}+ <div+ class={{concat-class+ "chat-modal-create-channel__hint"+ (if this.loadingPermissionHint "loading-permissions")+ }}+ >+ {{this.categoryPermissionsHint}}+ </div>+ {{/if}}+ </div>++ {{#if this.autoJoinAvailable}}+ <div class="chat-modal-create-channel__control -auto-join">+ <label class="chat-modal-create-channel__label">+ <Input+ name="auto_join_users"+ @type="checkbox"+ @checked={{this.autoJoinUsers}}+ />+ <div class="auto-join-channel">+ <span class="chat-modal-create-channel__label-title">+ {{i18n "chat.settings.auto_join_users_label"}}+ </span>+ <p class="chat-modal-create-channel__label-description">+ {{#if this.categoryName}}+ {{i18n+ "chat.settings.auto_join_users_info"+ category=this.categoryName+ }}+ {{else}}+ {{i18n "chat.settings.auto_join_users_info_no_category"}}+ {{/if}}+ </p>+ </div>+ </label>+ </div>+ {{/if}}++ {{#if this.threadingAvailable}}+ <div class="chat-modal-create-channel__control -threading-toggle">+ <label class="chat-modal-create-channel__label">+ <Input+ name="threading_enabled"+ @type="checkbox"+ @checked={{this.threadingEnabled}}+ />+ <div class="threading-channel">+ <span class="chat-modal-create-channel__label-title">+ {{i18n "chat.create_channel.threading.label"}}+ </span>+ <p class="chat-modal-create-channel__label-description">+ {{i18n "chat.settings.channel_threading_description"}}+ </p>+ </div>+ </label>+ </div>+ {{/if}}+ </:body>+ <:footer>+ <button+ class="btn btn-primary create"+ disabled={{this.createDisabled}}+ type="submit"+ >+ {{i18n "chat.create_channel.create"}}+ </button>+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/controllers/create-channel.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.jssimilarity index 62%rename from plugins/chat/assets/javascripts/discourse/controllers/create-channel.jsrename to plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.jsindex d4e464a0105..7d5a35c0f46 100644--- a/plugins/chat/assets/javascripts/discourse/controllers/create-channel.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.js@@ -2,14 +2,13 @@ import { escapeExpression } from "discourse/lib/utilities";import { ajax } from "discourse/lib/ajax";import { cancel } from "@ember/runloop";import discourseDebounce from "discourse-common/lib/debounce";-import Controller from "@ember/controller";+import Component from "@glimmer/component";import I18n from "I18n";-import ModalFunctionality from "discourse/mixins/modal-functionality";-import { action, computed } from "@ember/object";-import { gt, notEmpty } from "@ember/object/computed";+import { action } from "@ember/object";import { inject as service } from "@ember/service";import { isBlank, isPresent } from "@ember/utils";import { htmlSafe } from "@ember/template";+import { tracked } from "@glimmer/tracking";const DEFAULT_HINT = htmlSafe(I18n.t("chat.create_channel.choose_category.default_hint", {@@ -18,9 +17,7 @@ const DEFAULT_HINT = htmlSafe(}));-export default class CreateChannelController extends Controller.extend(- ModalFunctionality-) {+export default class ChatModalCreateChannel extends Component {@service chat;@service dialog;@service chatChannelsManager;@@ -28,21 +25,30 @@ export default class CreateChannelController extends Controller.extend(@service router;@service currentUser;@service siteSettings;+ @service site;- category = null;- categoryId = null;- name = "";- slug = "";- autoGeneratedSlug = "";- description = "";- categoryPermissionsHint = null;- autoJoinUsers = false;- autoJoinWarning = "";- loadingPermissionHint = false;- threadingEnabled = false;-- @notEmpty("category") categorySelected;- @gt("siteSettings.max_chat_auto_joined_users", 0) autoJoinAvailable;+ @tracked flash;+ @tracked name;+ @tracked category;+ @tracked categoryId;+ @tracked autoGeneratedSlug = "";+ @tracked categoryPermissionsHint;+ @tracked autoJoinWarning = "";+ @tracked loadingPermissionHint = false;++ #generateSlugHandler = null;++ willDestroy() {+ cancel(this.#generateSlugHandler);+ }++ get autoJoinAvailable() {+ return this.siteSettings.max_chat_auto_joined_users > 0;+ }++ get categorySelected() {+ return isPresent(this.category);+ }get threadingAvailable() {return (@@ -51,69 +57,88 @@ export default class CreateChannelController extends Controller.extend();}- @computed("categorySelected", "name")get createDisabled() {return !this.categorySelected || isBlank(this.name);}- @computed("categorySelected", "name")get categoryName() {return this.categorySelected && isPresent(this.name)? escapeExpression(this.name): null;}+ @actiononShow() {- this.set("categoryPermissionsHint", DEFAULT_HINT);+ this.categoryPermissionsHint = DEFAULT_HINT;}- onClose() {- cancel(this.generateSlugHandler);- this.setProperties({- categoryId: null,- category: null,- name: "",- description: "",- slug: "",- autoGeneratedSlug: "",- categoryPermissionsHint: DEFAULT_HINT,- autoJoinWarning: "",- });+ @action+ onCategoryChange(categoryId) {+ const category = categoryId+ ? this.site.categories.findBy("id", categoryId)+ : null;+ this.#updatePermissionsHint(category);++ const name = this.name || category?.name || "";+ this.categoryId = categoryId;+ this.category = category;+ this.name = name;+ this.#debouncedGenerateSlug(name);}- _createChannel() {- const data = {- chatable_id: this.categoryId,- name: this.name,- slug: this.slug || this.autoGeneratedSlug,- description: this.description,- auto_join_users: this.autoJoinUsers,- threading_enabled: this.threadingEnabled,- };+ @action+ onNameChange(name) {+ this.#debouncedGenerateSlug(name);+ }++ @action+ onSave(event) {+ event.preventDefault();++ if (this.createDisabled) {+ return;+ }++ const formData = new FormData(event.currentTarget);+ const data = Object.fromEntries(formData.entries());+ data.auto_join_users = data.auto_join_users === "on";+ data.slug ??= this.autoGeneratedSlug;+ data.threading_enabled = data.threading_enabled === "on";++ if (data.auto_join_users) {+ this.dialog.yesNoConfirm({+ message: this.autoJoinWarning,+ didConfirm: () => this.#createChannel(data),+ });+ } else {+ this.#createChannel(data);+ }+ }+ #createChannel(data) {return this.chatApi.createChannel(data).then((channel) => {- this.send("closeModal");+ this.args.closeModal();this.chatChannelsManager.follow(channel);this.router.transitionTo("chat.channel", ...channel.routeModels);}).catch((e) => {- this.flash(e.jqXHR.responseJSON.errors[0], "error");+ this.flash = e.jqXHR.responseJSON.errors[0];});}- _buildCategorySlug(category) {+ #buildCategorySlug(category) {const parent = category.parentCategory;if (parent) {- return `${this._buildCategorySlug(parent)}/${category.slug}`;+ return `${this.#buildCategorySlug(parent)}/${category.slug}`;} else {return category.slug;}}- _updateAutoJoinConfirmWarning(category, catPermissions) {+ #updateAutoJoinConfirmWarning(category, catPermissions) {const allowedGroups = catPermissions.allowed_groups;let warning;@@ -158,19 +183,19 @@ export default class CreateChannelController extends Controller.extend();}- this.set("autoJoinWarning", warning);+ this.autoJoinWarning = warning;}- _updatePermissionsHint(category) {+ #updatePermissionsHint(category) {if (category) {- const fullSlug = this._buildCategorySlug(category);+ const fullSlug = this.#buildCategorySlug(category);- this.set("loadingPermissionHint", true);+ this.loadingPermissionHint = true;return this.chatApi.categoryPermissions(category.id).then((catPermissions) => {- this._updateAutoJoinConfirmWarning(category, catPermissions);+ this.#updateAutoJoinConfirmWarning(category, catPermissions);const allowedGroups = catPermissions.allowed_groups;const settingLink = `/c/${escapeExpression(fullSlug)}/edit/security`;let hint;@@ -207,77 +232,40 @@ export default class CreateChannelController extends Controller.extend(break;}- this.set("categoryPermissionsHint", htmlSafe(hint));+ this.categoryPermissionsHint = htmlSafe(hint);}).finally(() => {- this.set("loadingPermissionHint", false);+ this.loadingPermissionHint = false;});} else {- this.set("categoryPermissionsHint", DEFAULT_HINT);- this.set("autoJoinWarning", "");+ this.categoryPermissionsHint = DEFAULT_HINT;+ this.autoJoinWarning = "";}}// intentionally not showing AJAX error for this, we will autogenerate// the slug server-side if they leave it blank- _generateSlug(name) {- ajax("/slugs.json", { type: "POST", data: { name } }).then((response) => {- this.set("autoGeneratedSlug", response.slug);- });+ #generateSlug(name) {+ return ajax("/slugs.json", { type: "POST", data: { name } }).then(+ (response) => {+ this.autoGeneratedSlug = response.slug;+ }+ );}- _debouncedGenerateSlug(name) {- cancel(this.generateSlugHandler);- this._clearAutoGeneratedSlug();+ #debouncedGenerateSlug(name) {+ cancel(this.#generateSlugHandler);+ this.autoGeneratedSlug = "";+if (!name) {return;}- this.generateSlugHandler = discourseDebounce(++ this.#generateSlugHandler = discourseDebounce(this,- this._generateSlug,+ this.#generateSlug,name,300);}-- _clearAutoGeneratedSlug() {- this.set("autoGeneratedSlug", "");- }-- @action- onCategoryChange(categoryId) {- let category = categoryId- ? this.site.categories.findBy("id", categoryId)- : null;- this._updatePermissionsHint(category);-- const name = this.name || category?.name || "";- this.setProperties({- categoryId,- category,- name,- });- this._debouncedGenerateSlug(name);- }-- @action- onNameChange(name) {- this._debouncedGenerateSlug(name);- }-- @action- create() {- if (this.createDisabled) {- return;- }-- if (this.autoJoinUsers) {- this.dialog.yesNoConfirm({- message: this.autoJoinWarning,- didConfirm: () => this._createChannel(),- });- } else {- this._createChannel();- }- }}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/delete-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/delete-channel.hbsnew file mode 100644index 00000000000..3e7c026a977--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/delete-channel.hbs@@ -0,0 +1,32 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-delete-channel"+ @inline={{@inline}}+ @title={{i18n "chat.channel_delete.title"}}+ @flash={{this.flash}}+ @flashType={{this.flashType}}+>+ <:body>+ <p class="chat-modal-delete-channel__instructions">+ {{this.instructionsText}}+ </p>++ <TextField+ @value={{this.channelNameConfirmation}}+ @id="channel-delete-confirm-name"+ @placeholderKey="chat.channel_delete.confirm_channel_name"+ @autocorrect="off"+ @autocapitalize="off"+ />+ </:body>+ <:footer>+ <DButton+ @disabled={{this.buttonDisabled}}+ @class="btn-danger"+ @action={{this.deleteChannel}}+ @label="chat.channel_delete.confirm"+ @id="chat-confirm-delete-channel"+ />+ <DButton @label="cancel" @class="btn-flat" @action={{@closeModal}} />+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/delete-channel.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/delete-channel.jsnew file mode 100644index 00000000000..affb248edc6--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/delete-channel.js@@ -0,0 +1,68 @@+import Component from "@glimmer/component";+import { isEmpty } from "@ember/utils";+import I18n from "I18n";+import { action } from "@ember/object";+import { inject as service } from "@ember/service";+import { popupAjaxError } from "discourse/lib/ajax-error";+import discourseLater from "discourse-common/lib/later";+import { htmlSafe } from "@ember/template";+import { tracked } from "@glimmer/tracking";++export default class ChatModalDeleteChannel extends Component {+ @service chatApi;+ @service router;++ @tracked channelNameConfirmation;+ @tracked deleting = false;+ @tracked confirmed = false;+ @tracked flash;+ @tracked flashType;++ get channel() {+ return this.args.model.channel;+ }++ get buttonDisabled() {+ if (this.deleting || this.confirmed) {+ return true;+ }++ if (+ isEmpty(this.channelNameConfirmation) ||+ this.channelNameConfirmation.toLowerCase() !==+ this.channel.title.toLowerCase()+ ) {+ return true;+ }++ return false;+ }++ get instructionsText() {+ return htmlSafe(+ I18n.t("chat.channel_delete.instructions", {+ name: this.channel.escapedTitle,+ })+ );+ }++ @action+ deleteChannel() {+ this.deleting = true;++ return this.chatApi+ .destroyChannel(this.channel.id, this.channelNameConfirmation)+ .then(() => {+ this.confirmed = true;+ this.flash = I18n.t("chat.channel_delete.process_started");+ this.flashType = "success";++ discourseLater(() => {+ this.args.closeModal();+ this.router.transitionTo("chat");+ }, 3000);+ })+ .catch(popupAjaxError)+ .finally(() => (this.deleting = false));+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-description.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-description.hbsnew file mode 100644index 00000000000..3a21233edbd--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-description.hbs@@ -0,0 +1,37 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-edit-channel-description"+ @inline={{@inline}}+ @title={{i18n "chat.channel_edit_description_modal.title"}}+ @flash={{this.flash}}+>+ <:body>+ <span class="chat-modal-edit-channel-description__description">{{i18n+ "chat.channel_edit_description_modal.description"+ }}</span>+ <CharCounter+ @value={{this.editedDescription}}+ @max={{this.descriptionMaxLength}}+ >+ <textarea+ {{on+ "input"+ (action this.onChangeChatChannelDescription value="target.value")+ }}+ class="chat-modal-edit-channel-description__description-input"+ placeholder={{i18n+ "chat.channel_edit_description_modal.input_placeholder"+ }}+ >{{this.editedDescription}}</textarea>+ </CharCounter>+ </:body>+ <:footer>+ <DButton+ @class="btn-primary create"+ @action={{this.onSaveChatChannelDescription}}+ @label="save"+ @disabled={{this.isSaveDisabled}}+ />+ <DModalCancel @close={{@closeModal}} />+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-description.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-description.jsnew file mode 100644index 00000000000..2336c6cc040--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-description.js@@ -0,0 +1,49 @@+import Component from "@glimmer/component";+import { action } from "@ember/object";+import { tracked } from "@glimmer/tracking";+import { inject as service } from "@ember/service";++const DESCRIPTION_MAX_LENGTH = 280;++export default class ChatModalEditChannelDescription extends Component {+ @service chatApi;++ @tracked editedDescription = this.channel.description || "";+ @tracked flash;++ get channel() {+ return this.args.model;+ }++ get isSaveDisabled() {+ return (+ this.channel.description === this.editedDescription ||+ this.editedDescription?.length > DESCRIPTION_MAX_LENGTH+ );+ }++ get descriptionMaxLength() {+ return DESCRIPTION_MAX_LENGTH;+ }++ @action+ onSaveChatChannelDescription() {+ return this.chatApi+ .updateChannel(this.channel.id, { description: this.editedDescription })+ .then((result) => {+ this.channel.description = result.channel.description;+ this.args.closeModal();+ })+ .catch((event) => {+ if (event.jqXHR?.responseJSON?.errors) {+ this.flash = event.jqXHR.responseJSON.errors.join("\n");+ }+ });+ }++ @action+ onChangeChatChannelDescription(description) {+ this.flash = null;+ this.editedDescription = description;+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.hbsnew file mode 100644index 00000000000..b4d8ee1df1c--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.hbs@@ -0,0 +1,54 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-edit-channel-name"+ @inline={{@inline}}+ @title={{i18n "chat.channel_edit_name_slug_modal.title"}}+ @flash={{this.flash}}+>+ <:body>+ <div class="edit-channel-control">+ <label for="channel-name" class="edit-channel-label">+ {{i18n "chat.channel_edit_name_slug_modal.name"}}+ </label>+ <Input+ name="channel-name"+ class="chat-channel-edit-name-slug-modal__name-input"+ placeholder={{i18n+ "chat.channel_edit_name_slug_modal.input_placeholder"+ }}+ @type="text"+ @value={{this.editedName}}+ {{on "input" (action "onChangeChatChannelName" value="target.value")}}+ />+ </div>++ <div class="edit-channel-control">+ <label for="channel-slug" class="edit-channel-label">+ {{i18n "chat.channel_edit_name_slug_modal.slug"}} + <span>+ {{d-icon "info-circle"}}+ <DTooltip>{{i18n+ "chat.channel_edit_name_slug_modal.slug_description"+ }}</DTooltip>+ </span>+ </label>+ <Input+ name="channel-slug"+ class="chat-channel-edit-name-slug-modal__slug-input"+ placeholder={{this.autoGeneratedSlug}}+ {{on "input" (action "onChangeChatChannelSlug" value="target.value")}}+ @type="text"+ @value={{this.editedSlug}}+ />+ </div>+ </:body>+ <:footer>+ <DButton+ @class="btn-primary create"+ @action={{this.onSave}}+ @label="save"+ @disabled={{this.isSaveDisabled}}+ />+ <DModalCancel @close={{@closeModal}} />+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.jsnew file mode 100644index 00000000000..433d6ac0ea6--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.js@@ -0,0 +1,84 @@+import Component from "@glimmer/component";+import discourseDebounce from "discourse-common/lib/debounce";+import { ajax } from "discourse/lib/ajax";+import { cancel } from "@ember/runloop";+import { action } from "@ember/object";+import { extractError } from "discourse/lib/ajax-error";+import { tracked } from "@glimmer/tracking";+import { inject as service } from "@ember/service";++export default class ChatModalEditChannelName extends Component {+ @service chatApi;+ @service siteSettings;++ @tracked editedName = this.channel.title;+ @tracked editedSlug = this.channel.slug;+ @tracked autoGeneratedSlug = "";+ @tracked flash;++ #generateSlugHandler = null;++ get channel() {+ return this.args.model;+ }++ get isSaveDisabled() {+ return (+ (this.channel.title === this.editedName &&+ this.channel.slug === this.editedSlug) ||+ this.editedName?.length > this.siteSettings.max_topic_title_length+ );+ }++ @action+ onSave() {+ return this.chatApi+ .updateChannel(this.channel.id, {+ name: this.editedName,+ slug: this.editedSlug || this.autoGeneratedSlug || this.channel.slug,+ })+ .then((result) => {+ this.channel.title = result.channel.title;+ this.args.closeModal();+ })+ .catch((error) => (this.flash = extractError(error)));+ }++ @action+ onChangeChatChannelName(title) {+ this.flash = null;+ this.#debouncedGenerateSlug(title);+ }++ @action+ onChangeChatChannelSlug() {+ this.flash = null;+ this.#debouncedGenerateSlug(this.editedName);+ }++ #debouncedGenerateSlug(name) {+ cancel(this.#generateSlugHandler);+ this.autoGeneratedSlug = "";++ if (!name) {+ return;+ }++ this.#generateSlugHandler = discourseDebounce(+ this,+ this.#generateSlug,+ name,+ 300+ );+ }++ // intentionally not showing AJAX error for this, we will autogenerate+ // the slug server-side if they leave it blank+ #generateSlug(name) {+ return ajax("/slugs.json", { type: "POST", data: { name } }).then(+ (response) => {+ this.autoGeneratedSlug = response.slug;+ }+ );+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/move-message-to-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/move-message-to-channel.hbsnew file mode 100644index 00000000000..2d09a13ba89--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/move-message-to-channel.hbs@@ -0,0 +1,29 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-move-message-to-channel"+ @inline={{@inline}}+ @title={{i18n "chat.move_to_channel.title"}}+>+ <:body>+ {{#if this.selectedMessageCount}}+ <p>{{this.instructionsText}}</p>+ {{/if}}++ <ChatChannelChooser+ @class="chat-modal-move-message-to-channel__channel-chooser"+ @content={{this.availableChannels}}+ @value={{this.destinationChannelId}}+ @nameProperty="title"+ />+ </:body>+ <:footer>+ <DButton+ @class="btn-primary"+ @icon="sign-out-alt"+ @disabled={{this.disableMoveButton}}+ @action={{this.moveMessages}}+ @label="chat.move_to_channel.confirm_move"+ />+ <DButton @label="cancel" @class="btn-flat" @action={{@closeModal}} />+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-move-to-channel-modal-inner.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/move-message-to-channel.jssimilarity index 64%rename from plugins/chat/assets/javascripts/discourse/components/chat-message-move-to-channel-modal-inner.jsrename to plugins/chat/assets/javascripts/discourse/components/chat/modal/move-message-to-channel.jsindex 86a2dd8c4c1..ca4ff3afbd4 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-message-move-to-channel-modal-inner.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/move-message-to-channel.js@@ -1,35 +1,49 @@-import Component from "@ember/component";-import I18n from "I18n";-import { reads } from "@ember/object/computed";+import Component from "@glimmer/component";import { isBlank } from "@ember/utils";-import { action, computed } from "@ember/object";+import { action } from "@ember/object";import { inject as service } from "@ember/service";+import { tracked } from "@glimmer/tracking";import { popupAjaxError } from "discourse/lib/ajax-error";import { htmlSafe } from "@ember/template";+import I18n from "I18n";-export default class MoveToChannelModalInner extends Component {+export default class ChatModalMoveMessageToChannel extends Component {@service chat;@service chatApi;@service router;@service chatChannelsManager;- tagName = "";- sourceChannel = null;- destinationChannelId = null;- selectedMessageIds = null;+ @tracked destinationChannelId;++ get sourceChannel() {+ return this.args.model.sourceChannel;+ }++ get selectedMessageIds() {+ return this.args.model.selectedMessageIds;+ }- @reads("selectedMessageIds.length") selectedMessageCount;+ get selectedMessageCount() {+ return this.selectedMessageIds?.length;+ }- @computed("destinationChannelId")get disableMoveButton() {return isBlank(this.destinationChannelId);}- @computed("chatChannelsManager.publicMessageChannels.[]")get availableChannels() {- return this.chatChannelsManager.publicMessageChannels.rejectBy(- "id",- this.sourceChannel.id+ return (+ this.args.model.availableChannels ||+ this.chatChannelsManager.publicMessageChannels+ ).rejectBy("id", this.sourceChannel.id);+ }++ get instructionsText() {+ return htmlSafe(+ I18n.t("chat.move_to_channel.instructions", {+ channelTitle: this.sourceChannel.escapedTitle,+ count: this.selectedMessageCount,+ }));}@@ -50,14 +64,4 @@ export default class MoveToChannelModalInner extends Component {}).catch(popupAjaxError);}-- @computed()- get instructionsText() {- return htmlSafe(- I18n.t("chat.move_to_channel.instructions", {- channelTitle: this.sourceChannel.escapedTitle,- count: this.selectedMessageCount,- })- );- }}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/new-message.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/new-message.hbsnew file mode 100644index 00000000000..05b535f5e6c--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/new-message.hbs@@ -0,0 +1,8 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-new-message"+ @title="chat.new_message_modal.title"+ @inline={{@inline}}+>+ <Chat::MessageCreator @onClose={{@closeModal}} />+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/thread-settings.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/thread-settings.hbsnew file mode 100644index 00000000000..348bf2ccd77--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/thread-settings.hbs@@ -0,0 +1,26 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-thread-settings"+ @inline={{@inline}}+ @title={{i18n "chat.thread.settings"}}+>+ <:body>+ <label for="thread-title" class="thread-title-label">+ {{i18n "chat.thread.title"}}+ </label>+ <Input+ name="thread-title"+ class="chat-modal-thread-settings__title-input"+ @type="text"+ @value={{this.editedTitle}}+ />+ </:body>+ <:footer>+ <DButton+ @class="btn-primary"+ @disabled={{this.buttonDisabled}}+ @action={{this.saveThread}}+ @label="save"+ />+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread/settings-modal-inner.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/thread-settings.jssimilarity index 69%rename from plugins/chat/assets/javascripts/discourse/components/chat/thread/settings-modal-inner.jsrename to plugins/chat/assets/javascripts/discourse/components/chat/modal/thread-settings.jsindex 18af082ba10..6871c195444 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/thread/settings-modal-inner.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/thread-settings.js@@ -4,25 +4,30 @@ import { tracked } from "@glimmer/tracking";import { inject as service } from "@ember/service";import { action } from "@ember/object";-export default class ChatThreadSettingsModalInner extends Component {+export default class ChatModalThreadSettings extends Component {@service chatApi;- @tracked editedTitle = this.args.thread.title || "";+ @tracked editedTitle = this.thread.title || "";@tracked saving = false;get buttonDisabled() {return this.saving;}+ get thread() {+ return this.args.model;+ }+@actionsaveThread() {this.saving = true;+this.chatApi- .editThread(this.args.thread.channel.id, this.args.thread.id, {+ .editThread(this.thread.channel.id, this.thread.id, {title: this.editedTitle,}).then(() => {- this.args.thread.title = this.editedTitle;+ this.thread.title = this.editedTitle;this.args.closeModal();}).catch(popupAjaxError)diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/toggle-channel-status.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/toggle-channel-status.hbsnew file mode 100644index 00000000000..85e35103ef5--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/toggle-channel-status.hbs@@ -0,0 +1,20 @@+<DModal+ @closeModal={{@closeModal}}+ class="chat-modal-toggle-channel-status"+ @inline={{@inline}}+ @title={{i18n this.modalTitle}}+>+ <:body>+ <p+ class="chat-modal-toggle-channel-status__instructions"+ >{{this.instructions}}</p>+ </:body>+ <:footer>+ <DButton+ @class="btn-primary"+ @action={{this.onStatusChange}}+ @label={{this.buttonLabel}}+ @id="chat-channel-toggle-btn"+ />+ </:footer>+</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-toggle-view.js b/plugins/chat/assets/javascripts/discourse/components/chat/modal/toggle-channel-status.jssimilarity index 65%rename from plugins/chat/assets/javascripts/discourse/components/chat-channel-toggle-view.jsrename to plugins/chat/assets/javascripts/discourse/components/chat/modal/toggle-channel-status.jsindex 5ed0b2dbdf5..d801aa67fe5 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-toggle-view.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/toggle-channel-status.js@@ -1,40 +1,37 @@-import Component from "@ember/component";+import Component from "@glimmer/component";+import { action } from "@ember/object";import { htmlSafe } from "@ember/template";import { CHANNEL_STATUSES } from "discourse/plugins/chat/discourse/models/chat-channel";import I18n from "I18n";-import { action, computed } from "@ember/object";import { inject as service } from "@ember/service";import { popupAjaxError } from "discourse/lib/ajax-error";-export default class ChatChannelToggleView extends Component {- @service chat;+export default class ChatModalToggleChannelStatus extends Component {@service chatApi;@service router;- tagName = "";- channel = null;- onStatusChange = null;- @computed("channel.isClosed")+ get channel() {+ return this.args.model;+ }+get buttonLabel() {- if (this.channel.isClosed) {+ if (this.channel?.isClosed) {return "chat.channel_settings.open_channel";} else {return "chat.channel_settings.close_channel";}}- @computed("channel.isClosed")get instructions() {- if (this.channel.isClosed) {+ if (this.channel?.isClosed) {return htmlSafe(I18n.t("chat.channel_open.instructions"));} else {return htmlSafe(I18n.t("chat.channel_close.instructions"));}}- @computed("channel.isClosed")get modalTitle() {- if (this.channel.isClosed) {+ if (this.channel?.isClosed) {return "chat.channel_open.title";} else {return "chat.channel_close.title";@@ -42,15 +39,16 @@ export default class ChatChannelToggleView extends Component {}@action- changeChannelStatus() {+ onStatusChange() {const status = this.channel.isClosed? CHANNEL_STATUSES.open: CHANNEL_STATUSES.closed;return this.chatApi.updateChannelStatus(this.channel.id, status)- .finally(() => {- this.onStatusChange?.(this.channel);+ .then(() => {+ this.args.closeModal();+ this.router.transitionTo("chat.channel", ...this.channel.routeModels);}).catch(popupAjaxError);}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/selection-manager.js b/plugins/chat/assets/javascripts/discourse/components/chat/selection-manager.jsindex 2c4a2e93428..9614e7b6d13 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/selection-manager.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/selection-manager.js@@ -1,6 +1,5 @@import Component from "@glimmer/component";import { action } from "@ember/object";-import showModal from "discourse/lib/show-modal";import { clipboardCopyAsync } from "discourse/lib/utilities";import { getOwner } from "discourse-common/lib/get-owner";import { isTesting } from "discourse-common/config/environment";@@ -8,10 +7,12 @@ import { popupAjaxError } from "discourse/lib/ajax-error";import { inject as service } from "@ember/service";import { bind } from "discourse-common/utils/decorators";import { tracked } from "@glimmer/tracking";+import ChatModalMoveMessageToChannel from "discourse/plugins/chat/discourse/components/chat/modal/move-message-to-channel";export default class ChatSelectionManager extends Component {@service("composer") topicComposer;@service router;+ @service modal;@service site;@service("chat-api") api;@@ -42,9 +43,11 @@ export default class ChatSelectionManager extends Component {@actionopenMoveMessageModal() {- showModal("chat-message-move-to-channel-modal").setProperties({- sourceChannel: this.args.pane.channel,- selectedMessageIds: this.args.pane.selectedMessageIds,+ this.modal.show(ChatModalMoveMessageToChannel, {+ model: {+ sourceChannel: this.args.pane.channel,+ selectedMessageIds: this.args.pane.selectedMessageIds,+ },});}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.js b/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.jsindex b2e5f877b3f..bbc0b8c84f8 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.js@@ -124,6 +124,7 @@ export default class ChatThreadList extends Component {}#unsubscribe() {+ // TODO (joffrey) In drawer we won't have channel anymore at this pointthis.messageBus.unsubscribe(`/chat/${this.args.channel.id}`,this.onMessageBusdiff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread/header.js b/plugins/chat/assets/javascripts/discourse/components/chat/thread/header.jsindex 3ddce5f9eb0..4b863f04094 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/thread/header.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/thread/header.js@@ -1,11 +1,11 @@import Component from "@glimmer/component";import { NotificationLevels } from "discourse/lib/notification-levels";import { popupAjaxError } from "discourse/lib/ajax-error";-import showModal from "discourse/lib/show-modal";import { inject as service } from "@ember/service";import { action } from "@ember/object";import UserChatThreadMembership from "discourse/plugins/chat/discourse/models/user-chat-thread-membership";import { tracked } from "@glimmer/tracking";+import ChatModalThreadSettings from "discourse/plugins/chat/discourse/components/chat/modal/thread-settings";export default class ChatThreadHeader extends Component {@service currentUser;@@ -14,6 +14,7 @@ export default class ChatThreadHeader extends Component {@service chatStateManager;@service chatHistory;@service site;+ @service modal;@tracked persistedNotificationLevel = true;@@ -60,8 +61,7 @@ export default class ChatThreadHeader extends Component {@actionopenThreadSettings() {- const controller = showModal("chat-thread-settings-modal");- controller.set("thread", this.args.thread);+ this.modal.show(ChatModalThreadSettings, { model: this.args.thread });}@actiondiff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread/settings-modal-inner.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/thread/settings-modal-inner.hbsdeleted file mode 100644index 15b4ae124bb..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/chat/thread/settings-modal-inner.hbs+++ /dev/null@@ -1,22 +0,0 @@-<DModalBody @title="chat.thread.settings">- <div>- <label for="thread-title" class="thread-title-label">- {{i18n "chat.thread.title"}}- </label>- <Input- name="thread-title"- class="thread-title-input"- @type="text"- @value={{this.editedTitle}}- />- </div>-</DModalBody>--<div class="modal-footer">- <DButton- @class="btn-primary"- @disabled={{this.buttonDisabled}}- @action={{action "saveThread"}}- @label="save"- />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/modal/chat-new-message.hbs b/plugins/chat/assets/javascripts/discourse/components/modal/chat-new-message.hbsdeleted file mode 100644index d090f4c9fbf..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/modal/chat-new-message.hbs+++ /dev/null@@ -1,7 +0,0 @@-<DModal- @closeModal={{@closeModal}}- class="chat-new-message-modal"- @title="chat.new_message_modal.title"->- <Chat::MessageCreator @onClose={{route-action "closeModal"}} />-</DModal>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/modal/chat-new-message.js b/plugins/chat/assets/javascripts/discourse/components/modal/chat-new-message.jsdeleted file mode 100644index 3a4a62b1fbb..00000000000--- a/plugins/chat/assets/javascripts/discourse/components/modal/chat-new-message.js+++ /dev/null@@ -1,6 +0,0 @@-import Component from "@ember/component";-import { inject as service } from "@ember/service";--export default class ChatNewMessageModal extends Component {- @service chat;-}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-archive-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-archive-channel.hbsnew file mode 100644index 00000000000..d2409d2f27c--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-archive-channel.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::ArchiveChannel>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-archive-channel.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-archive-channel.jsnew file mode 100644index 00000000000..57bcb49834a--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-archive-channel.js@@ -0,0 +1,20 @@+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";+import ChatModalArchiveChannel from "discourse/plugins/chat/discourse/components/chat/modal/archive-channel";+import Component from "@glimmer/component";++export default class ChatStyleguideChatModalArchiveChannel extends Component {+ @service modal;++ channel = fabricators.channel();++ @action+ openModal() {+ return this.modal.show(ChatModalArchiveChannel, {+ model: {+ channel: this.channel,+ },+ });+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-channel-summary.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-channel-summary.hbsnew file mode 100644index 00000000000..099820a0a0f--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-channel-summary.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::ChannelSummary>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-channel-summary.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-channel-summary.jsnew file mode 100644index 00000000000..79008022af7--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-channel-summary.js@@ -0,0 +1,16 @@+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import Component from "@glimmer/component";+import ChatModalChannelSummary from "discourse/plugins/chat/discourse/components/chat/modal/channel-summary";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";++export default class ChatStyleguideChatModalChannelSummary extends Component {+ @service modal;++ @action+ openModal() {+ return this.modal.show(ChatModalChannelSummary, {+ model: { channelId: fabricators.channel().id },+ });+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-create-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-create-channel.hbsnew file mode 100644index 00000000000..e2747d289e6--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-create-channel.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::CreateChannel>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-create-channel.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-create-channel.jsnew file mode 100644index 00000000000..3d37663d555--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-create-channel.js@@ -0,0 +1,13 @@+import Component from "@glimmer/component";+import ChatModalCreateChannel from "discourse/plugins/chat/discourse/components/chat/modal/create-channel";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";++export default class ChatStyleguideChatModalCreateChannel extends Component {+ @service modal;++ @action+ openModal() {+ return this.modal.show(ChatModalCreateChannel);+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-delete-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-delete-channel.hbsnew file mode 100644index 00000000000..f9787048ce6--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-delete-channel.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::DeleteChannel>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-delete-channel.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-delete-channel.jsnew file mode 100644index 00000000000..02bba90987b--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-delete-channel.js@@ -0,0 +1,18 @@+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";+import ChatModalDeleteChannel from "discourse/plugins/chat/discourse/components/chat/modal/delete-channel";+import Component from "@glimmer/component";++export default class ChatStyleguideChatModalDeleteChannel extends Component {+ @service modal;++ channel = fabricators.channel();++ @action+ openModal() {+ return this.modal.show(ChatModalDeleteChannel, {+ model: { channel: this.channel },+ });+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-description.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-description.hbsnew file mode 100644index 00000000000..b7d5dcc2804--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-description.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::EditChannelDescription>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-description.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-description.jsnew file mode 100644index 00000000000..018108bc2c7--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-description.js@@ -0,0 +1,18 @@+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";+import ChatModalEditChannelDescription from "discourse/plugins/chat/discourse/components/chat/modal/edit-channel-description";+import Component from "@glimmer/component";++export default class ChatStyleguideChatModalEditChannelDescription extends Component {+ @service modal;++ channel = fabricators.channel();++ @action+ openModal() {+ return this.modal.show(ChatModalEditChannelDescription, {+ model: this.channel,+ });+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-name.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-name.hbsnew file mode 100644index 00000000000..5a40bff03cd--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-name.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::EditChannelName>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-name.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-name.jsnew file mode 100644index 00000000000..7e9770840ba--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-edit-channel-name.js@@ -0,0 +1,18 @@+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";+import ChatModalEditChannelName from "discourse/plugins/chat/discourse/components/chat/modal/edit-channel-name";+import Component from "@glimmer/component";++export default class ChatStyleguideChatModalEditChannelName extends Component {+ @service modal;++ channel = fabricators.channel();++ @action+ openModal() {+ return this.modal.show(ChatModalEditChannelName, {+ model: this.channel,+ });+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-move-message-to-channel.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-move-message-to-channel.hbsnew file mode 100644index 00000000000..e508bd7810a--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-move-message-to-channel.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::MoveMessageToChannel>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-move-message-to-channel.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-move-message-to-channel.jsnew file mode 100644index 00000000000..513dda5dcfe--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-move-message-to-channel.js@@ -0,0 +1,26 @@+import Component from "@glimmer/component";+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";+import ChatModalMoveMessageToChannel from "discourse/plugins/chat/discourse/components/chat/modal/move-message-to-channel";++export default class ChatStyleguideChatModalMoveMessageToChannel extends Component {+ @service modal;++ channel = fabricators.channel();+ selectedMessageIds = [fabricators.message({ channel: this.channel })].mapBy(+ "id"+ );++ @action+ openModal() {+ return this.modal.show(ChatModalMoveMessageToChannel, {+ model: {+ sourceChannel: this.channel,+ selectedMessageIds: [+ fabricators.message({ channel: this.channel }),+ ].mapBy("id"),+ },+ });+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-new-message.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-new-message.hbsnew file mode 100644index 00000000000..e39c631ef7c--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-new-message.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::NewMessage>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-new-message.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-new-message.jsnew file mode 100644index 00000000000..1ace191332a--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-new-message.js@@ -0,0 +1,13 @@+import Component from "@glimmer/component";+import ChatModalNewMessage from "discourse/plugins/chat/discourse/components/chat/modal/new-message";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";++export default class ChatStyleguideChatModalNewMessage extends Component {+ @service modal;++ @action+ openModal() {+ return this.modal.show(ChatModalNewMessage);+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-thread-settings.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-thread-settings.hbsnew file mode 100644index 00000000000..496b4784b58--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-thread-settings.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::ThreadSettings>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-thread-settings.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-thread-settings.jsnew file mode 100644index 00000000000..106faef111d--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-thread-settings.js@@ -0,0 +1,16 @@+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import Component from "@glimmer/component";+import ChatModalThreadSettings from "discourse/plugins/chat/discourse/components/modal/chat/thread-settings";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";++export default class ChatStyleguideChatModalThreadSettings extends Component {+ @service modal;++ @action+ openModal() {+ return this.modal.show(ChatModalThreadSettings, {+ model: fabricators.thread(),+ });+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-toggle-channel-status.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-toggle-channel-status.hbsnew file mode 100644index 00000000000..c11dd520807--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-toggle-channel-status.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Modal::ToggleChannelStatus>">+ <Styleguide::Controls::Row>+ <DButton @translatedLabel="Open modal" @action={{this.openModal}} />+ </Styleguide::Controls::Row>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-toggle-channel-status.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-toggle-channel-status.jsnew file mode 100644index 00000000000..afd29aab914--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-modal-toggle-channel-status.js@@ -0,0 +1,16 @@+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import Component from "@glimmer/component";+import ChatModalToggleChannelStatus from "discourse/plugins/chat/discourse/components/chat/modal/toggle-channel-status";+import { inject as service } from "@ember/service";+import { action } from "@ember/object";++export default class ChatStyleguideChatModalToggleChannelStatus extends Component {+ @service modal;++ @action+ openModal() {+ return this.modal.show(ChatModalToggleChannelStatus, {+ model: fabricators.channel(),+ });+ }+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/organisms/chat.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/organisms/chat.hbsindex d37a61138f9..e883457235a 100644--- a/plugins/chat/assets/javascripts/discourse/components/styleguide/organisms/chat.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/organisms/chat.hbs@@ -3,4 +3,17 @@<Styleguide::ChatThreadListItem /><Styleguide::ChatComposerMessageDetails /><Styleguide::ChatHeaderIcon />-<Styleguide::ChatMessageMentionWarning />\ No newline at end of file+<Styleguide::ChatMessageMentionWarning />++<h2>Modals</h2>++<Styleguide::ChatModalArchiveChannel />+<Styleguide::ChatModalMoveMessageToChannel />+<Styleguide::ChatModalDeleteChannel />+<Styleguide::ChatModalEditChannelDescription />+<Styleguide::ChatModalEditChannelName />+<Styleguide::ChatModalThreadSettings />+<Styleguide::ChatModalCreateChannel />+<Styleguide::ChatModalToggleChannelStatus />+<Styleguide::ChatModalNewMessage />+<Styleguide::ChatModalChannelSummary />\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-archive-modal.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-archive-modal.jsdeleted file mode 100644index d46a9f241d0..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-archive-modal.js+++ /dev/null@@ -1,8 +0,0 @@-import Controller from "@ember/controller";-import ModalFunctionality from "discourse/mixins/modal-functionality";--export default class ChatChannelArchiveModalController extends Controller.extend(- ModalFunctionality-) {- chatChannel = null;-}diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-delete-modal.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-delete-modal.jsdeleted file mode 100644index ad230c1021b..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-delete-modal.js+++ /dev/null@@ -1,8 +0,0 @@-import Controller from "@ember/controller";-import ModalFunctionality from "discourse/mixins/modal-functionality";--export default class ChatChannelDeleteModalController extends Controller.extend(- ModalFunctionality-) {- chatChannel = null;-}diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-edit-description.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-edit-description.jsdeleted file mode 100644index 664a1993bad..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-edit-description.js+++ /dev/null@@ -1,53 +0,0 @@-import Controller from "@ember/controller";-import { action, computed } from "@ember/object";-import ModalFunctionality from "discourse/mixins/modal-functionality";-import { tracked } from "@glimmer/tracking";-import { inject as service } from "@ember/service";--const DESCRIPTION_MAX_LENGTH = 280;--export default class ChatChannelEditDescriptionController extends Controller.extend(- ModalFunctionality-) {- @service chatApi;- @tracked editedDescription = this.model.description || "";-- @computed("model.description", "editedDescription")- get isSaveDisabled() {- return (- this.model.description === this.editedDescription ||- this.editedDescription?.length > DESCRIPTION_MAX_LENGTH- );- }-- get descriptionMaxLength() {- return DESCRIPTION_MAX_LENGTH;- }-- onClose() {- this.clearFlash();- }-- @action- onSaveChatChannelDescription() {- return this.chatApi- .updateChannel(this.model.id, {- description: this.editedDescription,- })- .then((result) => {- this.model.set("description", result.channel.description);- this.send("closeModal");- })- .catch((event) => {- if (event.jqXHR?.responseJSON?.errors) {- this.flash(event.jqXHR.responseJSON.errors.join("\n"), "error");- }- });- }-- @action- onChangeChatChannelDescription(description) {- this.clearFlash();- this.editedDescription = description;- }-}diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-edit-name-slug.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-edit-name-slug.jsdeleted file mode 100644index 82bc6c59b2e..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-edit-name-slug.js+++ /dev/null@@ -1,92 +0,0 @@-import Controller from "@ember/controller";-import discourseDebounce from "discourse-common/lib/debounce";-import { ajax } from "discourse/lib/ajax";-import { cancel } from "@ember/runloop";-import { action, computed } from "@ember/object";-import { flashAjaxError } from "discourse/lib/ajax-error";-import ModalFunctionality from "discourse/mixins/modal-functionality";-import { inject as service } from "@ember/service";-export default class ChatChannelEditTitleController extends Controller.extend(- ModalFunctionality-) {- @service chatApi;- editedName = "";- editedSlug = "";- autoGeneratedSlug = "";-- @computed("model.title", "editedName", "editedSlug")- get isSaveDisabled() {- return (- (this.model.title === this.editedName &&- this.model.slug === this.editedSlug) ||- this.editedName?.length > this.siteSettings.max_topic_title_length- );- }-- onShow() {- this.setProperties({- editedName: this.model.title,- editedSlug: this.model.slug,- });- }-- onClose() {- this.setProperties({- editedName: "",- editedSlug: "",- });- this.clearFlash();- }-- @action- onSaveChatChannelName() {- return this.chatApi- .updateChannel(this.model.id, {- name: this.editedName,- slug: this.editedSlug || this.autoGeneratedSlug || this.model.slug,- })- .then((result) => {- this.model.title = result.channel.title;- this.send("closeModal");- })- .catch(flashAjaxError(this));- }-- @action- onChangeChatChannelName(title) {- this.clearFlash();- this._debouncedGenerateSlug(title);- }-- @action- onChangeChatChannelSlug() {- this.clearFlash();- this._debouncedGenerateSlug(this.editedName);- }-- _clearAutoGeneratedSlug() {- this.set("autoGeneratedSlug", "");- }-- _debouncedGenerateSlug(name) {- cancel(this.generateSlugHandler);- this._clearAutoGeneratedSlug();- if (!name) {- return;- }- this.generateSlugHandler = discourseDebounce(- this,- this._generateSlug,- name,- 300- );- }-- // intentionally not showing AJAX error for this, we will autogenerate- // the slug server-side if they leave it blank- _generateSlug(name) {- ajax("/slugs.json", { type: "POST", data: { name } }).then((response) => {- this.set("autoGeneratedSlug", response.slug);- });- }-}diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-info-about.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-info-about.jsindex b21daefbe2c..8748478788f 100644--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-info-about.js+++ b/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-info-about.js@@ -1,19 +1,25 @@import Controller from "@ember/controller";import { action } from "@ember/object";import ModalFunctionality from "discourse/mixins/modal-functionality";-import showModal from "discourse/lib/show-modal";+import { inject as service } from "@ember/service";+import ChatModalEditChannelDescription from "discourse/plugins/chat/discourse/components/chat/modal/edit-channel-description";+import ChatModalEditChannelName from "discourse/plugins/chat/discourse/components/chat/modal/edit-channel-name";export default class ChatChannelInfoAboutController extends Controller.extend(ModalFunctionality) {+ @service modal;+@actiononEditChatChannelName() {- showModal("chat-channel-edit-name-slug", { model: this.model });+ return this.modal.show(ChatModalEditChannelName, {+ model: this.model,+ });}@actiononEditChatChannelDescription() {- showModal("chat-channel-edit-description", {+ return this.modal.show(ChatModalEditChannelDescription, {model: this.model,});}diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-selector-modal.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-selector-modal.jsdeleted file mode 100644index ac07dd24838..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-selector-modal.js+++ /dev/null@@ -1,12 +0,0 @@-import Controller from "@ember/controller";-import ModalFunctionality from "discourse/mixins/modal-functionality";-import { action } from "@ember/object";--export default class ChatChannelSelectorModalController extends Controller.extend(- ModalFunctionality-) {- @action- closeSelf() {- this.send("closeModal");- }-}diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-toggle.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-toggle.jsdeleted file mode 100644index a9cba248a8e..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-channel-toggle.js+++ /dev/null@@ -1,19 +0,0 @@-import Controller from "@ember/controller";-import ModalFunctionality from "discourse/mixins/modal-functionality";-import { action } from "@ember/object";-import { inject as service } from "@ember/service";--export default class ChatChannelToggleController extends Controller.extend(- ModalFunctionality-) {- @service chat;- @service router;-- chatChannel = null;-- @action- channelStatusChanged(channel) {- this.send("closeModal");- this.router.transitionTo("chat.channel", ...channel.routeModels);- }-}diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-message-move-to-channel-modal.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-message-move-to-channel-modal.jsdeleted file mode 100644index 86ebd1e8ab4..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-message-move-to-channel-modal.js+++ /dev/null@@ -1,8 +0,0 @@-import Controller from "@ember/controller";-import ModalFunctionality from "discourse/mixins/modal-functionality";--export default class ChatMessageMoveToChannelModalController extends Controller.extend(- ModalFunctionality-) {- chatChannel = null;-}diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat-thread-settings-modal.js b/plugins/chat/assets/javascripts/discourse/controllers/chat-thread-settings-modal.jsdeleted file mode 100644index 7a59f9b99e5..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/chat-thread-settings-modal.js+++ /dev/null@@ -1,8 +0,0 @@-import Controller from "@ember/controller";-import ModalFunctionality from "discourse/mixins/modal-functionality";--export default class ChatThreadSettingsModalController extends Controller.extend(- ModalFunctionality-) {- thread = null;-}diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-keyboard-shortcuts.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-keyboard-shortcuts.jsindex f8f87fc89fd..ba6a1b4434b 100644--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-keyboard-shortcuts.js+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-keyboard-shortcuts.js@@ -1,6 +1,6 @@import { withPluginApi } from "discourse/lib/plugin-api";import { PLATFORM_KEY_MODIFIER } from "discourse/lib/keyboard-shortcuts";-import ChatNewMessageModal from "discourse/plugins/chat/discourse/components/modal/chat-new-message";+import ChatModalNewMessage from "discourse/plugins/chat/discourse/components/chat/modal/new-message";export default {name: "chat-keyboard-shortcuts",@@ -22,10 +22,10 @@ export default {const chatChannelsManager = container.lookup("service:chat-channels-manager");- const openChannelSelector = (e) => {+ const openQuickChannelSelector = (e) => {e.preventDefault();e.stopPropagation();- modal.show(ChatNewMessageModal);+ modal.show(ChatModalNewMessage);};const handleMoveUpShortcut = (e) => {@@ -126,7 +126,7 @@ export default {withPluginApi("0.12.1", (api) => {api.addKeyboardShortcut(`${PLATFORM_KEY_MODIFIER}+k`,- openChannelSelector,+ openQuickChannelSelector,{global: true,help: {diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.jsindex 7b8ab459fb7..7b9886706ca 100644--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js@@ -9,7 +9,7 @@ import { emojiUnescape } from "discourse/lib/text";import { decorateUsername } from "discourse/helpers/decorate-username-selector";import { until } from "discourse/lib/formatter";import { inject as service } from "@ember/service";-import ChatNewMessageModal from "discourse/plugins/chat/discourse/components/modal/chat-new-message";+import ChatModalNewMessage from "discourse/plugins/chat/discourse/components/chat/modal/new-message";export default {name: "chat-sidebar",@@ -379,7 +379,7 @@ export default {id: "startDm",title: I18n.t("chat.direct_messages.new"),action: () => {- this.modal.show(ChatNewMessageModal);+ this.modal.show(ChatModalNewMessage);},},];diff --git a/plugins/chat/assets/javascripts/discourse/lib/fabricators.js b/plugins/chat/assets/javascripts/discourse/lib/fabricators.jsindex 3b90bd00037..a4dba3ff61b 100644--- a/plugins/chat/assets/javascripts/discourse/lib/fabricators.js+++ b/plugins/chat/assets/javascripts/discourse/lib/fabricators.js@@ -68,6 +68,7 @@ function channelFabricator(args = {}) {description: args.description,chatable: args.chatable || categoryFabricator(),status: CHANNEL_STATUSES.open,+ slug: args.chatable?.slug || "general",},args)diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-api.js b/plugins/chat/assets/javascripts/discourse/services/chat-api.jsindex 960376a4b39..54d86607e81 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat-api.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat-api.js@@ -476,7 +476,8 @@ export default class ChatApi extends Service {** @param {number} channelId - The ID of the channel.* @param {Array<number>} userIds - The IDs of the users to invite.- * @param {Array<number>} [messageId] - The ID of a message to highlight when opening the notification.+ * @param {object} options+ * @param {number} options.chat_message_id - A message ID to display in the invite.*/invite(channelId, userIds, options = {}) {return ajax(`/chat/${channelId}/invite`, {@@ -485,6 +486,17 @@ export default class ChatApi extends Service {});}+ /**+ * Summarize a channel.+ *+ * @param {number} channelId - The ID of the channel to summarize.+ * @param {object} options+ * @param {number} options.since - Number of hours ago the summary should start (1, 3, 6, 12, 24, 72, 168).+ */+ summarize(channelId, options = {}) {+ return this.#getRequest(`/channels/${channelId}/summarize`, options);+ }+get #basePath() {return "/chat/api";}diff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/channel-summary.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/channel-summary.hbsdeleted file mode 100644index c5bf414e9f7..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/channel-summary.hbs+++ /dev/null@@ -1,4 +0,0 @@-<ChannelSummary- @channelId={{this.channelId}}- @closeModal={{route-action "closeModal"}}-/>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-archive-modal.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-archive-modal.hbsdeleted file mode 100644index bb925b1952b..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-archive-modal.hbs+++ /dev/null@@ -1,4 +0,0 @@-<ChatChannelArchiveModalInner- @chatChannel={{this.chatChannel}}- @closeModal={{route-action "closeModal"}}-/>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-delete-modal.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-delete-modal.hbsdeleted file mode 100644index 90820b131a3..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-delete-modal.hbs+++ /dev/null@@ -1,4 +0,0 @@-<ChatChannelDeleteModalInner- @chatChannel={{this.chatChannel}}- @closeModal={{action "closeModal"}}-/>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-description.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-description.hbsdeleted file mode 100644index 059e2d147bf..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-description.hbs+++ /dev/null@@ -1,32 +0,0 @@-<DModalBody @title="chat.channel_edit_description_modal.title">- <span class="chat-channel-edit-description-modal__description">- {{i18n "chat.channel_edit_description_modal.description"}}- </span>- <CharCounter- @value={{this.editedDescription}}- @max={{this.descriptionMaxLength}}- >- <textarea- {{on- "input"- (action this.onChangeChatChannelDescription value="target.value")- }}- class="chat-channel-edit-description-modal__description-input"- placeholder={{i18n- "chat.channel_edit_description_modal.input_placeholder"- }}- >- {{this.editedDescription}}- </textarea>- </CharCounter>-</DModalBody>--<div class="modal-footer">- <DButton- @class="btn-primary create"- @action={{action "onSaveChatChannelDescription"}}- @label="save"- @disabled={{this.isSaveDisabled}}- />- <DModalCancel @close={{route-action "closeModal"}} />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name-slug.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name-slug.hbsdeleted file mode 100644index 0d73d0003b8..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name-slug.hbs+++ /dev/null@@ -1,45 +0,0 @@-<DModalBody @title="chat.channel_edit_name_slug_modal.title">- <div class="edit-channel-control">- <label for="channel-name" class="edit-channel-label">- {{i18n "chat.channel_edit_name_slug_modal.name"}}- </label>- <Input- name="channel-name"- class="chat-channel-edit-name-slug-modal__name-input"- placeholder={{i18n "chat.channel_edit_name_slug_modal.input_placeholder"}}- @type="text"- @value={{this.editedName}}- {{on "input" (action "onChangeChatChannelName" value="target.value")}}- />- </div>-- <div class="edit-channel-control">- <label for="channel-slug" class="edit-channel-label">- {{i18n "chat.channel_edit_name_slug_modal.slug"}} - <span>- {{d-icon "info-circle"}}- <DTooltip>{{i18n- "chat.channel_edit_name_slug_modal.slug_description"- }}</DTooltip>- </span>- </label>- <Input- name="channel-slug"- class="chat-channel-edit-name-slug-modal__slug-input"- placeholder={{this.autoGeneratedSlug}}- {{on "input" (action "onChangeChatChannelSlug" value="target.value")}}- @type="text"- @value={{this.editedSlug}}- />- </div>-</DModalBody>--<div class="modal-footer">- <DButton- @class="btn-primary create"- @action={{action "onSaveChatChannelName"}}- @label="save"- @disabled={{this.isSaveDisabled}}- />- <DModalCancel @close={{route-action "closeModal"}} />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name.hbsdeleted file mode 100644index fffffe406c7..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-edit-name.hbs+++ /dev/null@@ -1,22 +0,0 @@-<DModalBody @title="chat.channel_edit_name_modal.title">- <input- class="chat-channel-edit-name-modal__name-input"- placeholder={{i18n "chat.channel_edit_name_modal.input_placeholder"}}- {{on "input" (action "onChangeChatChannelName" value="target.value")}}- type="text"- value={{this.model.title}}- />- <span class="chat-channel-edit-name-modal__description">- {{i18n "chat.channel_edit_name_modal.description"}}- </span>-</DModalBody>--<div class="modal-footer">- <DButton- @class="btn-primary create"- @action={{action "onSaveChatChannelName"}}- @label="save"- @disabled={{this.isSaveDisabled}}- />- <DModalCancel @close={{route-action "closeModal"}} />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-selector-modal.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-selector-modal.hbsdeleted file mode 100644index 498861076c6..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-selector-modal.hbs+++ /dev/null@@ -1 +0,0 @@-<ChatChannelSelectorModalInner @close={{this.closeSelf}} />\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-toggle.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-toggle.hbsdeleted file mode 100644index 121e2c8f424..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-channel-toggle.hbs+++ /dev/null@@ -1,5 +0,0 @@-<ChatChannelToggleView- @channel={{this.chatChannel}}- @closeModal={{action "closeModal"}}- @onStatusChange={{action "channelStatusChanged"}}-/>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-message-move-to-channel-modal.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-message-move-to-channel-modal.hbsdeleted file mode 100644index 0dcc0c1114d..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-message-move-to-channel-modal.hbs+++ /dev/null@@ -1,5 +0,0 @@-<ChatMessageMoveToChannelModalInner- @sourceChannel={{this.sourceChannel}}- @selectedMessageIds={{this.selectedMessageIds}}- @closeModal={{action "closeModal"}}-/>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-thread-settings-modal.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/chat-thread-settings-modal.hbsdeleted file mode 100644index d94e9d24ae3..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/chat-thread-settings-modal.hbs+++ /dev/null@@ -1,4 +0,0 @@-<Chat::Thread::SettingsModalInner- @thread={{this.thread}}- @closeModal={{route-action "closeModal"}}-/>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/templates/modal/create-channel.hbs b/plugins/chat/assets/javascripts/discourse/templates/modal/create-channel.hbsdeleted file mode 100644index 278f03c1c6a..00000000000--- a/plugins/chat/assets/javascripts/discourse/templates/modal/create-channel.hbs+++ /dev/null@@ -1,115 +0,0 @@-<DModalBody @title="chat.create_channel.title">- <div class="create-channel__control -name">- <label for="channel-name" class="create-channel__label">- {{i18n "chat.create_channel.name"}}- </label>- <Input- name="channel-name"- class="create-channel__input"- @type="text"- @value={{this.name}}- {{on "input" (action "onNameChange" value="target.value")}}- />- </div>-- <div class="create-channel__control -slug">- <label for="channel-slug" class="create-channel__label">- {{i18n "chat.create_channel.slug"}} - <span>- {{d-icon "info-circle"}}- <DTooltip>- {{i18n "chat.channel_edit_name_slug_modal.slug_description"}}- </DTooltip>- </span>- </label>- <Input- name="channel-slug"- class="create-channel__input"- @type="text"- @value={{this.slug}}- placeholder={{this.autoGeneratedSlug}}- />- </div>-- <div class="create-channel__control -description">- <label for="channel-description" class="create-channel__label">- {{i18n "chat.create_channel.description"}}- </label>- <Input- name="channel-description"- class="create-channel__input"- @type="textarea"- @value={{this.description}}- />- </div>-- <div class="create-channel__control">- <label class="create-channel__label">- {{i18n "chat.create_channel.choose_category.label"}}- </label>- <CategoryChooser- @value={{this.categoryId}}- @onChange={{action "onCategoryChange"}}- @options={{hash none="chat.create_channel.choose_category.none"}}- />-- {{#if this.categoryPermissionsHint}}- <div- class={{concat-class- "create-channel__hint"- (if this.loadingPermissionHint "loading-permissions")- }}- >- {{this.categoryPermissionsHint}}- </div>- {{/if}}- </div>-- {{#if this.autoJoinAvailable}}- <div class="create-channel__control -auto-join">- <label class="create-channel__label">- <Input @type="checkbox" @checked={{this.autoJoinUsers}} />- <div class="auto-join-channel">- <span class="create-channel__label-title">- {{i18n "chat.settings.auto_join_users_label"}}- </span>- <p class="create-channel__label-description">- {{#if this.categoryName}}- {{i18n- "chat.settings.auto_join_users_info"- category=this.categoryName- }}- {{else}}- {{i18n "chat.settings.auto_join_users_info_no_category"}}- {{/if}}- </p>- </div>- </label>- </div>- {{/if}}-- {{#if this.threadingAvailable}}- <div class="create-channel__control -threading-toggle">- <label class="create-channel__label">- <Input @type="checkbox" @checked={{this.threadingEnabled}} />- <div class="threading-channel">- <span class="create-channel__label-title">- {{i18n "chat.create_channel.threading.label"}}- </span>- <p class="create-channel__label-description">- {{i18n "chat.settings.channel_threading_description"}}- </p>- </div>- </label>- </div>- {{/if}}-</DModalBody>--<div class="modal-footer">- <DButton- @class="btn-primary create"- @action={{action "create"}}- @label="chat.create_channel.create"- @disabled={{this.createDisabled}}- />-</div>\ No newline at end of filediff --git a/plugins/chat/assets/stylesheets/common/base-common.scss b/plugins/chat/assets/stylesheets/common/base-common.scssindex ee156bf2aaa..884ca7aac50 100644--- a/plugins/chat/assets/stylesheets/common/base-common.scss+++ b/plugins/chat/assets/stylesheets/common/base-common.scss@@ -16,19 +16,6 @@ html.ios-device.keyboard-visible body #main-outlet .full-page-chat {padding-bottom: 0.2rem;}-.chat-message-move-to-channel-modal-modal {- .modal-inner-container {- .chat-move-message-channel-chooser {- width: 100%;- .category-chat-badge {- .d-icon {- color: inherit;- }- }- }- }-}-.uppy-is-drag-over .chat-composer .drop-a-file {display: flex;position: absolute;@@ -315,38 +302,6 @@ body.has-full-page-chat {}}-.chat-channel-archive-modal-inner {- .chat-to-topic-selector {- width: 500px;- height: 300px;- }-- .radios {- margin-bottom: 10px;- display: flex;- flex-direction: row;-- .radio-label {- margin-right: 10px;- }- }-- details {- margin-bottom: 9px;- }-- input[type="text"],- .select-kit.combo-box.category-chooser {- width: 100%;- }-}--.chat-channel-archive-modal-inner {- .chat-to-topic-selector {- width: auto;- }-}-.user-preferences .chat-setting .controls {margin-bottom: 0;}diff --git a/plugins/chat/assets/stylesheets/common/chat-channel-info.scss b/plugins/chat/assets/stylesheets/common/chat-channel-info.scssindex b3f10acf39b..be5dee75b81 100644--- a/plugins/chat/assets/stylesheets/common/chat-channel-info.scss+++ b/plugins/chat/assets/stylesheets/common/chat-channel-info.scss@@ -139,25 +139,3 @@ input.channel-members-view__search-input {padding: 0.5rem 0;color: var(--primary-medium);}--// Channel info edit description modal-.chat-channel-edit-description-modal {- .exceeded-word-count {- .chat-channel-edit-description-modal__description-input {- outline: 1px solid var(--danger);- border: 1px solid var(--danger);- }- }-}--.chat-channel-edit-description-modal__description-input {- display: flex;- margin: 0;- min-height: 200px;-}--.chat-channel-edit-description-modal__description {- display: flex;- padding-bottom: 0.75rem;- color: var(--primary-medium);-}diff --git a/plugins/chat/assets/stylesheets/common/chat-modal-archive-channel.scss b/plugins/chat/assets/stylesheets/common/chat-modal-archive-channel.scssnew file mode 100644index 00000000000..aff98188d14--- /dev/null+++ b/plugins/chat/assets/stylesheets/common/chat-modal-archive-channel.scss@@ -0,0 +1,25 @@+.chat-modal-archive-channel {+ .chat-to-topic-selector {+ width: auto;+ height: 300px;+ }++ .radios {+ margin-bottom: 10px;+ display: flex;+ flex-direction: row;++ .radio-label {+ margin-right: 10px;+ }+ }++ details {+ margin-bottom: 9px;+ }++ input[type="text"],+ .select-kit.combo-box.category-chooser {+ width: 100%;+ }+}diff --git a/plugins/chat/assets/stylesheets/common/channel-summary-modal.scss b/plugins/chat/assets/stylesheets/common/chat-modal-channel-summary.scsssimilarity index 80%rename from plugins/chat/assets/stylesheets/common/channel-summary-modal.scssrename to plugins/chat/assets/stylesheets/common/chat-modal-channel-summary.scssindex b1ce698e8ec..3f795455cff 100644--- a/plugins/chat/assets/stylesheets/common/channel-summary-modal.scss+++ b/plugins/chat/assets/stylesheets/common/chat-modal-channel-summary.scss@@ -1,4 +1,4 @@-.channel-summary-modal {+.chat-modal-channel-summary {.summarization-since,.summary-area {margin: 10px 0 10px 0;diff --git a/plugins/chat/assets/stylesheets/common/create-channel-modal.scss b/plugins/chat/assets/stylesheets/common/chat-modal-create-channel.scsssimilarity index 83%rename from plugins/chat/assets/stylesheets/common/create-channel-modal.scssrename to plugins/chat/assets/stylesheets/common/chat-modal-create-channel.scssindex f7385374d6a..e1dfc3956f9 100644--- a/plugins/chat/assets/stylesheets/common/create-channel-modal.scss+++ b/plugins/chat/assets/stylesheets/common/chat-modal-create-channel.scss@@ -1,4 +1,4 @@-.create-channel-modal {+.chat-modal-create-channel {.modal-inner-container {width: 500px;}@@ -9,7 +9,7 @@}.select-kit.combo-box,- .create-channel__input,+ &__input,#choose-topic-title {width: 100%;margin-bottom: 0;@@ -22,18 +22,18 @@}}- .create-channel__hint {+ &__hint {font-size: var(--font-down-1);padding-top: 0.25rem;color: var(--secondary-low);}- .create-channel__control,+ &__control,.edit-channel-control {margin-bottom: 1rem;}- .create-channel__label-description {+ &__label-description {margin: 0;padding-top: 0.25rem;color: var(--secondary-low);diff --git a/plugins/chat/assets/stylesheets/common/chat-modal-edit-channel-description.scss b/plugins/chat/assets/stylesheets/common/chat-modal-edit-channel-description.scssnew file mode 100644index 00000000000..359f6e8144b--- /dev/null+++ b/plugins/chat/assets/stylesheets/common/chat-modal-edit-channel-description.scss@@ -0,0 +1,20 @@+.chat-modal-edit-channel-description {+ .exceeded-word-count {+ .chat-modal-edit-channel-description__description-input {+ outline: 1px solid var(--danger);+ border: 1px solid var(--danger);+ }+ }++ &__description-input {+ display: flex;+ margin: 0;+ min-height: 200px;+ }++ &__description {+ display: flex;+ padding-bottom: 0.75rem;+ color: var(--primary-medium);+ }+}diff --git a/plugins/chat/assets/stylesheets/common/chat-modal-move-message-to-channel.scss b/plugins/chat/assets/stylesheets/common/chat-modal-move-message-to-channel.scssnew file mode 100644index 00000000000..2f9abebc49e--- /dev/null+++ b/plugins/chat/assets/stylesheets/common/chat-modal-move-message-to-channel.scss@@ -0,0 +1,10 @@+.chat-modal-move-message-to-channel {+ &__channel-chooser {+ width: 100%;+ .category-chat-badge {+ .d-icon {+ color: inherit;+ }+ }+ }+}diff --git a/plugins/chat/assets/stylesheets/common/chat-new-message-modal.scss b/plugins/chat/assets/stylesheets/common/chat-modal-new-message.scsssimilarity index 95%rename from plugins/chat/assets/stylesheets/common/chat-new-message-modal.scssrename to plugins/chat/assets/stylesheets/common/chat-modal-new-message.scssindex 670766913e2..da33bf6813e 100644--- a/plugins/chat/assets/stylesheets/common/chat-new-message-modal.scss+++ b/plugins/chat/assets/stylesheets/common/chat-modal-new-message.scss@@ -1,4 +1,4 @@-.chat-new-message-modal {+.chat-modal-new-message {& + .modal-backdrop {opacity: 1;background: transparent;diff --git a/plugins/chat/assets/stylesheets/common/index.scss b/plugins/chat/assets/stylesheets/common/index.scssindex 499dc84e46f..39e9619177f 100644--- a/plugins/chat/assets/stylesheets/common/index.scss+++ b/plugins/chat/assets/stylesheets/common/index.scss@@ -41,7 +41,6 @@@import "chat-upload-drop-zone";@import "chat-transcript";@import "core-extensions";-@import "create-channel-modal";@import "dc-filter-input";@import "full-page-chat-header";@import "incoming-chat-webhooks";@@ -53,9 +52,14 @@@import "chat-thread-list-header";@import "chat-thread-unread-indicator";@import "chat-thread-participants";-@import "channel-summary-modal";@import "chat-message-mention-warning";@import "chat-message-error";-@import "chat-new-message-modal";@import "chat-message-creator";@import "chat-user-avatar";+@import "chat-modal-new-message";+@import "chat-modal-archive-channel";+@import "chat-modal-edit-channel-description";+@import "chat-modal-create-channel";+@import "chat-modal-create-channel";+@import "chat-modal-channel-summary";+@import "chat-modal-move-message-to-channel";diff --git a/plugins/chat/assets/stylesheets/mobile/chat-modal-thread-settings.scss b/plugins/chat/assets/stylesheets/mobile/chat-modal-thread-settings.scssnew file mode 100644index 00000000000..db511f4e7d0--- /dev/null+++ b/plugins/chat/assets/stylesheets/mobile/chat-modal-thread-settings.scss@@ -0,0 +1,9 @@+.modal-chat-thread-settings {+ .modal-inner-container {+ width: 98%;+ }++ &__title-input {+ width: 100%;+ }+}diff --git a/plugins/chat/assets/stylesheets/mobile/chat-thread-settings-modal.scss b/plugins/chat/assets/stylesheets/mobile/chat-thread-settings-modal.scssdeleted file mode 100644index b27bcfd979a..00000000000--- a/plugins/chat/assets/stylesheets/mobile/chat-thread-settings-modal.scss+++ /dev/null@@ -1,9 +0,0 @@-.chat-thread-settings-modal-modal {- .modal-inner-container {- width: 98%;-- .thread-title-input {- width: 100%;- }- }-}diff --git a/plugins/chat/assets/stylesheets/mobile/index.scss b/plugins/chat/assets/stylesheets/mobile/index.scssindex c4de1d951d3..f9fdace3e91 100644--- a/plugins/chat/assets/stylesheets/mobile/index.scss+++ b/plugins/chat/assets/stylesheets/mobile/index.scss@@ -11,6 +11,6 @@@import "chat-side-panel";@import "chat-thread";@import "chat-threads-list";-@import "chat-thread-settings-modal";+@import "chat-modal-thread-settings";@import "chat-message-thread-indicator";@import "chat-message-creator";diff --git a/plugins/chat/spec/system/channel_about_page_spec.rb b/plugins/chat/spec/system/channel_about_page_spec.rbindex 098b30a1310..550fa4c3ee4 100644--- a/plugins/chat/spec/system/channel_about_page_spec.rb+++ b/plugins/chat/spec/system/channel_about_page_spec.rb@@ -97,12 +97,12 @@ RSpec.describe "Channel - Info - About page", type: :system dofind(".edit-description-btn").clickexpect(page).to have_selector(- ".chat-channel-edit-description-modal__description-input",+ ".chat-modal-edit-channel-description__description-input",text: channel_1.description,)description = "A new description"- find(".chat-channel-edit-description-modal__description-input").fill_in(with: description)+ find(".chat-modal-edit-channel-description__description-input").fill_in(with: description)find(".create").clickexpect(page).to have_content(description)diff --git a/plugins/chat/spec/system/chat_summarization_spec.rb b/plugins/chat/spec/system/chat_summarization_spec.rbindex df504058e7d..57401b57559 100644--- a/plugins/chat/spec/system/chat_summarization_spec.rb+++ b/plugins/chat/spec/system/chat_summarization_spec.rb@@ -33,7 +33,7 @@ RSpec.describe "Summarize a channel since your last visit", type: :system, js: tfind(".chat-composer-dropdown__trigger-btn").clickfind(".chat-composer-dropdown__action-btn.channel-summary").click- expect(page.has_css?(".channel-summary-modal", wait: 5)).to eq(true)+ expect(page.has_css?(".chat-modal-channel-summary")).to eq(true)find(".summarization-since").clickfind(".select-kit-row[data-value=\"3\"]").clickdiff --git a/plugins/chat/spec/system/create_channel_spec.rb b/plugins/chat/spec/system/create_channel_spec.rbindex 45b9959b19a..2b6fe007def 100644--- a/plugins/chat/spec/system/create_channel_spec.rb+++ b/plugins/chat/spec/system/create_channel_spec.rb@@ -148,7 +148,7 @@ RSpec.describe "Create channel", type: :system docontext "for a public category" dobefore dochannel_modal.select_category(category_1)- find(".-auto-join .create-channel__label").click+ find(".-auto-join .chat-modal-create-channel__label").clickchannel_modal.click_primary_buttonend@@ -172,7 +172,7 @@ RSpec.describe "Create channel", type: :system doit "does nothing if no is clicked" dodialog.click_no- expect(page).to have_css(".create-channel-modal")+ expect(page).to have_css(".chat-modal-create-channel")expect(Chat::Channel.exists?(chatable_id: category_1.id)).to eq(false)endend@@ -185,7 +185,7 @@ RSpec.describe "Create channel", type: :system dobefore dogroup_1.add(user_1)channel_modal.select_category(private_category)- find(".-auto-join .create-channel__label").click+ find(".-auto-join .chat-modal-create-channel__label").clickchannel_modal.click_primary_buttonenddiff --git a/plugins/chat/spec/system/move_message_to_channel_spec.rb b/plugins/chat/spec/system/move_message_to_channel_spec.rbindex 7757b93fcca..c98121a6da4 100644--- a/plugins/chat/spec/system/move_message_to_channel_spec.rb+++ b/plugins/chat/spec/system/move_message_to_channel_spec.rb@@ -79,7 +79,7 @@ RSpec.describe "Move message to channel", type: :system dochat_page.visit_channel(channel_1)channel_page.messages.select(message_1)channel_page.selection_management.move- find(".chat-move-message-channel-chooser").click+ find(".chat-modal-move-message-to-channel__channel-chooser").clickfind("[data-value='#{channel_2.id}']").clickclick_button(I18n.t("js.chat.move_to_channel.confirm_move"))diff --git a/plugins/chat/spec/system/page_objects/chat/chat.rb b/plugins/chat/spec/system/page_objects/chat/chat.rbindex a79d717b4a7..c95069f2814 100644--- a/plugins/chat/spec/system/page_objects/chat/chat.rb+++ b/plugins/chat/spec/system/page_objects/chat/chat.rb@@ -27,7 +27,7 @@ module PageObjectsdef open_new_messagesend_keys([PLATFORM_KEY_MODIFIER, "k"])- find(".chat-new-message-modal")+ find(".chat-modal-new-message")enddef has_drawer?(channel_id: nil, expanded: true)diff --git a/plugins/chat/spec/system/page_objects/chat/chat_channel_about.rb b/plugins/chat/spec/system/page_objects/chat/chat_channel_about.rbindex 795893346a7..a28836bb59f 100644--- a/plugins/chat/spec/system/page_objects/chat/chat_channel_about.rb+++ b/plugins/chat/spec/system/page_objects/chat/chat_channel_about.rb@@ -3,7 +3,7 @@module PageObjectsmodule Pagesclass ChatChannelAbout < PageObjects::Pages::Base- EDIT_MODAL_SELECTOR = ".chat-channel-edit-name-slug-modal"+ EDIT_MODAL_SELECTOR = ".chat-modal-edit-channel-name"def open_edit_modalclick_button(class: "edit-name-slug-btn")diff --git a/plugins/chat/spec/system/page_objects/chat/components/message_creator.rb b/plugins/chat/spec/system/page_objects/chat/components/message_creator.rbindex 8a02518453e..896c3b27776 100644--- a/plugins/chat/spec/system/page_objects/chat/components/message_creator.rb+++ b/plugins/chat/spec/system/page_objects/chat/components/message_creator.rb@@ -6,7 +6,7 @@ module PageObjectsclass MessageCreator < PageObjects::Components::Baseattr_reader :context- SELECTOR = ".chat-new-message-modal"+ SELECTOR = ".chat-modal-new-message"def componentfind(SELECTOR)diff --git a/plugins/chat/spec/system/page_objects/modals/chat_channel_create.rb b/plugins/chat/spec/system/page_objects/modals/chat_channel_create.rbindex 9b68c680fdc..228760729cb 100644--- a/plugins/chat/spec/system/page_objects/modals/chat_channel_create.rb+++ b/plugins/chat/spec/system/page_objects/modals/chat_channel_create.rb@@ -9,11 +9,11 @@ module PageObjectsenddef create_channel_hint- find(".create-channel__hint")+ find(".chat-modal-create-channel__hint")enddef slug_input- find(".-slug .create-channel__input")+ find(".-slug .chat-modal-create-channel__input")enddef has_create_hint?(content)@@ -21,23 +21,23 @@ module PageObjectsenddef has_threading_toggle?- has_selector?(".create-channel__control.-threading-toggle")+ has_selector?(".chat-modal-create-channel__control.-threading-toggle")enddef fill_name(name)- fill_in("channel-name", with: name)+ fill_in("name", with: name)enddef fill_slug(slug)- fill_in("channel-slug", with: slug)+ fill_in("slug", with: slug)enddef fill_description(description)- fill_in("channel-description", with: description)+ fill_in("description", with: description)enddef has_name_prefilled?(name)- has_field?("channel-name", with: name)+ has_field?("name", with: name)endendenddiff --git a/plugins/chat/spec/system/thread_list/full_page_spec.rb b/plugins/chat/spec/system/thread_list/full_page_spec.rbindex 6851672cbc6..89cdf66a026 100644--- a/plugins/chat/spec/system/thread_list/full_page_spec.rb+++ b/plugins/chat/spec/system/thread_list/full_page_spec.rb@@ -150,7 +150,7 @@ describe "Thread list in side panel | full page", type: :system doopen_thread_listthread_list_page.item_by_id(thread_1.id).clickthread_page.header.open_settings- find(".thread-title-input").fill_in(with: new_title)+ find(".chat-modal-thread-settings__title-input").fill_in(with: new_title)find(".modal-footer .btn-primary").clickexpect(thread_page.header).to have_title_content(new_title)end@@ -161,7 +161,7 @@ describe "Thread list in side panel | full page", type: :system doopen_thread_listthread_list_page.item_by_id(thread_1.id).clickthread_page.header.open_settings- find(".thread-title-input").fill_in(with: new_title)+ find(".chat-modal-thread-settings__title-input").fill_in(with: new_title)find(".modal-footer .btn-primary").clickexpect(thread_page.header).to have_title_content(new_title)enddiff --git a/plugins/chat/test/javascripts/components/chat-channel-delete-modal-inner-test.js b/plugins/chat/test/javascripts/components/chat-modal-archive-channel-test.jssimilarity index 64%rename from plugins/chat/test/javascripts/components/chat-channel-delete-modal-inner-test.jsrename to plugins/chat/test/javascripts/components/chat-modal-archive-channel-test.jsindex 72a9d84d3be..847a5162b7e 100644--- a/plugins/chat/test/javascripts/components/chat-channel-delete-modal-inner-test.js+++ b/plugins/chat/test/javascripts/components/chat-modal-archive-channel-test.js@@ -6,24 +6,21 @@ import { render } from "@ember/test-helpers";import { module, test } from "qunit";module(- "Discourse Chat | Component | chat-channel-delete-modal-inner",+ "Discourse Chat | Component | <Chat::Modal::ArchiveChannel>",function (hooks) {setupRenderingTest(hooks);test("channel title is escaped in instructions correctly", async function (assert) {- this.set(- "channel",- fabricators.channel({- title: `<script>someeviltitle</script>`,- })- );+ this.channel = fabricators.channel({+ title: `<script>someeviltitle</script>`,+ });await render(- hbs`<ChatChannelDeleteModalInner @chatChannel={{this.channel}} />`+ hbs`<Chat::Modal::ArchiveChannel @inline={{true}} @model={{hash channel=this.channel}} />`);assert.true(- query(".chat-channel-delete-modal-instructions").innerHTML.includes(+ query(".chat-modal-archive-channel").innerHTML.includes("<script>someeviltitle</script>"));diff --git a/plugins/chat/test/javascripts/components/chat-channel-archive-modal-inner-test.js b/plugins/chat/test/javascripts/components/chat-modal-delete-channel-test.jssimilarity index 65%rename from plugins/chat/test/javascripts/components/chat-channel-archive-modal-inner-test.jsrename to plugins/chat/test/javascripts/components/chat-modal-delete-channel-test.jsindex 6995574c416..2d441aa2619 100644--- a/plugins/chat/test/javascripts/components/chat-channel-archive-modal-inner-test.js+++ b/plugins/chat/test/javascripts/components/chat-modal-delete-channel-test.js@@ -6,24 +6,21 @@ import { render } from "@ember/test-helpers";import { module, test } from "qunit";module(- "Discourse Chat | Component | chat-channel-archive-modal-inner",+ "Discourse Chat | Component | <Chat::Modal::DeleteChannel />",function (hooks) {setupRenderingTest(hooks);test("channel title is escaped in instructions correctly", async function (assert) {- this.set(- "channel",- fabricators.channel({- title: `<script>someeviltitle</script>`,- })- );+ this.channel = fabricators.channel({+ title: `<script>someeviltitle</script>`,+ });await render(- hbs`<ChatChannelArchiveModalInner @chatChannel={{this.channel}} />`+ hbs`<Chat::Modal::DeleteChannel @inline={{true}} @model={{hash channel=this.channel}} />`);assert.true(- query(".chat-channel-archive-modal-instructions").innerHTML.includes(+ query(".chat-modal-delete-channel__instructions").innerHTML.includes("<script>someeviltitle</script>"));diff --git a/plugins/chat/test/javascripts/components/chat-message-move-to-channel-modal-inner-test.js b/plugins/chat/test/javascripts/components/chat-modal-move-message-to-channel-test.jssimilarity index 54%rename from plugins/chat/test/javascripts/components/chat-message-move-to-channel-modal-inner-test.jsrename to plugins/chat/test/javascripts/components/chat-modal-move-message-to-channel-test.jsindex e40a49f7819..086e8756a79 100644--- a/plugins/chat/test/javascripts/components/chat-message-move-to-channel-modal-inner-test.js+++ b/plugins/chat/test/javascripts/components/chat-modal-move-message-to-channel-test.js@@ -6,28 +6,25 @@ import { render } from "@ember/test-helpers";import { module, test } from "qunit";module(- "Discourse Chat | Component | chat-message-move-to-channel-modal-inner",+ "Discourse Chat | Component | <Chat::Modal::MoveMessageToChannel />",function (hooks) {setupRenderingTest(hooks);test("channel title is escaped in instructions correctly", async function (assert) {- this.set(- "channel",- fabricators.channel({ title: "<script>someeviltitle</script>" })- );- this.set("chat", { publicChannels: [this.channel] });- this.set("selectedMessageIds", [1]);+ this.channel = fabricators.channel({+ title: "<script>someeviltitle</script>",+ });+ this.selectedMessageIds = [this.channel.id];await render(hbs`- <ChatMessageMoveToChannelModalInner- @selectedMessageIds={{this.selectedMessageIds}}- @sourceChannel={{this.channel}}- @chat={{this.chat}}+ <Chat::Modal::MoveMessageToChannel+ @inline={{true}}+ @model={{hash sourceChannel=this.channel selectedMessageIds=this.selectedMessageIds}}/>`);assert.true(- query(".chat-message-move-to-channel-modal-inner").innerHTML.includes(+ query(".chat-modal-move-message-to-channel").innerHTML.includes("<script>someeviltitle</script>"));diff --git a/plugins/styleguide/assets/javascripts/discourse/components/styleguide/controls/row.hbs b/plugins/styleguide/assets/javascripts/discourse/components/styleguide/controls/row.hbsindex 59f0c996c77..20f1b586a6d 100644--- a/plugins/styleguide/assets/javascripts/discourse/components/styleguide/controls/row.hbs+++ b/plugins/styleguide/assets/javascripts/discourse/components/styleguide/controls/row.hbs@@ -1,5 +1,7 @@<tr class="component-properties__row">- <td class="component-properties__cell">{{@name}}</td>+ {{#if @name}}+ <td class="component-properties__cell">{{@name}}</td>+ {{/if}}<td class="component-properties__cell">{{yield}}</td>