A platform for community discussion. Free, open, simple.
DEV: introduces Chat::Thread::ListItem in styleguide (#21851)
Joffrey JAFFEUX473992bd3655
diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-thread-list-item.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-thread-list-item.hbsnew file mode 100644index 00000000000..b4c67be041e--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-thread-list-item.hbs@@ -0,0 +1,5 @@+<StyleguideExample @title="<Chat::Thread::ListItem>">+ <Styleguide::Component>+ <Chat::Thread::ListItem @thread={{this.thread}} />+ </Styleguide::Component>+</StyleguideExample>\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-thread-list-item.js b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-thread-list-item.jsnew file mode 100644index 00000000000..b6108bb0271--- /dev/null+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/chat-thread-list-item.js@@ -0,0 +1,9 @@+import Component from "@glimmer/component";+import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";+import { inject as service } from "@ember/service";++export default class ChatStyleguideChatThreadListItem extends Component {+ @service currentUser;++ thread = fabricators.thread();+}diff --git a/plugins/chat/assets/javascripts/discourse/components/styleguide/organisms/chat.hbs b/plugins/chat/assets/javascripts/discourse/components/styleguide/organisms/chat.hbsindex 85c37a190fa..a1fe944aac2 100644--- a/plugins/chat/assets/javascripts/discourse/components/styleguide/organisms/chat.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/styleguide/organisms/chat.hbs@@ -1,4 +1,4 @@<Styleguide::ChatMessage /><Styleguide::ChatComposer />-<Styleguide::ChatThreadOriginalMessage />+<Styleguide::ChatThreadListItem /><Styleguide::ChatComposerMessageDetails />\ No newline at end of filediff --git a/plugins/chat/assets/javascripts/discourse/lib/fabricators.js b/plugins/chat/assets/javascripts/discourse/lib/fabricators.jsindex 9e483f47d4d..6c514b1e08b 100644--- a/plugins/chat/assets/javascripts/discourse/lib/fabricators.js+++ b/plugins/chat/assets/javascripts/discourse/lib/fabricators.js@@ -11,6 +11,7 @@ import ChatChannel, {} from "discourse/plugins/chat/discourse/models/chat-channel";import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";import ChatThread from "discourse/plugins/chat/discourse/models/chat-thread";+import ChatThreadPreview from "discourse/plugins/chat/discourse/models/chat-thread-preview";import ChatDirectMessage from "discourse/plugins/chat/discourse/models/chat-direct-message";import ChatMessageReaction from "discourse/plugins/chat/discourse/models/chat-message-reaction";import User from "discourse/models/user";@@ -126,6 +127,14 @@ function threadFabricator(args = {}) {return ChatThread.create(channel, {id: args.id || sequence++,original_message: args.original_message || messageFabricator({ channel }),+ preview: args.preview || threadPreviewFabricator({ channel }),+ });+}+function threadPreviewFabricator(args = {}) {+ return ChatThreadPreview.create({+ last_reply_id: args.last_reply_id || sequence++,+ last_reply_created_at: args.last_reply_created_at || Date.now(),+ last_reply_excerpt: args.last_reply_excerpt || "This is a reply",});}@@ -163,6 +172,7 @@ export default {directMessageChannel: directMessageChannelFabricator,message: messageFabricator,thread: threadFabricator,+ threadPreview: threadPreviewFabricator,reaction: reactionFabricator,upload: uploadFabricator,category: categoryFabricator,diff --git a/plugins/chat/assets/javascripts/discourse/models/chat-thread-preview.js b/plugins/chat/assets/javascripts/discourse/models/chat-thread-preview.jsindex 9b04d4cbe50..e790c156480 100644--- a/plugins/chat/assets/javascripts/discourse/models/chat-thread-preview.js+++ b/plugins/chat/assets/javascripts/discourse/models/chat-thread-preview.js@@ -1,8 +1,8 @@import { tracked } from "@glimmer/tracking";export default class ChatThreadPreview {- static create(channel, args = {}) {- return new ChatThreadPreview(channel, args);+ static create(args = {}) {+ return new ChatThreadPreview(args);}@tracked lastReplyId;