diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs b/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs new file mode 100644 index 00000000000..a014679d985 --- /dev/null +++ b/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs @@ -0,0 +1,49 @@ +import Component from "@glimmer/component"; +import { htmlSafe } from "@ember/template"; +import icon from "discourse-common/helpers/d-icon"; +import ChatUserAvatar from "discourse/plugins/chat/discourse/components/chat-user-avatar"; + +export default class ChatChannelIcon extends Component { + get firstUser() { + return this.args.channel.chatable.users[0]; + } + + get groupDirectMessage() { + return ( + this.args.channel.isDirectMessageChannel && + this.args.channel.chatable.group + ); + } + + get channelColorStyle() { + return htmlSafe(`color: #${this.args.channel.chatable.color}`); + } + + +} diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-name/index.gjs b/plugins/chat/assets/javascripts/discourse/components/channel-name/index.gjs new file mode 100644 index 00000000000..6aeb8aa933f --- /dev/null +++ b/plugins/chat/assets/javascripts/discourse/components/channel-name/index.gjs @@ -0,0 +1,79 @@ +import Component from "@glimmer/component"; +import { get, hash } from "@ember/helper"; +import { inject as service } from "@ember/service"; +import { htmlSafe } from "@ember/template"; +import PluginOutlet from "discourse/components/plugin-outlet"; +import UserStatusMessage from "discourse/components/user-status-message"; +import replaceEmoji from "discourse/helpers/replace-emoji"; + +export default class ChatChannelName extends Component { + @service currentUser; + + get firstUser() { + return this.args.channel.chatable.users[0]; + } + + get users() { + return this.args.channel.chatable.users; + } + + get groupDirectMessage() { + return ( + this.args.channel.isDirectMessageChannel && + this.args.channel.chatable.group + ); + } + + get groupsDirectMessageTitle() { + return this.args.channel.title || this.usernames; + } + + get usernames() { + return this.users.mapBy("username").join(", "); + } + + get channelColorStyle() { + return htmlSafe(`color: #${this.args.channel.chatable.color}`); + } + + get showUserStatus() { + return !!(this.users.length === 1 && this.users[0].status); + } + + +} diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-title/index.gjs b/plugins/chat/assets/javascripts/discourse/components/channel-title/index.gjs index 65b36f386c7..c2339d7f052 100644 --- a/plugins/chat/assets/javascripts/discourse/components/channel-title/index.gjs +++ b/plugins/chat/assets/javascripts/discourse/components/channel-title/index.gjs @@ -1,111 +1,21 @@ -import Component from "@glimmer/component"; -import { get, hash } from "@ember/helper"; -import { inject as service } from "@ember/service"; -import { htmlSafe } from "@ember/template"; -import PluginOutlet from "discourse/components/plugin-outlet"; -import UserStatusMessage from "discourse/components/user-status-message"; -import replaceEmoji from "discourse/helpers/replace-emoji"; -import icon from "discourse-common/helpers/d-icon"; -import ChatUserAvatar from "discourse/plugins/chat/discourse/components/chat-user-avatar"; +import concatClass from "discourse/helpers/concat-class"; +import ChannelIcon from "discourse/plugins/chat/discourse/components/channel-icon"; +import ChannelName from "discourse/plugins/chat/discourse/components/channel-name"; -export default class ChatChannelTitle extends Component { - @service currentUser; +const ChatChannelTitle = ; + +export default ChatChannelTitle; diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs index 7fd591fbe5f..b00f21c38dd 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs @@ -18,9 +18,9 @@ export default class ChatChannelMetadata extends Component { }