A platform for community discussion. Free, open, simple.
UX: simplify chat join preview card (#41054)
Penar Musaraj3212d0b2da57
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-preview-card.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-preview-card.gjsindex a2eebce42cc..25aab0331c9 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-preview-card.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-preview-card.gjs@@ -1,56 +1,37 @@import Component from "@glimmer/component";import { hash } from "@ember/helper";-import { LinkTo } from "@ember/routing";-import { service } from "@ember/service";-import { isEmpty } from "@ember/utils";import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";import { i18n } from "discourse-i18n";-import ChannelTitle from "./channel-title";import ToggleChannelMembershipButton from "./toggle-channel-membership-button";export default class ChatChannelPreviewCard extends Component {- @service currentUser;-get showJoinButton() {return this.args.channel?.isOpen && this.args.channel?.canJoin;}- get showBrowseAllLink() {- return !!this.currentUser;- }-- get hasDescription() {- return !isEmpty(this.args.channel?.description);+ get channelPlaceholder() {+ return i18n("chat.placeholder_channel", {+ channelName: `#${this.args.channel.title}`,+ });}<template><divclass={{dConcatClass"chat-channel-preview-card"- (unless this.hasDescription "-no-description")(unless this.showJoinButton "-no-button")}}>- <ChannelTitle @channel={{@channel}} />- {{#if this.hasDescription}}- <p class="chat-channel-preview-card__description">- {{@channel.description}}- </p>- {{/if}}{{#if this.showJoinButton}}+ <div class="chat-channel__placeholder">+ {{this.channelPlaceholder}}+ </div>+<ToggleChannelMembershipButton@channel={{@channel}}- @options={{hash joinClass="btn-primary"}}+ @options={{hash joinClass="btn-primary" labelType="short"}}/>{{/if}}- {{#if this.showBrowseAllLink}}- <LinkTo- @route="chat.browse"- class="chat-channel-preview-card__browse-all"- >- {{i18n "chat.browse_all_channels"}}- </LinkTo>- {{/if}}</div></template>}diff --git a/plugins/chat/assets/stylesheets/common/chat-channel-preview-card.scss b/plugins/chat/assets/stylesheets/common/chat-channel-preview-card.scssindex 1b57a40e23f..7bf4c5854f4 100644--- a/plugins/chat/assets/stylesheets/common/chat-channel-preview-card.scss+++ b/plugins/chat/assets/stylesheets/common/chat-channel-preview-card.scss@@ -1,48 +1,17 @@.chat-channel-preview-card {- margin: 1rem 0 0 0;- padding: 1.5rem 1rem;- background-color: var(--secondary-very-high);+ padding: 0.5rem;display: flex;- flex-direction: column;+ flex-direction: row;align-items: center;+ justify-content: space-between;z-index: 3;+ border: 1px solid var(--d-chat-input-border-color);+ background-color: var(--d-chat-input-bg-color);+ border-radius: var(--d-border-radius-large);+ margin: 1rem;+ margin-top: 0.25rem;- &.-no-description {- .chat-channel-title {- margin-bottom: 1.5rem;- }- }-- &.-no-button {- .chat-channel-preview-card__browse-all {- margin-top: 0;- }- }-- &__description {- color: var(--primary-600);- text-align: center;- overflow-wrap: break-word;- max-width: 100%;- }-- .chat-channel-title__name {- font-size: var(--font-up-2);- }-- &__join-channel-btn {- font-size: var(--font-up-2);- border: 1px solid transparent;- border-radius: var(--d-button-border-radius);- line-height: normal;- box-sizing: border-box;- padding: 0.5em 0.65em;- font-weight: normal;- cursor: pointer;- }-- &__browse-all {- margin-top: 1rem;- font-size: var(--font-down-1);+ .chat-channel__placeholder {+ color: var(--primary-medium);}}diff --git a/plugins/chat/assets/stylesheets/common/chat-channel-title.scss b/plugins/chat/assets/stylesheets/common/chat-channel-title.scssindex d6dc7a0f1dc..e2e02fae98a 100644--- a/plugins/chat/assets/stylesheets/common/chat-channel-title.scss+++ b/plugins/chat/assets/stylesheets/common/chat-channel-title.scss@@ -4,10 +4,6 @@align-items: center;gap: 0.5rem;- .chat-channel-preview-card & {- max-width: 100%;- }-&__user-info {overflow: hidden;}diff --git a/plugins/chat/spec/system/anonymous_public_channels_spec.rb b/plugins/chat/spec/system/anonymous_public_channels_spec.rbindex a5d30390070..cdd79bab791 100644--- a/plugins/chat/spec/system/anonymous_public_channels_spec.rb+++ b/plugins/chat/spec/system/anonymous_public_channels_spec.rb@@ -41,7 +41,6 @@ RSpec.describe "Anonymous public chat channels" doexpect(channel_page).to have_no_composerexpect(channel_page).to have_no_search_buttonexpect(channel_page).to have_no_star_button- expect(channel_page).to have_no_browse_all_linkchannel_page.join_channeldiff --git a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb b/plugins/chat/spec/system/page_objects/chat/chat_channel.rbindex b3919d6b701..732531e3fd8 100644--- a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb+++ b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb@@ -251,10 +251,6 @@ module PageObjectshas_no_css?(".c-navbar__star-channel-button")end- def has_no_browse_all_link?- has_no_css?(".chat-channel-preview-card__browse-all")- end-def thread_list_button_selector".c-navbar__threads-list-button"enddiff --git a/plugins/chat/spec/system/visit_channel_spec.rb b/plugins/chat/spec/system/visit_channel_spec.rbindex 5319ebd631b..4fd2fd5f668 100644--- a/plugins/chat/spec/system/visit_channel_spec.rb+++ b/plugins/chat/spec/system/visit_channel_spec.rb@@ -127,7 +127,7 @@ RSpec.describe "Visit channel" doit "allows to join it" dochat.visit_channel(category_channel_1)- expect(page).to have_content(I18n.t("js.chat.channel_settings.join_channel"))+ expect(page).to have_content(I18n.t("js.chat.channel_settings.join"))endit "shows a preview of the channel" do@@ -152,10 +152,7 @@ RSpec.describe "Visit channel" doit "allows to join it" dochat.visit_thread(thread)- expect(page).to have_content(- I18n.t("js.chat.channel_settings.join_channel"),- count: 2,- )+ expect(page).to have_content(I18n.t("js.chat.channel_settings.join"), count: 2)endendenddiff --git a/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.gjs b/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.gjsindex bb418e4dd19..7d37a3445e8 100644--- a/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.gjs+++ b/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.gjs@@ -23,46 +23,14 @@ module("Component | ChatChannelPreviewCard", function (hooks) {this.siteSettings.chat_enabled = true;});- test("channel title", async function (assert) {+ test("card", async function (assert) {await render(<template><ChatChannelPreviewCard @channel={{this.channel}} /></template>);assert- .dom(".chat-channel-name__label")- .hasText(this.channel.title, "shows the channel title");-- assert- .dom(".chat-channel-icon.--icon")- .exists("shows the category hashtag badge");- });-- test("channel description", async function (assert) {- await render(- <template><ChatChannelPreviewCard @channel={{this.channel}} /></template>- );-- assert- .dom(".chat-channel-preview-card__description")- .hasText(this.channel.description, "the channel description is shown");- });-- test("no channel description", async function (assert) {- this.channel.description = null;-- await render(- <template><ChatChannelPreviewCard @channel={{this.channel}} /></template>- );-- assert- .dom(".chat-channel-preview-card__description")- .doesNotExist(- "no line is left for the channel description if there is none"- );-- assert- .dom(".chat-channel-preview-card.-no-description")- .exists("adds a modifier class for styling");+ .dom(".chat-channel-preview-card")+ .exists("shows the channel preview card");});test("join", async function (assert) {@@ -75,16 +43,6 @@ module("Component | ChatChannelPreviewCard", function (hooks) {.exists("shows the join channel button");});- test("browse all", async function (assert) {- await render(- <template><ChatChannelPreviewCard @channel={{this.channel}} /></template>- );-- assert- .dom(".chat-channel-preview-card__browse-all")- .exists("shows a link to browse all channels");- });-test("closed channel", async function (assert) {this.channel.status = "closed";await render(@@ -92,26 +50,7 @@ module("Component | ChatChannelPreviewCard", function (hooks) {);assert- .dom(".chat-channel-preview-card__join-channel-btn")+ .dom(".toggle-channel-membership-button.-join").doesNotExist("it does not show the join channel button");});});--module("Component | ChatChannelPreviewCard | anonymous", function (hooks) {- setupRenderingTest(hooks, { anonymous: true });-- hooks.beforeEach(function () {- this.channel = new ChatFabricators(getOwner(this)).channel({- chatable_type: "Category",- meta: { can_join_chat_channel: true },- });- });-- test("browse all link is hidden", async function (assert) {- await render(- <template><ChatChannelPreviewCard @channel={{this.channel}} /></template>- );-- assert.dom(".chat-channel-preview-card__browse-all").doesNotExist();- });-});diff --git a/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss b/plugins/discourse-calendar/assets/stylesheets/common/livestream.scssindex 2166c6601db..c3d1c6e7061 100644--- a/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss+++ b/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss@@ -23,16 +23,6 @@ body.chat-enabled.livestream-topic.confirmed-event-assistance {}}-body.chat-enabled.livestream-topic .chat-channel-preview-card {- .chat-channel-preview-card__browse-all {- display: none;- }-- .chat-channel-title {- display: none;- }-}-.livestream-chat-modal {.chat-drawer {width: 100%;