This repository was archived by the owner on Jul 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
DEV: Add compatibility with the Glimmer Post Stream #651
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1b8b2a3
DEV: Add compatibility with the Glimmer Post Stream
megothss e8cb949
Use `modifyClass("model:post", ...)` as an alternative to `addPostTra…
megothss 76d3bc1
Fixed markup issues and changed test scenarios to also use the Glimme…
megothss 456c253
Fix failing test because of prioritize_full_name_in_ux
megothss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
assets/javascripts/discourse/components/assigned-to-first-post.gjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import Component from "@glimmer/component"; | ||
import { concat } from "@ember/helper"; | ||
import icon from "discourse/helpers/d-icon"; | ||
import userPrioritizedName from "discourse/helpers/user-prioritized-name"; | ||
import { i18n } from "discourse-i18n"; | ||
import { assignedToGroupPath, assignedToUserPath } from "../lib/url"; | ||
|
||
export default class AssignedToFirstPost extends Component { | ||
get assignedToUser() { | ||
return this.args.post?.topic?.assigned_to_user; | ||
} | ||
|
||
get assignedToGroup() { | ||
return this.args.post?.topic?.assigned_to_group; | ||
} | ||
|
||
get icon() { | ||
return this.assignedToUser ? "user-plus" : "group-plus"; | ||
} | ||
|
||
get indirectlyAssignedTo() { | ||
return this.args.post?.topic?.indirectly_assigned_to; | ||
} | ||
|
||
get indirectAssignments() { | ||
if (!this.indirectlyAssignedTo) { | ||
return null; | ||
} | ||
|
||
return Object.keys(this.indirectlyAssignedTo).map((postId) => { | ||
const postNumber = this.indirectlyAssignedTo[postId].post_number; | ||
|
||
return { | ||
postId, | ||
assignee: this.indirectlyAssignedTo[postId].assigned_to, | ||
postNumber, | ||
url: `${this.args.post.topic.url}/${postNumber}`, | ||
}; | ||
}); | ||
} | ||
|
||
get isAssigned() { | ||
return !!( | ||
this.assignedToUser || | ||
this.assignedToGroup || | ||
this.args.post?.topic?.indirectly_assigned_to | ||
); | ||
} | ||
|
||
<template> | ||
{{#if this.isAssigned}} | ||
<p class="assigned-to"> | ||
{{icon this.icon}} | ||
{{#if this.assignedToUser}} | ||
<span class="assignee"> | ||
<span class="assigned-to--user"> | ||
{{i18n | ||
"discourse_assign.assigned_topic_to" | ||
username=(userPrioritizedName this.assignedToUser) | ||
path=(assignedToUserPath this.assignedToUser) | ||
}} | ||
</span> | ||
</span> | ||
{{/if}} | ||
|
||
{{#if this.assignedToGroup}} | ||
<span class="assignee"> | ||
<span class="assigned-to--group"> | ||
{{i18n | ||
"discourse_assign.assigned_topic_to" | ||
username=this.assignedToGroup.name | ||
path=(assignedToGroupPath this.assignedToGroup) | ||
}} | ||
</span> | ||
</span> | ||
{{/if}} | ||
|
||
{{#each this.indirectAssignments key="postId" as |indirectAssignment|}} | ||
<span class="assign-text"> | ||
{{i18n "discourse_assign.assigned"}} | ||
</span> | ||
<span class="assignee"> | ||
<a href={{indirectAssignment.url}} class="assigned-indirectly"> | ||
{{i18n | ||
"discourse_assign.assign_post_to_multiple" | ||
post_number=indirectAssignment.postNumber | ||
username=(userPrioritizedName indirectAssignment.assignee) | ||
}} | ||
</a> | ||
</span> | ||
{{/each}} | ||
</p> | ||
{{/if}} | ||
</template> | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
assets/javascripts/discourse/components/post-assignments-display.gjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Component from "@glimmer/component"; | ||
import { assignedToGroupPath, assignedToUserPath } from "../lib/url"; | ||
import AssignedFirstPost from "./assigned-to-first-post"; | ||
import AssignedToPost from "./assigned-to-post"; | ||
|
||
export default class PostAssignmentsDisplay extends Component { | ||
static shouldRender(args) { | ||
return args.post; | ||
} | ||
|
||
get post() { | ||
return this.args.outletArgs.post; | ||
} | ||
|
||
get assignedTo() { | ||
return this.post.topic?.indirectly_assigned_to?.[this.post.id]?.assigned_to; | ||
} | ||
|
||
get assignedToUser() { | ||
return this.assignedTo.username ? this.assignedTo : null; | ||
} | ||
|
||
get assignedToGroup() { | ||
return !this.assignedToUser && this.assignedTo.name | ||
? this.assignedTo | ||
: null; | ||
} | ||
|
||
get assignedHref() { | ||
return this.assignedToUser | ||
? assignedToUserPath(this.assignedToUser) | ||
: assignedToGroupPath(this.assignedToGroup); | ||
} | ||
|
||
<template> | ||
{{#if this.post.firstPost}} | ||
<AssignedFirstPost @post={{this.post}} /> | ||
{{else if this.assignedTo}} | ||
<p class="assigned-to"> | ||
<AssignedToPost | ||
@assignedToUser={{this.assignedToUser}} | ||
@assignedToGroup={{this.assignedToGroup}} | ||
@href={{this.assignedHref}} | ||
@post={{this.post}} | ||
/> | ||
</p> | ||
{{/if}} | ||
</template> | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.