+ {{icon this.icon}} + {{#if this.assignedToUser}} + + + {{i18n + "discourse_assign.assigned_topic_to" + username=(userPrioritizedName this.assignedToUser) + path=(assignedToUserPath this.assignedToUser) + }} + + + {{/if}} + + {{#if this.assignedToGroup}} + + + {{i18n + "discourse_assign.assigned_topic_to" + username=this.assignedToGroup.name + path=(assignedToGroupPath this.assignedToGroup) + }} + + + {{/if}} + + {{#each this.indirectAssignments key="postId" as |indirectAssignment|}} + + {{i18n "discourse_assign.assigned"}} + + + + {{i18n + "discourse_assign.assign_post_to_multiple" + post_number=indirectAssignment.postNumber + username=(userPrioritizedName indirectAssignment.assignee) + }} + + + {{/each}} +
+ {{/if}} + +} diff --git a/assets/javascripts/discourse/components/assigned-to-post.gjs b/assets/javascripts/discourse/components/assigned-to-post.gjs index 65d143b6..80800a6b 100644 --- a/assets/javascripts/discourse/components/assigned-to-post.gjs +++ b/assets/javascripts/discourse/components/assigned-to-post.gjs @@ -4,6 +4,7 @@ import { service } from "@ember/service"; import DButton from "discourse/components/d-button"; import DropdownMenu from "discourse/components/dropdown-menu"; import icon from "discourse/helpers/d-icon"; +import userPrioritizedName from "discourse/helpers/user-prioritized-name"; import { i18n } from "discourse-i18n"; import DMenu from "float-kit/components/d-menu"; @@ -11,14 +12,6 @@ export default class AssignedToPost extends Component { @service taskActions; @service siteSettings; - get nameOrUsername() { - if (!this.siteSettings.prioritize_username_in_ux) { - return this.args.assignedToUser.name || this.args.assignedToUser.username; - } else { - return this.args.assignedToUser.username; - } - } - @action unassign() { this.taskActions.unassignPost(this.args.post); @@ -42,7 +35,7 @@ export default class AssignedToPost extends Component { {{#if @assignedToUser}} - {{this.nameOrUsername}} + {{userPrioritizedName @assignedToUser}} {{else}} {{@assignedToGroup.name}} {{/if}} diff --git a/assets/javascripts/discourse/components/post-assignments-display.gjs b/assets/javascripts/discourse/components/post-assignments-display.gjs new file mode 100644 index 00000000..c078c890 --- /dev/null +++ b/assets/javascripts/discourse/components/post-assignments-display.gjs @@ -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); + } + + + {{#if this.post.firstPost}} +
+