Skip to content

A platform for community discussion. Free, open, simple.

UI: simplify chat thread title (#29998)

Joffrey JAFFEUXb546c31b7fc4
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-thread-heading.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-thread-heading.gjs
new file mode 100644
index 00000000000..716ac34f4e1
--- /dev/null
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-thread-heading.gjs
@@ -0,0 +1,22 @@
+import Component from "@glimmer/component";
+import replaceEmoji from "discourse/helpers/replace-emoji";
+import icon from "discourse-common/helpers/d-icon";
+
+export default class ChatThreadHeading extends Component {
+ get showHeading() {
+ return this.args.thread?.title;
+ }
+
+ <template>
+ {{#if this.showHeading}}
+ <div class="chat-thread__heading">
+ <div class="chat-thread__heading-icon">
+ {{icon "discourse-threads"}}
+ </div>
+ <h2 class="chat-thread__heading-title">
+ {{replaceEmoji @thread.title}}
+ </h2>
+ </div>
+ {{/if}}
+ </template>
+}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-thread.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-thread.gjs
index 3975a9f3755..d58797bcc83 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-thread.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-thread.gjs
@@ -38,6 +38,7 @@ import Message from "./chat-message";
import ChatMessagesContainer from "./chat-messages-container";
import ChatMessagesScroller from "./chat-messages-scroller";
import ChatSkeleton from "./chat-skeleton";
+import ChatThreadHeading from "./chat-thread-heading";
import ChatUploadDropZone from "./chat-upload-drop-zone";
export default class ChatThread extends Component {
@@ -143,7 +144,6 @@ export default class ChatThread extends Component {
(state.distanceToBottom.pixels > 250 && !state.atBottom);
this.isScrolling = false;
this.atBottom = state.atBottom;
- this.args.setFullTitle?.(state.atTop);
if (state.atBottom) {
this.fetchMoreMessages({ direction: FUTURE });
@@ -569,6 +569,8 @@ export default class ChatThread extends Component {
{{/if}}
{{/unless}}
</ChatMessagesContainer>
+
+ <ChatThreadHeading @thread={{@thread}} />
</ChatMessagesScroller>
<ChatScrollToBottomArrow
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/browse.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/browse.gjs
index 54f167a5597..fd8f176992a 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/browse.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/browse.gjs
@@ -1,5 +1,4 @@
import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
import { array } from "@ember/helper";
import { service } from "@ember/service";
import { i18n } from "discourse-i18n";
@@ -12,19 +11,9 @@ export default class ChatDrawerRoutesBrowse extends Component {
@service chatChannelsManager;
@service chatHistory;
- @tracked showThreadFullTitle = false;
-
- get showfullTitle() {
- return this.chatStateManager.isDrawerExpanded && this.showThreadFullTitle;
- }
-
<template>
<div class="c-drawer-routes --browse">
- <Navbar
- @onClick={{this.chat.toggleDrawer}}
- @showFullTitle={{this.showfullTitle}}
- as |navbar|
- >
+ <Navbar @onClick={{this.chat.toggleDrawer}} as |navbar|>
<navbar.BackButton @route="chat.channels" />
<navbar.Title @title={{i18n "chat.browse.title"}} />
<navbar.Actions as |a|>
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/channel-thread.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/channel-thread.gjs
index 2e1635e8fb1..ed43633a488 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/channel-thread.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/channel-thread.gjs
@@ -1,5 +1,4 @@
import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
import { array } from "@ember/helper";
import { action } from "@ember/object";
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
@@ -16,12 +15,6 @@ export default class ChatDrawerRoutesChannelThread extends Component {
@service chatChannelsManager;
@service chatHistory;
- @tracked showThreadFullTitle = false;
-
- get showfullTitle() {
- return this.chatStateManager.isDrawerExpanded && this.showThreadFullTitle;
- }
-
get backButton() {
const link = {
models: this.chat.activeChannel?.routeModels,
@@ -71,11 +64,6 @@ export default class ChatDrawerRoutesChannelThread extends Component {
}
}
- @action
- setFullTitle(value) {
- this.showThreadFullTitle = value;
- }
-
<template>
<div
class="c-drawer-routes --channel-thread"
@@ -109,7 +97,6 @@ export default class ChatDrawerRoutesChannelThread extends Component {
<ChatThread
@thread={{thread}}
@targetMessageId={{@params.messageId}}
- @setFullTitle={{this.setFullTitle}}
/>
{{/if}}
{{/each}}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/index.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/index.gjs
index 100917167f3..d3cc0375b79 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/index.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/index.gjs
@@ -28,11 +28,7 @@ export default class ChatNavbar extends Component {
<template>
{{! template-lint-disable no-invalid-interactive }}
<div
- class={{concatClass
- "c-navbar-container"
- (if @onClick "-clickable")
- (if @showFullTitle "-full-title")
- }}
+ class={{concatClass "c-navbar-container" (if @onClick "-clickable")}}
{{on "click" (if @onClick @onClick (noop))}}
{{ChatOnResize this.handleResize}}
>
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/title.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/title.gjs
index d006a0c37c4..c088ada4030 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/title.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/title.gjs
@@ -1,5 +1,4 @@
import { hash } from "@ember/helper";
-import DButton from "discourse/components/d-button";
import concatClass from "discourse/helpers/concat-class";
import icon from "discourse-common/helpers/d-icon";
import SubTitle from "./sub-title";
@@ -8,20 +7,13 @@ const ChatNavbarTitle = <template>
<div
title={{@title}}
class={{concatClass "c-navbar__title" (if @showFullTitle "full-title")}}
+ ...attributes
>
- {{#if @openThreadTitleModal}}
- <DButton
- class="c-navbar__title-text btn-transparent"
- @icon={{@icon}}
- @action={{@openThreadTitleModal}}
- @translatedLabel={{@title}}
- />
- {{else}}
- <span class="c-navbar__title-text">
- {{if @icon (icon @icon)}}
- {{@title}}
- </span>
- {{/if}}
+ <span class="c-navbar__title-text">
+ {{if @icon (icon @icon)}}
+ {{@title}}
+ </span>
+
{{#if (has-block)}}
{{yield (hash SubTitle=SubTitle)}}
{{/if}}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread/header.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/thread/header.gjs
index 5bbbe0788b0..fc8a99a7870 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/thread/header.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/thread/header.gjs
@@ -1,4 +1,5 @@
import Component from "@glimmer/component";
+import { on } from "@ember/modifier";
import { service } from "@ember/service";
import noop from "discourse/helpers/noop";
import replaceEmoji from "discourse/helpers/replace-emoji";
@@ -91,7 +92,9 @@ export default class ChatThreadHeader extends Component {
<navbar.Title
@title={{replaceEmoji this.headerTitle}}
- @openThreadTitleModal={{this.openThreadTitleModal}}
+ {{on "click" this.openThreadTitleModal}}
+ role={{if this.openThreadTitleModal "button"}}
+ class="clickable"
/>
<navbar.Actions as |action|>
<action.ThreadTrackingDropdown @thread={{@thread}} />
diff --git a/plugins/chat/assets/stylesheets/common/chat-navbar.scss b/plugins/chat/assets/stylesheets/common/chat-navbar.scss
index 129801cc1ef..71cd5db68f1 100644
--- a/plugins/chat/assets/stylesheets/common/chat-navbar.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-navbar.scss
@@ -10,21 +10,6 @@
&.-clickable {
cursor: pointer;
}
-
- &.-full-title {
- .c-navbar__title {
- min-height: var(--chat-header-offset);
- }
-
- .c-navbar__title,
- .c-navbar__title-text {
- height: auto;
- overflow: visible;
- white-space: normal;
- text-overflow: unset;
- overflow-wrap: anywhere;
- }
- }
}
.c-navbar {
diff --git a/plugins/chat/assets/stylesheets/common/chat-thread-heading.scss b/plugins/chat/assets/stylesheets/common/chat-thread-heading.scss
new file mode 100644
index 00000000000..0ad4fece994
--- /dev/null
+++ b/plugins/chat/assets/stylesheets/common/chat-thread-heading.scss
@@ -0,0 +1,19 @@
+.chat-thread__heading {
+ padding: 0.5rem 0.5rem 0 0.5rem;
+ display: flex;
+ align-items: baseline;
+}
+
+.chat-thread__heading-icon {
+ color: var(--secondary-low);
+ display: flex;
+ background-color: var(--primary-100);
+ padding: 0.5em;
+ border-radius: 100%;
+}
+
+.chat-thread__heading-title {
+ padding-left: 0.5em;
+ color: var(--secondary-low);
+ margin-bottom: 0;
+}
diff --git a/plugins/chat/assets/stylesheets/common/index.scss b/plugins/chat/assets/stylesheets/common/index.scss
index a2ddcd1f510..63180512d43 100644
--- a/plugins/chat/assets/stylesheets/common/index.scss
+++ b/plugins/chat/assets/stylesheets/common/index.scss
@@ -14,6 +14,7 @@
@import "chat-composer-dropdown";
@import "chat-composer-upload";
@import "chat-composer-uploads";
+@import "chat-thread-heading";
@import "chat-composer";
@import "chat-composer-button";
@import "chat-message-blocks";
diff --git a/plugins/chat/assets/stylesheets/mobile/chat-navbar.scss b/plugins/chat/assets/stylesheets/mobile/chat-navbar.scss
index 3ef278ea3a9..63e33f04f64 100644
--- a/plugins/chat/assets/stylesheets/mobile/chat-navbar.scss
+++ b/plugins/chat/assets/stylesheets/mobile/chat-navbar.scss
@@ -10,17 +10,4 @@
&__back-button {
align-self: stretch;
}
- &.-full-title {
- .c-navbar {
- &__actions,
- &__back-button {
- height: calc(var(--chat-header-offset) - 2px) !important;
- }
- &__title {
- padding-block: calc(1rem + 2px);
- }
- }
- left: 0.25rem;
- width: calc(100% - 0.5rem);
- }
}
diff --git a/plugins/chat/test/javascripts/components/chat-thread-heading-test.gjs b/plugins/chat/test/javascripts/components/chat-thread-heading-test.gjs
new file mode 100644
index 00000000000..9602b435376
--- /dev/null
+++ b/plugins/chat/test/javascripts/components/chat-thread-heading-test.gjs
@@ -0,0 +1,30 @@
+import { getOwner } from "@ember/owner";
+import { render } from "@ember/test-helpers";
+import { module, test } from "qunit";
+import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+import ChatThreadHeading from "discourse/plugins/chat/discourse/components/chat-thread-heading";
+import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
+
+module("Discourse Chat | Component | chat-thread-heading", function (hooks) {
+ setupRenderingTest(hooks);
+
+ test("it renders the title", async function (assert) {
+ const thread = new ChatFabricators(getOwner(this)).thread({
+ title: "A nice thread title",
+ });
+
+ await render(<template><ChatThreadHeading @thread={{thread}} /></template>);
+
+ assert.dom(".chat-thread__heading-title").hasText("A nice thread title");
+ });
+
+ test("it doesn’t render heading when no title", async function (assert) {
+ const thread = new ChatFabricators(getOwner(this)).thread({
+ title: null,
+ });
+
+ await render(<template><ChatThreadHeading @thread={{thread}} /></template>);
+
+ assert.dom(".chat-thread__heading").doesNotExist();
+ });
+});