DEV: introduces Chat::Thread::ListItem in styleguide (#21851)

This commit is contained in:
Joffrey JAFFEUX 2023-05-31 10:29:38 +02:00 committed by GitHub
parent 4e99ef3952
commit 473992bd36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 3 deletions

View File

@ -0,0 +1,5 @@
<StyleguideExample @title="<Chat::Thread::ListItem>">
<Styleguide::Component>
<Chat::Thread::ListItem @thread={{this.thread}} />
</Styleguide::Component>
</StyleguideExample>

View File

@ -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();
}

View File

@ -1,4 +1,4 @@
<Styleguide::ChatMessage />
<Styleguide::ChatComposer />
<Styleguide::ChatThreadOriginalMessage />
<Styleguide::ChatThreadListItem />
<Styleguide::ChatComposerMessageDetails />

View File

@ -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,

View File

@ -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;