A platform for community discussion. Free, open, simple.
DEV: Migrate u/preferences/chat to formkit (#36583)
Jordan Vidrinef902c92b436b
diff --git a/app/assets/stylesheets/common/base/user.scss b/app/assets/stylesheets/common/base/user.scssindex 234d0d8f642..cb54fe304c4 100644--- a/app/assets/stylesheets/common/base/user.scss+++ b/app/assets/stylesheets/common/base/user.scss@@ -771,6 +771,12 @@}}+ #control-chat_quick_reactions_custom .form-kit__control-custom {+ display: flex;+ flex-direction: row;+ gap: var(--space-2);+ }+.category-selector,.tag-chooser,textarea,diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/header/icon/unread-indicator.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/header/icon/unread-indicator.gjsindex 196cb9b1728..fb3883eb7a3 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/header/icon/unread-indicator.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat/header/icon/unread-indicator.gjs@@ -5,7 +5,7 @@ import {HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS,HEADER_INDICATOR_PREFERENCE_NEVER,HEADER_INDICATOR_PREFERENCE_ONLY_MENTIONS,-} from "discourse/plugins/chat/discourse/controllers/preferences/chat";+} from "discourse/plugins/chat/discourse/lib/chat-constants";const MAX_UNREAD_COUNT = 99;diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-header-icon.gjs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-header-icon.gjsindex ce6dd4b929d..e7e7d355c50 100644--- a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-header-icon.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-header-icon.gjs@@ -11,7 +11,7 @@ import {HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS,HEADER_INDICATOR_PREFERENCE_NEVER,HEADER_INDICATOR_PREFERENCE_ONLY_MENTIONS,-} from "discourse/plugins/chat/discourse/controllers/preferences/chat";+} from "discourse/plugins/chat/discourse/lib/chat-constants";const StyleguideComponent = optionalRequire("discourse/plugins/styleguide/discourse/components/styleguide/component"diff --git a/plugins/chat/assets/javascripts/discourse/controllers/preferences/chat.js b/plugins/chat/assets/javascripts/discourse/controllers/preferences/chat.jsdeleted file mode 100644index 73200d1a0bb..00000000000--- a/plugins/chat/assets/javascripts/discourse/controllers/preferences/chat.js+++ /dev/null@@ -1,165 +0,0 @@-import Controller from "@ember/controller";-import { action } from "@ember/object";-import { service } from "@ember/service";-import { popupAjaxError } from "discourse/lib/ajax-error";-import discourseComputed from "discourse/lib/decorators";-import { isTesting } from "discourse/lib/environment";-import { translateModKey } from "discourse/lib/utilities";-import { PLATFORM_KEY_MODIFIER } from "discourse/services/keyboard-shortcuts";-import { i18n } from "discourse-i18n";-import { CHAT_SOUNDS } from "discourse/plugins/chat/discourse/services/chat-audio-manager";--const CHAT_ATTRS = [- "chat_enabled",- "only_chat_push_notifications",- "ignore_channel_wide_mention",- "show_thread_title_prompts",- "chat_sound",- "chat_email_frequency",- "chat_header_indicator_preference",- "chat_separate_sidebar_mode",- "chat_send_shortcut",- "chat_quick_reaction_type",- "chat_quick_reactions_custom",-];--export const CHAT_QUICK_REACTIONS_CUSTOM_DEFAULT = "heart|+1|smile";--export const HEADER_INDICATOR_PREFERENCE_NEVER = "never";-export const HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS = "dm_and_mentions";-export const HEADER_INDICATOR_PREFERENCE_ALL_NEW = "all_new";-export const HEADER_INDICATOR_PREFERENCE_ONLY_MENTIONS = "only_mentions";--export default class PreferencesChatController extends Controller {- @service chatAudioManager;- @service siteSettings;-- subpageTitle = i18n("chat.admin.title");-- chatQuickReactionTypes = [- {- label: i18n("chat.quick_reaction_type.options.frequent"),- value: "frequent",- },- {- label: i18n("chat.quick_reaction_type.options.custom"),- value: "custom",- },- ];-- chatSendShortcutOptions = [- {- label: i18n("chat.send_shortcut.enter.label"),- value: "enter",- description: i18n("chat.send_shortcut.enter.description"),- },- {- label: i18n("chat.send_shortcut.meta_enter.label", {- meta_key: translateModKey(PLATFORM_KEY_MODIFIER),- }),- value: "meta_enter",- description: i18n("chat.send_shortcut.meta_enter.description"),- },- ];-- headerIndicatorOptions = [- {- name: i18n("chat.header_indicator_preference.all_new"),- value: HEADER_INDICATOR_PREFERENCE_ALL_NEW,- },- {- name: i18n("chat.header_indicator_preference.dm_and_mentions"),- value: HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS,- },- {- name: i18n("chat.header_indicator_preference.only_mentions"),- value: HEADER_INDICATOR_PREFERENCE_ONLY_MENTIONS,- },- {- name: i18n("chat.header_indicator_preference.never"),- value: HEADER_INDICATOR_PREFERENCE_NEVER,- },- ];-- chatSeparateSidebarModeOptions = [- {- name: i18n("admin.site_settings.chat_separate_sidebar_mode.always"),- value: "always",- },- {- name: i18n("admin.site_settings.chat_separate_sidebar_mode.fullscreen"),- value: "fullscreen",- },- {- name: i18n("admin.site_settings.chat_separate_sidebar_mode.never"),- value: "never",- },- ];-- get chatSeparateSidebarMode() {- const mode = this.model.get("user_option.chat_separate_sidebar_mode");- if (mode === "default") {- return this.siteSettings.chat_separate_sidebar_mode;- } else {- return mode;- }- }-- get chatSendShortcut() {- return this.model.get("user_option.chat_send_shortcut");- }-- get chatQuickReactionsCustom() {- const emojis =- this.model.get("user_option.chat_quick_reactions_custom") ||- CHAT_QUICK_REACTIONS_CUSTOM_DEFAULT;- return emojis.split("|");- }-- @discourseComputed- chatSounds() {- return Object.keys(CHAT_SOUNDS).map((value) => {- return { name: i18n(`chat.sounds.${value}`), value };- });- }-- @action- onChangeChatSound(sound) {- if (sound) {- this.chatAudioManager.play(sound);- }- this.model.set("user_option.chat_sound", sound);- }-- @action- onChangeQuickReactionType(value) {- this.model.set("user_option.chat_quick_reaction_type", value);- if (value === "custom") {- this.model.set(- "user_option.chat_quick_reactions_custom",- this.chatQuickReactionsCustom.join("|")- );- }- }-- @action- didSelectEmoji(index, selected) {- let emoji = this.chatQuickReactionsCustom;- emoji[index] = selected;- this.model.set("user_option.chat_quick_reactions_custom", emoji.join("|"));- }-- @action- save() {- this.set("saved", false);- return this.model- .save(CHAT_ATTRS)- .then(() => {- this.set("saved", true);- if (!isTesting()) {- location.reload();- }- })- .catch(popupAjaxError);- }-}diff --git a/plugins/chat/assets/javascripts/discourse/lib/chat-constants.js b/plugins/chat/assets/javascripts/discourse/lib/chat-constants.jsindex 060b72235e8..43335b36376 100644--- a/plugins/chat/assets/javascripts/discourse/lib/chat-constants.js+++ b/plugins/chat/assets/javascripts/discourse/lib/chat-constants.js@@ -16,3 +16,30 @@ export const INDICATOR_PREFERENCES = {only_mentions: "only_mentions",never: "never",};+export const CHAT_ATTRS = [+ "chat_enabled",+ "only_chat_push_notifications",+ "ignore_channel_wide_mention",+ "show_thread_title_prompts",+ "chat_sound",+ "chat_email_frequency",+ "chat_header_indicator_preference",+ "chat_separate_sidebar_mode",+ "chat_send_shortcut",+ "chat_quick_reaction_type",+ "chat_quick_reactions_custom",+];++export const CHAT_QUICK_REACTIONS_CUSTOM_DEFAULT = "heart|+1|smile";++export const HEADER_INDICATOR_PREFERENCE_NEVER = "never";+export const HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS = "dm_and_mentions";+export const HEADER_INDICATOR_PREFERENCE_ALL_NEW = "all_new";+export const HEADER_INDICATOR_PREFERENCE_ONLY_MENTIONS = "only_mentions";+export const CHAT_SEND_SHORTCUT_ENTER = "enter";+export const CHAT_SEND_SHORTCUT_META_ENTER = "meta_enter";+export const CHAT_QUICK_REACTION_TYPE_FREQUENT = "frequent";+export const CHAT_QUICK_REACTION_TYPE_CUSTOM = "custom";+export const CHAT_SEPARATE_SIDEBAR_MODE_ALWAYS = "always";+export const CHAT_SEPARATE_SIDEBAR_MODE_FULLSCREEN = "fullscreen";+export const CHAT_SEPARATE_SIDEBAR_MODE_NEVER = "never";diff --git a/plugins/chat/assets/javascripts/discourse/lib/chat-user-preferences.js b/plugins/chat/assets/javascripts/discourse/lib/chat-user-preferences.jsindex 5d7a1bad7dc..622c1fced24 100644--- a/plugins/chat/assets/javascripts/discourse/lib/chat-user-preferences.js+++ b/plugins/chat/assets/javascripts/discourse/lib/chat-user-preferences.js@@ -3,7 +3,7 @@ import {HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS,HEADER_INDICATOR_PREFERENCE_NEVER,HEADER_INDICATOR_PREFERENCE_ONLY_MENTIONS,-} from "discourse/plugins/chat/discourse/controllers/preferences/chat";+} from "discourse/plugins/chat/discourse/lib/chat-constants";export function hasChatIndicator(user) {const pref = user.user_option.chat_header_indicator_preference;diff --git a/plugins/chat/assets/javascripts/discourse/templates/preferences/chat.gjs b/plugins/chat/assets/javascripts/discourse/templates/preferences/chat.gjsindex 625a27ad871..e12b5d91bf0 100644--- a/plugins/chat/assets/javascripts/discourse/templates/preferences/chat.gjs+++ b/plugins/chat/assets/javascripts/discourse/templates/preferences/chat.gjs@@ -1,195 +1,308 @@-import { Input } from "@ember/component";-import { array, concat, fn, get, hash } from "@ember/helper";-import { on } from "@ember/modifier";+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";+import { fn } from "@ember/helper";+import { action } from "@ember/object";+import { service } from "@ember/service";import EmojiPicker from "discourse/components/emoji-picker";-import SaveControls from "discourse/components/save-controls";-import withEventValue from "discourse/helpers/with-event-value";-import ComboBox from "discourse/select-kit/components/combo-box";+import Form from "discourse/components/form";+import { popupAjaxError } from "discourse/lib/ajax-error";+import { isTesting } from "discourse/lib/environment";+import { translateModKey } from "discourse/lib/utilities";+import { PLATFORM_KEY_MODIFIER } from "discourse/services/keyboard-shortcuts";import { eq } from "discourse/truth-helpers";import { i18n } from "discourse-i18n";+import {+ CHAT_ATTRS,+ CHAT_QUICK_REACTION_TYPE_CUSTOM,+ CHAT_QUICK_REACTION_TYPE_FREQUENT,+ CHAT_QUICK_REACTIONS_CUSTOM_DEFAULT,+ CHAT_SEND_SHORTCUT_ENTER,+ CHAT_SEND_SHORTCUT_META_ENTER,+ CHAT_SEPARATE_SIDEBAR_MODE_ALWAYS,+ CHAT_SEPARATE_SIDEBAR_MODE_FULLSCREEN,+ CHAT_SEPARATE_SIDEBAR_MODE_NEVER,+ HEADER_INDICATOR_PREFERENCE_ALL_NEW,+ HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS,+ HEADER_INDICATOR_PREFERENCE_NEVER,+ HEADER_INDICATOR_PREFERENCE_ONLY_MENTIONS,+} from "discourse/plugins/chat/discourse/lib/chat-constants";+import { CHAT_SOUNDS } from "discourse/plugins/chat/discourse/services/chat-audio-manager";-export default <template>- <label class="control-label">{{i18n "chat.title_capitalized"}}</label>-- <div class="control-group chat-setting" data-setting-name="user_chat_enabled">- <label class="controls">- <Input- id="user_chat_enabled"- @type="checkbox"- @checked={{@controller.model.user_option.chat_enabled}}- />- {{i18n "chat.enable"}}- </label>- </div>-- <fieldset- class="control-group chat-setting"- data-setting-name="user_chat_quick_reaction_type"- >- <legend class="control-label">{{i18n- "chat.quick_reaction_type.title"- }}</legend>- <div class="radio-group">- {{#each @controller.chatQuickReactionTypes as |option|}}- <div class="radio-group-option">- <label class="controls">- <input- type="radio"- name="user_chat_quick_reaction_type"- id={{concat "user_chat_quick_reaction_type_" option.value}}- value={{option.value}}- checked={{eq- @controller.model.user_option.chat_quick_reaction_type- option.value- }}- {{on- "change"- (withEventValue @controller.onChangeQuickReactionType)- }}- />- {{option.label}}- </label>- </div>- {{/each}}- </div>-- {{#if (eq @controller.model.user_option.chat_quick_reaction_type "custom")}}- <div class="controls tracking-controls emoji-pickers">- {{#each (array 0 1 2) as |index|}}- <EmojiPicker- @emoji={{get @controller.chatQuickReactionsCustom index}}- @didSelectEmoji={{fn @controller.didSelectEmoji index}}- @context="chat_preferences"- />- {{/each}}+export default class Chat extends Component {+ @service chatAudioManager;++ @tracked saved = false;++ get chatQuickReactionTypes() {+ return [+ {+ label: i18n("chat.quick_reaction_type.options.frequent"),+ value: CHAT_QUICK_REACTION_TYPE_FREQUENT,+ },+ {+ label: i18n("chat.quick_reaction_type.options.custom"),+ value: CHAT_QUICK_REACTION_TYPE_CUSTOM,+ },+ ];+ }++ get chatSendShortcutOptions() {+ return [+ {+ label: i18n("chat.send_shortcut.enter.label"),+ value: CHAT_SEND_SHORTCUT_ENTER,+ },+ {+ label: i18n("chat.send_shortcut.meta_enter.label", {+ meta_key: translateModKey(PLATFORM_KEY_MODIFIER),+ }),+ value: CHAT_SEND_SHORTCUT_META_ENTER,+ },+ ];+ }++ get headerIndicatorOptions() {+ return [+ {+ name: i18n("chat.header_indicator_preference.all_new"),+ value: HEADER_INDICATOR_PREFERENCE_ALL_NEW,+ },+ {+ name: i18n("chat.header_indicator_preference.dm_and_mentions"),+ value: HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS,+ },+ {+ name: i18n("chat.header_indicator_preference.only_mentions"),+ value: HEADER_INDICATOR_PREFERENCE_ONLY_MENTIONS,+ },+ {+ name: i18n("chat.header_indicator_preference.never"),+ value: HEADER_INDICATOR_PREFERENCE_NEVER,+ },+ ];+ }++ get chatSeparateSidebarModeOptions() {+ return [+ {+ name: i18n("admin.site_settings.chat_separate_sidebar_mode.always"),+ value: CHAT_SEPARATE_SIDEBAR_MODE_ALWAYS,+ },+ {+ name: i18n("admin.site_settings.chat_separate_sidebar_mode.fullscreen"),+ value: CHAT_SEPARATE_SIDEBAR_MODE_FULLSCREEN,+ },+ {+ name: i18n("admin.site_settings.chat_separate_sidebar_mode.never"),+ value: CHAT_SEPARATE_SIDEBAR_MODE_NEVER,+ },+ ];+ }++ get chatSounds() {+ return Object.keys(CHAT_SOUNDS).map((value) => {+ return { name: i18n(`chat.sounds.${value}`), value };+ });+ }++ get formData() {+ const userOption = this.args.model.user_option;+ const emojis = (+ userOption.chat_quick_reactions_custom ||+ CHAT_QUICK_REACTIONS_CUSTOM_DEFAULT+ ).split("|");++ return {+ chat_enabled: userOption.chat_enabled,+ chat_quick_reaction_type: userOption.chat_quick_reaction_type,+ chat_quick_reactions_custom: emojis,+ only_chat_push_notifications: userOption.only_chat_push_notifications,+ ignore_channel_wide_mention: userOption.ignore_channel_wide_mention,+ chat_sound: userOption.chat_sound,+ chat_header_indicator_preference:+ userOption.chat_header_indicator_preference,+ chat_separate_sidebar_mode: userOption.chat_separate_sidebar_mode,+ chat_send_shortcut: userOption.chat_send_shortcut,+ };+ }++ @action+ handleEmojiSet(index, field, selectedEmoji) {+ let newValue = [...field.value];+ newValue[index] = selectedEmoji;+ field.set(newValue);+ }++ @action+ handleChatSoundSet(sound, { set, name }) {+ if (sound) {+ this.chatAudioManager?.play(sound);+ }+ set(name, sound == null ? null : sound);+ }++ @action+ handleSubmit(data) {+ const { chat_quick_reactions_custom, ...userOptions } = data;+ const shouldReload =+ userOptions.chat_enabled !== this.args.model.user_option.chat_enabled;++ this.args.model.set(+ "user_option.chat_quick_reactions_custom",+ chat_quick_reactions_custom.join("|")+ );++ for (const [key, value] of Object.entries(userOptions)) {+ this.args.model.set(`user_option.${key}`, value);+ }+ return this.args.model+ .save(CHAT_ATTRS)+ .then(() => {+ if (shouldReload && !isTesting()) {+ location.reload();+ }+ })+ .catch(popupAjaxError)+ .finally(() => {+ this.saved = true;+ });+ }++ <template>+ <Form+ @data={{this.formData}}+ @onSubmit={{this.handleSubmit}}+ as |form data|+ >+ <form.Field+ @title={{i18n "chat.enable"}}+ @name="chat_enabled"+ @format="large"+ as |field|+ >+ <field.Checkbox @value={{field.value}} />+ </form.Field>++ <form.Section @title={{i18n "chat.chat_notifications_title"}}>+ <form.Field+ @title={{i18n "chat.only_chat_push_notifications.title"}}+ @name="only_chat_push_notifications"+ @format="large"+ as |field|+ >+ <field.Checkbox @value={{field.value}} />+ </form.Field>+ <form.Field+ @title={{i18n "chat.ignore_channel_wide_mention.title"}}+ @name="ignore_channel_wide_mention"+ @format="large"+ as |field|+ >+ <field.Checkbox @value={{field.value}} />+ </form.Field>++ <form.Field+ @title={{i18n "chat.sound.title"}}+ @name="chat_sound"+ @format="large"+ @onSet={{this.handleChatSoundSet}}+ as |field|+ >+ <field.Select @includeNone={{true}} as |select|>+ {{#each this.chatSounds as |sound|}}+ <select.Option @value={{sound.value}}>+ {{sound.name}}+ </select.Option>+ {{/each}}+ </field.Select>+ </form.Field>++ <form.Field+ @title={{i18n "chat.header_indicator_preference.title"}}+ @name="chat_header_indicator_preference"+ @format="large"+ as |field|+ >+ <field.Select @includeNone={{false}} as |select|>+ {{#each this.headerIndicatorOptions as |option|}}+ <select.Option @value={{option.value}}>+ {{option.name}}+ </select.Option>+ {{/each}}+ </field.Select>+ </form.Field>+ <form.Field+ @title={{i18n "chat.separate_sidebar_mode.title"}}+ @name="chat_separate_sidebar_mode"+ @format="large"+ as |field|+ >+ <field.Select @includeNone={{false}} as |select|>+ {{#each this.chatSeparateSidebarModeOptions as |option|}}+ <select.Option @value={{option.value}}>+ {{option.name}}+ </select.Option>+ {{/each}}+ </field.Select>+ </form.Field>+ </form.Section>+ <form.Section @title={{i18n "chat.personalization_title"}}>+ <form.Field+ @title={{i18n "chat.quick_reaction_type.title"}}+ @name="chat_quick_reaction_type"+ @format="large"+ as |field|+ >+ <field.RadioGroup as |radioGroup|>+ {{#each this.chatQuickReactionTypes as |option|}}+ <radioGroup.Radio @value={{option.value}}>+ {{option.label}}+ </radioGroup.Radio>+ {{/each}}+ </field.RadioGroup>+ </form.Field>++ {{#if (eq data.chat_quick_reaction_type "custom")}}+ <form.Field+ @title={{i18n "chat.quick_reaction_type.options.custom"}}+ @name="chat_quick_reactions_custom"+ @format="large"+ as |field|+ >+ <field.Custom>++ {{#each data.chat_quick_reactions_custom as |emoji index|}}+ <EmojiPicker+ @emoji={{emoji}}+ @btnClass="btn-default"+ @context="chat_preferences"+ @didSelectEmoji={{fn this.handleEmojiSet index field}}+ />+ {{/each}}+ </field.Custom>+ </form.Field>+ {{/if}}+ <form.Field+ @title={{i18n "chat.send_shortcut.title"}}+ @name="chat_send_shortcut"+ @format="large"+ as |field|+ >+ <field.RadioGroup as |radioGroup|>+ {{#each this.chatSendShortcutOptions as |option|}}+ <radioGroup.Radio @value={{option.value}}>+ {{option.label}}+ </radioGroup.Radio>+ {{/each}}+ </field.RadioGroup>+ </form.Field>+ </form.Section>+ <div class="save-controls">+ <form.Submit />+ {{#if this.saved}}+ <span class="saved">{{i18n "saved"}}</span>+ {{/if}}</div>- {{/if}}- </fieldset>-- <div- class="control-group chat-setting"- data-setting-name="user_chat_only_push_notifications"- >- <label class="controls">- <Input- id="user_chat_only_push_notifications"- @type="checkbox"- @checked={{@controller.model.user_option.only_chat_push_notifications}}- />- {{i18n "chat.only_chat_push_notifications.title"}}- </label>- <span class="control-instructions">- {{i18n "chat.only_chat_push_notifications.description"}}- </span>- </div>-- <div- class="control-group chat-setting"- data-setting-name="user_chat_ignore_channel_wide_mention"- >- <label class="controls">- <Input- id="user_chat_ignore_channel_wide_mention"- @type="checkbox"- @checked={{@controller.model.user_option.ignore_channel_wide_mention}}- />- {{i18n "chat.ignore_channel_wide_mention.title"}}- </label>- <span class="control-instructions">- {{i18n "chat.ignore_channel_wide_mention.description"}}- </span>- </div>-- <div- class="control-group chat-setting controls-dropdown"- data-setting-name="user_chat_sounds"- >- <label for="user_chat_sounds">{{i18n "chat.sound.title"}}</label>- <ComboBox- @options={{hash none="chat.sounds.none"}}- @valueProperty="value"- @content={{@controller.chatSounds}}- @value={{@controller.model.user_option.chat_sound}}- @id="user_chat_sounds"- @onChange={{@controller.onChangeChatSound}}- />- </div>-- <div- class="control-group chat-setting controls-dropdown"- data-setting-name="user_chat_header_indicator_preference"- >- <label for="user_chat_header_indicator_preference">- {{i18n "chat.header_indicator_preference.title"}}- </label>- <ComboBox- @valueProperty="value"- @content={{@controller.headerIndicatorOptions}}- @value={{@controller.model.user_option.chat_header_indicator_preference}}- @id="user_chat_header_indicator_preference"- @onChange={{fn- (mut @controller.model.user_option.chat_header_indicator_preference)- }}- />- </div>-- <div- class="control-group chat-setting controls-dropdown"- data-setting-name="user_chat_separate_sidebar_mode"- >- <label for="user_chat_separate_sidebar_mode">- {{i18n "chat.separate_sidebar_mode.title"}}- </label>-- <ComboBox- @valueProperty="value"- @content={{@controller.chatSeparateSidebarModeOptions}}- @value={{@controller.chatSeparateSidebarMode}}- @id="user_chat_separate_sidebar_mode"- @onChange={{fn- (mut @controller.model.user_option.chat_separate_sidebar_mode)- }}- />- </div>-- <div- class="control-group chat-setting controls-dropdown"- data-setting-name="user_chat_send_shortcut"- >- <div class="radio-group">- {{#each @controller.chatSendShortcutOptions as |option|}}- <div class="radio-group-option">- <label class="controls">- <input- type="radio"- name="chat_send_shortcut"- id={{concat "chat_send_shortcut_" option.value}}- value={{option.value}}- checked={{eq- @controller.model.user_option.chat_send_shortcut- option.value- }}- {{on- "change"- (withEventValue- (fn (mut @controller.model.user_option.chat_send_shortcut))- )- }}- />- {{option.label}}- </label>- <span class="control-instructions">- {{option.description}}- </span>- </div>- {{/each}}- </div>- </div>-- <SaveControls- @id="user_chat_preference_save"- @model={{@controller.model}}- @action={{@controller.save}}- @saved={{@controller.saved}}- />-</template>+ </Form>+ </template>+}diff --git a/plugins/chat/config/locales/client.en.yml b/plugins/chat/config/locales/client.en.ymlindex fff8b16cd9a..721331fe2f5 100644--- a/plugins/chat/config/locales/client.en.yml+++ b/plugins/chat/config/locales/client.en.yml@@ -142,12 +142,11 @@ en:separate_sidebar_mode:title: "Show separate sidebar modes for forum and chat"send_shortcut:+ title: "Send shortcut"enter:label: "Send by Enter"- description: "New line by Shift + Enter"meta_enter:label: "Send by %{meta_key} + Enter"- description: "New line by Enter"enable: "Enable chat"flag: "Flag"emoji: "Insert emoji"@@ -245,12 +244,12 @@ en:no_public_channels: "You have not joined any channels yet!"no_public_channels_cta: "Browse channels"kicked_from_channel: "You can no longer access this channel."+ chat_notifications_title: "Chat notifications"only_chat_push_notifications:title: "Only send chat push notifications"- description: "Block all non-chat push notifications from being sent"+ personalization_title: "Personalization"ignore_channel_wide_mention:title: "Ignore channel-wide mentions"- description: "Do not send notifications for channel-wide mentions (@here and @all)"show_thread_title_prompts:title: "Show thread title prompts"description: "Show prompts to set a title for new threads"diff --git a/plugins/chat/spec/system/user_chat_preferences_spec.rb b/plugins/chat/spec/system/user_chat_preferences_spec.rbindex 2adbda6d486..f40ce8184b0 100644--- a/plugins/chat/spec/system/user_chat_preferences_spec.rb+++ b/plugins/chat/spec/system/user_chat_preferences_spec.rb@@ -7,6 +7,7 @@ RSpec.describe "User chat preferences", type: :system dolet(:emoji_picker) { PageObjects::Components::EmojiPicker.new }let(:chat) { PageObjects::Pages::Chat.new }let(:channel) { PageObjects::Pages::ChatChannel.new }+ let(:form) { PageObjects::Components::FormKit.new(".form-kit") }before dochat_system_bootstrap@@ -34,17 +35,26 @@ RSpec.describe "User chat preferences", type: :system doit "can change chat quick reaction type to custom and select emoji" douser_preferences_chat_page.visit- choose("user_chat_quick_reaction_type", option: "custom")+ form.field("chat_quick_reaction_type").select("custom")- expect(user_preferences_chat_page.emoji_picker_triggers.count).to eq 3- expect(user_preferences_chat_page.reactions_selected.first).to eq "heart"+ custom_field = form.field("chat_quick_reactions_custom")+ expect(custom_field.component).to have_css(".emoji-picker-trigger", count: 3, wait: 5)- user_preferences_chat_page.reaction_buttons.first.click+ reaction_buttons = custom_field.component.all("button.emoji-picker-trigger")+ expect(reaction_buttons.first.find("img")[:title]).to eq "heart"++ reaction_buttons.first.clickemoji_picker.select_emoji(":sweat_smile:")- user_preferences_chat_page.save_changes_and_refresh+ form.submit+ user_preferences_chat_page.visit- expect(page).to have_checked_field("user_chat_quick_reaction_type_custom")- expect(user_preferences_chat_page.reactions_selected.first).to eq "sweat_smile"+ expect(+ form.field("chat_quick_reaction_type").component.find("input[type='radio'][value='custom']"),+ ).to be_checked++ custom_field = form.field("chat_quick_reactions_custom")+ reaction_buttons = custom_field.component.all("button.emoji-picker-trigger")+ expect(reaction_buttons.first.find("img")[:title]).to eq "sweat_smile"enddescribe "chat interface" do@@ -56,8 +66,9 @@ RSpec.describe "User chat preferences", type: :system do# save custom and look for reactionuser_preferences_chat_page.visit- choose("user_chat_quick_reaction_type", option: "custom")- user_preferences_chat_page.save_changes_and_refresh+ form.field("chat_quick_reaction_type").select("custom")+ form.submit+ user_preferences_chat_page.visitchat.visit_channel(category_channel_1)channel.hover_message(message_1)@@ -65,8 +76,9 @@ RSpec.describe "User chat preferences", type: :system do# save frequent and look for reactionuser_preferences_chat_page.visit- find("#user_chat_quick_reaction_type_frequent").click- user_preferences_chat_page.save_changes_and_refresh+ form.field("chat_quick_reaction_type").select("frequent")+ form.submit+ user_preferences_chat_page.visitchat.visit_channel(category_channel_1)channel.hover_message(message_1)@@ -77,40 +89,44 @@ RSpec.describe "User chat preferences", type: :system doshared_examples "select and save" doit "can select and save" douser_preferences_chat_page.visit- user_preferences_chat_page.select_option_value(sel, val)- user_preferences_chat_page.save_changes_and_refresh+ form.field(field_name).select(val)+ form.submit+ user_preferences_chat_page.visit- expect(user_preferences_chat_page.selected_option_value(sel)).to eq val+ expect(form.field(field_name).value).to eq valendenddescribe "chat sound" doinclude_examples "select and save" do- let(:sel) { "#user_chat_sounds" }+ let(:field_name) { "chat_sound" }let(:val) { "bell" }endenddescribe "header_indicator_preference" doinclude_examples "select and save" do- let(:sel) { "#user_chat_header_indicator_preference" }+ let(:field_name) { "chat_header_indicator_preference" }let(:val) { "dm_and_mentions" }endenddescribe "separate sidebar mode" doinclude_examples "select and save" do- let(:sel) { "#user_chat_separate_sidebar_mode" }+ let(:field_name) { "chat_separate_sidebar_mode" }let(:val) { "fullscreen" }endendit "can select send shorcut sidebar mode" douser_preferences_chat_page.visit- find("#chat_send_shortcut_meta_enter").click- user_preferences_chat_page.save_changes_and_refresh+ form.field("chat_send_shortcut").select("meta_enter")+ form.submit+ user_preferences_chat_page.visit- expect(page).to have_checked_field("chat_send_shortcut_meta_enter")+ expect(+ form.field("chat_send_shortcut").component.find("input[type='radio'][value='meta_enter']"),+ ).to be_checkedendcontext "as an admin on another user's preferences" dodiff --git a/plugins/chat/test/javascripts/components/chat-header-icon-test.gjs b/plugins/chat/test/javascripts/components/chat-header-icon-test.gjsindex 747749770c7..671c1f86115 100644--- a/plugins/chat/test/javascripts/components/chat-header-icon-test.gjs+++ b/plugins/chat/test/javascripts/components/chat-header-icon-test.gjs@@ -6,7 +6,7 @@ import { forceMobile } from "discourse/lib/mobile";import { setupRenderingTest } from "discourse/tests/helpers/component-test";import { i18n } from "discourse-i18n";import Icon from "discourse/plugins/chat/discourse/components/chat/header/icon";-import { HEADER_INDICATOR_PREFERENCE_ALL_NEW } from "discourse/plugins/chat/discourse/controllers/preferences/chat";+import { HEADER_INDICATOR_PREFERENCE_ALL_NEW } from "discourse/plugins/chat/discourse/lib/chat-constants";module("Discourse Chat | Component | chat-header-icon", function (hooks) {setupRenderingTest(hooks);