A platform for community discussion. Free, open, simple.
UX: update chat form to formkit, clean up chat modal styles (#40845)
Kris2655f4673dbb
diff --git a/app/assets/stylesheets/common/base/uc-modernize-foundation-theme/buttons-controls.scss b/app/assets/stylesheets/common/base/uc-modernize-foundation-theme/buttons-controls.scssindex 061b7b45e01..2e5846a73cc 100644--- a/app/assets/stylesheets/common/base/uc-modernize-foundation-theme/buttons-controls.scss+++ b/app/assets/stylesheets/common/base/uc-modernize-foundation-theme/buttons-controls.scss@@ -39,6 +39,7 @@.topic-list-header-tab,.reviewable-action-dropdown,.sidebar-section-header,+ .chat-message-creator__member,.tag-choice) {padding-block: 0;diff --git a/app/assets/stylesheets/common/components/emoji-picker.scss b/app/assets/stylesheets/common/components/emoji-picker.scssindex 4d3e9871f7a..185cb4ac7de 100644--- a/app/assets/stylesheets/common/components/emoji-picker.scss+++ b/app/assets/stylesheets/common/components/emoji-picker.scss@@ -15,7 +15,7 @@}.emoji-picker-trigger {- gap: var(--space-2);+ gap: var(--space-1);.d-icon + .d-button-label {margin-left: 0.25em;diff --git a/app/assets/stylesheets/common/modal/modal-overrides.scss b/app/assets/stylesheets/common/modal/modal-overrides.scssindex 7bcfdfa9634..1e95279a468 100644--- a/app/assets/stylesheets/common/modal/modal-overrides.scss+++ b/app/assets/stylesheets/common/modal/modal-overrides.scss@@ -311,7 +311,7 @@&__members {min-height: unset;- padding: 0.25rem 0.5rem;+ padding: 0 0.5rem;}&__add-members__close-btn {diff --git a/frontend/discourse/app/form-kit/components/fk/control/emoji.gjs b/frontend/discourse/app/form-kit/components/fk/control/emoji.gjsindex d2e98b5369c..2fd4ed4ee4a 100644--- a/frontend/discourse/app/form-kit/components/fk/control/emoji.gjs+++ b/frontend/discourse/app/form-kit/components/fk/control/emoji.gjs@@ -16,10 +16,8 @@ export default class FKControlEmoji extends FKBaseControl {@context={{@context}}@didSelectEmoji={{this.updateField}}@modalForMobile={{false}}- @btnClass="btn-emoji"- @icon={{null}}+ @btnClass="btn-emoji btn-default"@showCaret={{true}}- @showSelectedName={{true}}/></template>}diff --git a/plugins/chat/app/services/chat/create_category_channel.rb b/plugins/chat/app/services/chat/create_category_channel.rbindex 0df045197e7..ac4c6a5308c 100644--- a/plugins/chat/app/services/chat/create_category_channel.rb+++ b/plugins/chat/app/services/chat/create_category_channel.rb@@ -45,6 +45,7 @@ module Chatbefore_validation doself.auto_join_users = auto_join_users.presence || falseself.threading_enabled = threading_enabled.presence || false+ self.emoji = emoji.presenceendvalidates :category_id, presence: truediff --git a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/list-action.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/list-action.gjsindex 6dcd093b997..a080afd786a 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/list-action.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/list-action.gjs@@ -1,11 +1,14 @@-import DButton from "discourse/ui-kit/d-button";+import dIcon from "discourse/ui-kit/helpers/d-icon";const ListAction = <template>- <DButton- class="btn btn-flat"- @icon={{@item.icon}}- @translatedLabel={{@item.label}}- />+ <div class="chat-message-creator__chatable -group">+ <div class="chat-message-creator__group-icon">+ {{dIcon @item.icon}}+ </div>+ <div class="chat-message-creator__group-name">+ {{@item.label}}+ </div>+ </div></template>;export default ListAction;diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/member.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/member.gjsindex 0b67bcf708c..2bfca5bdbf7 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/member.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/member.gjs@@ -8,7 +8,7 @@ import ChatUserAvatar from "discourse/plugins/chat/discourse/components/chat-useconst Member = <template><DButtonclass={{dConcatClass- "chat-message-creator__member btn-default"+ "chat-message-creator__member btn-default btn-small"(if @highlighted "-highlighted")}}@action={{fn @onSelect @member}}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/search.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/search.gjsindex c623b8c5ea4..3bca4cc8fd0 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/search.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/search.gjs@@ -33,7 +33,7 @@ export default class ChatMessageCreatorSearch extends Component {type: "list-action",label: i18n("chat.new_message_modal.new_group_chat"),enabled: true,- icon: "users",+ icon: "user-group",id: "new-group-chat",});}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.gjsindex 6936efb6f5b..0e4e2a87c49 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.gjs@@ -1,16 +1,11 @@import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";-import { Input } from "@ember/component";-import { hash } from "@ember/helper";-import { on } from "@ember/modifier";+import { fn, hash } from "@ember/helper";import { action } from "@ember/object";import { cancel } from "@ember/runloop";import { service } from "@ember/service";import { trustHTML } from "@ember/template";-import { isBlank, isPresent } from "@ember/utils";-import EmojiPicker from "discourse/components/emoji-picker";-import DTooltip from "discourse/float-kit/components/d-tooltip";-import withEventValue from "discourse/helpers/with-event-value";+import Form from "discourse/components/form";import { ajax } from "discourse/lib/ajax";import { extractError } from "discourse/lib/ajax-error";import discourseDebounce from "discourse/lib/debounce";@@ -21,7 +16,6 @@ import { not } from "discourse/truth-helpers";import DButton from "discourse/ui-kit/d-button";import DModal from "discourse/ui-kit/d-modal";import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";-import dIcon from "discourse/ui-kit/helpers/d-icon";import I18n, { i18n } from "discourse-i18n";const DEFAULT_HINT = trustHTML(@@ -39,15 +33,22 @@ export default class ChatModalCreateChannel extends Component {@service siteSettings;@tracked flash;- @tracked name;@tracked category;- @tracked categoryId;@tracked autoGeneratedSlug = "";- @tracked categoryPermissionsHint;+ @tracked categoryPermissionsHint = DEFAULT_HINT;@tracked autoJoinWarning = "";@tracked loadingPermissionHint = false;- @tracked editedEmoji = null;+ formApi;+ formData = {+ name: "",+ slug: "",+ description: "",+ chatable_id: null,+ emoji: null,+ auto_join_users: false,+ threading_enabled: false,+ };#generateSlugHandler = null;willDestroy() {@@ -59,72 +60,57 @@ export default class ChatModalCreateChannel extends Component {return this.siteSettings.max_chat_auto_joined_users > 0;}- get categorySelected() {- return isPresent(this.category);- }-- get createDisabled() {- return !this.categorySelected || isBlank(this.name);+ get categoryName() {+ return this.category ? escapeExpression(this.category.name) : null;}- get categoryName() {- return this.categorySelected ? escapeExpression(this.category?.name) : null;+ @action+ registerApi(api) {+ this.formApi = api;}@action- onShow() {- this.categoryPermissionsHint = DEFAULT_HINT;+ submit() {+ this.formApi.submit();}@action- onCategoryChange(categoryId) {+ onCategoryChange(categoryId, { set }) {const category = categoryId ? Category.findById(categoryId) : null;+ set("chatable_id", categoryId);+ this.category = category;this.#updatePermissionsHint(category);- const name = this.name || category?.name || "";- this.categoryId = categoryId;- this.category = category;- this.name = name;+ const name = this.formApi.get("name") || category?.name || "";+ set("name", name);this.#debouncedGenerateSlug(name);}@action- onNameChange(name) {+ onNameChange(name, { set }) {+ set("name", name);this.#debouncedGenerateSlug(name);}@action- emojiSelected(emoji) {- this.editedEmoji = emoji;- }-- @action- resetEmoji() {- this.editedEmoji = null;- }-- @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";- data.emoji = this.editedEmoji;-- if (data.auto_join_users) {+ onSubmit(data) {+ const payload = {+ name: data.name,+ slug: data.slug || this.autoGeneratedSlug,+ description: data.description,+ chatable_id: data.chatable_id,+ auto_join_users: data.auto_join_users,+ threading_enabled: data.threading_enabled,+ emoji: data.emoji,+ };++ if (payload.auto_join_users) {this.dialog.yesNoConfirm({message: this.autoJoinWarning,- didConfirm: () => this.#createChannel(data),+ didConfirm: () => this.#createChannel(payload),});} else {- this.#createChannel(data);+ this.#createChannel(payload);}}@@ -282,154 +268,137 @@ export default class ChatModalCreateChannel extends Component {@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" (withEventValue this.onNameChange)}}- />- </div>-- <div class="chat-modal-create-channel__control -slug">- <label for="slug" class="chat-modal-create-channel__label">- {{i18n "chat.create_channel.slug"}} - <span>- {{dIcon "circle-info"}}- <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={{this.onCategoryChange}}- @options={{hash- formName="chatable_id"- none="chat.create_channel.choose_category.none"+ <Form+ @data={{this.formData}}+ @onSubmit={{this.onSubmit}}+ @onRegisterApi={{this.registerApi}}+ class="chat-modal-create-channel__form"+ as |form|+ >+ <form.Field+ @name="name"+ @title={{i18n "chat.create_channel.name"}}+ @type="input"+ @validation="required"+ @format="full"+ @onSet={{this.onNameChange}}+ as |field|+ >+ <field.Control />+ </form.Field>++ <form.Field+ @name="slug"+ @title={{i18n "chat.create_channel.slug"}}+ @type="input"+ @format="full"+ @tooltip={{i18n+ "chat.channel_edit_name_slug_modal.slug_description"}}- />-- {{#if this.categoryPermissionsHint}}- <div- class={{dConcatClass- "chat-modal-create-channel__hint"- (if this.loadingPermissionHint "loading-permissions")- }}- >- {{this.categoryPermissionsHint}}- </div>- {{/if}}- </div>-- <div class="chat-modal-create-channel__control -emoji">- <label for="emoji" class="chat-modal-create-channel__label">- {{i18n "chat.create_channel.emoji.label"}}- </label>-- <EmojiPicker- @emoji={{this.editedEmoji}}- @didSelectEmoji={{this.emojiSelected}}- @btnClass="btn-emoji"- @modalForMobile={{false}}- @context="channel-emoji"- @inline={{true}}- />-- <DButton- @label="chat.create_channel.emoji.reset"- @action={{this.resetEmoji}}- @disabled={{not this.editedEmoji}}- class="btn-flat edit-channel-clear-emoji"- />- </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}}+ as |field|+ >+ <field.Control placeholder={{this.autoGeneratedSlug}} />+ </form.Field>++ <form.Field+ @name="description"+ @title={{i18n "chat.create_channel.description"}}+ @type="input"+ @format="full"+ as |field|+ >+ <field.Control />+ </form.Field>++ <form.Field+ @name="chatable_id"+ @title={{i18n "chat.create_channel.choose_category.label"}}+ @type="custom"+ @validation="required"+ @format="full"+ @onSet={{this.onCategoryChange}}+ as |field|+ >+ <field.Control>+ <CategoryChooser+ @value={{field.value}}+ @onChange={{field.set}}+ @options={{hash+ none="chat.create_channel.choose_category.none"+ }}/>- <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}}-- <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}}++ {{#if this.categoryPermissionsHint}}+ <div+ class={{dConcatClass+ "chat-modal-create-channel__hint"+ (if this.loadingPermissionHint "loading-permissions")+ }}+ >+ {{this.categoryPermissionsHint}}+ </div>+ {{/if}}+ </field.Control>+ </form.Field>++ <form.Field+ @name="emoji"+ @title={{i18n "chat.create_channel.emoji.label"}}+ @type="emoji"+ as |field|+ >+ <field.Control @context="channel-emoji" />++ <DButton+ @label="chat.create_channel.emoji.reset"+ @action={{fn field.set null}}+ @disabled={{not field.value}}+ class="btn-flat edit-channel-clear-emoji"/>- <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>+ </form.Field>++ {{#if this.autoJoinAvailable}}+ <form.Field+ @name="auto_join_users"+ @title={{i18n "chat.settings.auto_join_users_label"}}+ @type="checkbox"+ @format="full"+ as |field|+ >+ <field.Control>+ {{#if this.categoryName}}+ {{i18n+ "chat.settings.auto_join_users_info"+ category=this.categoryName+ }}+ {{else}}+ {{i18n "chat.settings.auto_join_users_info_no_category"}}+ {{/if}}+ </field.Control>+ </form.Field>+ {{/if}}++ <form.Field+ @name="threading_enabled"+ @title={{i18n "chat.create_channel.threading.label"}}+ @type="checkbox"+ @format="full"+ as |field|+ >+ <field.Control>+ {{i18n "chat.settings.channel_threading_description"}}+ </field.Control>+ </form.Field>+ </Form></:body><:footer>- <button- class="btn btn-primary create"- disabled={{this.createDisabled}}- type="submit"- >- {{i18n "chat.create_channel.create"}}- </button>+ <DButton+ @action={{this.submit}}+ @label="chat.create_channel.create"+ class="btn-primary create"+ /></:footer></DModal></template>diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.gjsindex f47a9eb8bac..3cf03373a24 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.gjs@@ -169,10 +169,11 @@ export default class ChatModalEditChannelName extends Component {<EmojiPicker@emoji={{this.editedEmoji}}@didSelectEmoji={{this.emojiSelected}}- @btnClass="btn-emoji"+ @btnClass="btn-default btn-emoji"@modalForMobile={{false}}@context="channel-emoji"@inline={{true}}+ @showCaret={{true}}/><DButtondiff --git a/plugins/chat/assets/javascripts/discourse/connectors/chat-composer-inline-buttons/emoji-picker.gjs b/plugins/chat/assets/javascripts/discourse/connectors/chat-composer-inline-buttons/emoji-picker.gjsindex 73eb4ead349..b87cf06677b 100644--- a/plugins/chat/assets/javascripts/discourse/connectors/chat-composer-inline-buttons/emoji-picker.gjs+++ b/plugins/chat/assets/javascripts/discourse/connectors/chat-composer-inline-buttons/emoji-picker.gjs@@ -10,7 +10,7 @@ export default class ChatEmojiPicker extends Component {{{#if this.site.desktopView}}<EmojiPicker@didSelectEmoji={{@outletArgs.composer.onSelectEmoji}}- @btnClass="chat-composer-button btn-transparent -emoji"+ @btnClass="chat-composer-button btn-transparent --emoji"@context="chat"/>diff --git a/plugins/chat/assets/stylesheets/common/chat-composer-button.scss b/plugins/chat/assets/stylesheets/common/chat-composer-button.scssindex 4db22359c36..b568075f31f 100644--- a/plugins/chat/assets/stylesheets/common/chat-composer-button.scss+++ b/plugins/chat/assets/stylesheets/common/chat-composer-button.scss@@ -82,7 +82,7 @@}}- &.-emoji {+ &.--emoji {transition: transform 0.1s ease-in-out;&:hover {diff --git a/plugins/chat/assets/stylesheets/common/chat-message-creator.scss b/plugins/chat/assets/stylesheets/common/chat-message-creator.scssindex 7e5a63581a7..639cd98c94c 100644--- a/plugins/chat/assets/stylesheets/common/chat-message-creator.scss+++ b/plugins/chat/assets/stylesheets/common/chat-message-creator.scss@@ -52,29 +52,11 @@&__member {padding: 0 0.25rem;- border-radius: var(--border-radius);- background: var(--primary-very-low);- gap: 0.25rem;+ gap: var(--space-1);@media (prefers-reduced-motion: no-preference) {animation: popIn 0.1s ease-out;}-- &:hover {- .discourse-no-touch & {- background: var(--primary-very-low);- color: var(--primary);- border-color: var(--tertiary);-- .d-icon-xmark {- color: var(--primary);- }- }- }-- .d-icon-xmark {- margin-left: 0.25rem;- }}&__add-members__close-btn {@@ -85,7 +67,6 @@&__add-members-header {display: flex;flex-grow: 1;- gap: 0.5rem;&-container {display: flex;@@ -138,13 +119,16 @@display: flex;align-items: center;flex-grow: 1;- padding: 0.5rem;- background: var(--primary-low);+ padding: 0 0.5rem;flex-wrap: wrap;gap: 0.5rem;- border-radius: var(--border-radius);- min-height: 50px;+ border: var(--d-input-border);box-sizing: border-box;+ border-radius: var(--d-input-border-radius);++ &:focus-within {+ @include default-focus;+ }.d-icon-magnifying-glass {color: var(--primary-high);@@ -290,8 +274,9 @@border: 1px solid var(--primary-400);width: 100%;box-sizing: border-box;- height: 42px;+ height: var(--d-control-height);padding: 0 0.5rem;+ border-radius: var(--d-input-border-radius);&:focus,&:focus-within {diff --git a/plugins/chat/assets/stylesheets/common/chat-modal-create-channel.scss b/plugins/chat/assets/stylesheets/common/chat-modal-create-channel.scssindex ed36faf30b5..d9831ad171c 100644--- a/plugins/chat/assets/stylesheets/common/chat-modal-create-channel.scss+++ b/plugins/chat/assets/stylesheets/common/chat-modal-create-channel.scss@@ -1,12 +1,6 @@.chat-modal-create-channel {- .choose-topic-results-list {- max-height: 200px;- overflow-y: scroll;- }-.select-kit.combo-box,- &__input,- #choose-topic-title {+ .category-chooser {width: 100%;margin-bottom: 0;}@@ -25,15 +19,9 @@color: var(--secondary-low);}- &__control,- .edit-channel-control {- margin-bottom: 1rem;- }-- &__label-description {- margin: 0;- padding-top: 0.25rem;- color: var(--secondary-low);- font-size: var(--font-down-1) !important;+ .form-kit__field-emoji .form-kit__container-content {+ flex-direction: row;+ align-items: center;+ gap: 0.5rem;}}diff --git a/plugins/chat/assets/stylesheets/common/chat-modal-edit-channel-name.scss b/plugins/chat/assets/stylesheets/common/chat-modal-edit-channel-name.scssdeleted file mode 100644index bba05753352..00000000000--- a/plugins/chat/assets/stylesheets/common/chat-modal-edit-channel-name.scss+++ /dev/null@@ -1,5 +0,0 @@-.chat-modal-edit-channel-name {- .edit-channel-clear-emoji {- vertical-align: top;- }-}diff --git a/plugins/chat/assets/stylesheets/common/chat-navbar.scss b/plugins/chat/assets/stylesheets/common/chat-navbar.scssindex 3f7339e1b16..6842dedf6b2 100644--- a/plugins/chat/assets/stylesheets/common/chat-navbar.scss+++ b/plugins/chat/assets/stylesheets/common/chat-navbar.scss@@ -138,10 +138,6 @@align-items: center;height: var(--chat-header-offset);- .d-icon {- color: var(--primary-low-mid);- }-.c-navbar__filter {&.active {.d-icon {diff --git a/plugins/chat/assets/stylesheets/common/index.scss b/plugins/chat/assets/stylesheets/common/index.scssindex d3ada729e03..6650c659d44 100644--- a/plugins/chat/assets/stylesheets/common/index.scss+++ b/plugins/chat/assets/stylesheets/common/index.scss@@ -55,7 +55,6 @@@import "chat-user-avatar";@import "chat-modal-new-message";@import "chat-modal-archive-channel";-@import "chat-modal-edit-channel-name";@import "chat-modal-edit-channel-description";@import "chat-modal-create-channel";@import "chat-modal-channel-summary";diff --git a/plugins/chat/config/locales/client.en.yml b/plugins/chat/config/locales/client.en.ymlindex 6150af1eb03..afa745fa51d 100644--- a/plugins/chat/config/locales/client.en.yml+++ b/plugins/chat/config/locales/client.en.yml@@ -411,8 +411,8 @@ en:input_placeholder: Add a nameslug_description: A channel slug is used in the URL instead of the channel namename: Channel name- slug: Channel slug (optional)- emoji: Channel emoji (optional)+ slug: Channel slug+ emoji: Channel emojireset_emoji: Reset emojichannel_edit_description_modal:@@ -474,16 +474,16 @@ en:one: 'Users in %{group} and %{count} other group will have access to this channel per the <a href="%{settingLink}" target="_blank">security settings</a>'other: 'Users in %{group} and %{count} other groups will have access to this channel per the <a href="%{settingLink}" target="_blank">security settings</a>'create: "Create channel"- description: "Description (optional)"+ description: "Description"name: "Channel name"- slug: "Channel slug (optional)"+ slug: "Channel slug"title: "New channel"type: "Type"types:category: "Category"topic: "Topic"emoji:- label: "Channel emoji (optional)"+ label: "Channel emoji"reset: "Reset emoji"reviewable:diff --git a/plugins/chat/spec/system/create_channel_spec.rb b/plugins/chat/spec/system/create_channel_spec.rbindex c8ed37abcd8..275c3b2347e 100644--- a/plugins/chat/spec/system/create_channel_spec.rb+++ b/plugins/chat/spec/system/create_channel_spec.rb@@ -146,7 +146,7 @@ RSpec.describe "Create channel" docontext "for a public category" dobefore dochannel_modal.select_category(category_1)- find(".-auto-join .chat-modal-create-channel__label").click+ channel_modal.toggle_auto_joinchannel_modal.click_primary_buttonend@@ -183,7 +183,7 @@ RSpec.describe "Create channel" dobefore dogroup_1.add(user_1)channel_modal.select_category(private_category)- find(".-auto-join .chat-modal-create-channel__label").click+ channel_modal.toggle_auto_joinchannel_modal.click_primary_buttonend@@ -288,6 +288,35 @@ RSpec.describe "Create channel" dochat.channel_path(created_channel.slug, created_channel.id),)end++ it "persists the selected emoji" do+ chat_page.visit_browse+ chat_page.new_channel_button.click+ channel_modal.select_category(category_1)+ channel_modal.fill_name("Cats & Dogs")+ channel_modal.select_emoji("cat")+ channel_modal.click_primary_button++ expect(channel_modal).to be_closed++ created_channel = Chat::Channel.find_by(chatable_id: category_1.id)+ expect(created_channel.emoji).to eq("cat")+ end++ it "clears the emoji when reset before saving" do+ chat_page.visit_browse+ chat_page.new_channel_button.click+ channel_modal.select_category(category_1)+ channel_modal.fill_name("Cats & Dogs")+ channel_modal.select_emoji("cat")+ channel_modal.reset_emoji+ channel_modal.click_primary_button++ expect(channel_modal).to be_closed++ created_channel = Chat::Channel.find_by(chatable_id: category_1.id)+ expect(created_channel.emoji).to be_nil+ endendendenddiff --git a/plugins/chat/spec/system/page_objects/chat/components/composer.rb b/plugins/chat/spec/system/page_objects/chat/components/composer.rbindex 33daafcb78a..f7caee1bfbf 100644--- a/plugins/chat/spec/system/page_objects/chat/components/composer.rb+++ b/plugins/chat/spec/system/page_objects/chat/components/composer.rb@@ -84,7 +84,7 @@ module PageObjectsenddef open_emoji_picker- find(context).find(SELECTOR).find(".chat-composer-button.-emoji").click+ find(context).find(SELECTOR).find(".chat-composer-button.--emoji").clickenddef cancel_editingdiff --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 28e335d9db0..afdbf09a8ce 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@@ -3,17 +3,33 @@module PageObjectsmodule Modalsclass ChatChannelCreate < PageObjects::Modals::Base+ EMOJI_PICKER = PageObjects::Components::EmojiPicker.new++ def form+ @form ||= PageObjects::Components::FormKit.new(".chat-modal-create-channel__form")+ end+def select_category(category)find(".category-chooser").clickfind(".category-row[data-value=\"#{category.id}\"]").clickend+ def select_emoji(emoji)+ find(".form-kit__field-emoji .btn-emoji").click+ EMOJI_PICKER.search_emoji(emoji)+ EMOJI_PICKER.select_emoji(":#{emoji}:")+ end++ def reset_emoji+ find(".form-kit__field-emoji .edit-channel-clear-emoji").click+ end+def create_channel_hintfind(".chat-modal-create-channel__hint")enddef slug_input- find(".-slug .chat-modal-create-channel__input")+ find("[data-name='slug'] input")enddef has_create_hint?(content)@@ -21,23 +37,27 @@ module PageObjectsenddef has_threading_toggle?- has_selector?(".chat-modal-create-channel__control.-threading-toggle")+ has_selector?("[data-name='threading_enabled']")+ end++ def toggle_auto_join+ find("[data-name='auto_join_users'] .form-kit__control-checkbox-label").clickenddef fill_name(name)- fill_in("name", with: name)+ form.field("name").fill_in(name)enddef fill_slug(slug)- fill_in("slug", with: slug)+ form.field("slug").fill_in(slug)enddef fill_description(description)- fill_in("description", with: description)+ form.field("description").fill_in(description)enddef has_name_prefilled?(name)- has_field?("name", with: name)+ form.field("name").has_value?(name)enddef closed?