Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit 456c253

Browse files
committed
Fix failing test because of prioritize_full_name_in_ux
1 parent 76d3bc1 commit 456c253

File tree

1 file changed

+23
-136
lines changed

1 file changed

+23
-136
lines changed

assets/javascripts/discourse/initializers/extend-for-assigns.js

Lines changed: 23 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,6 @@ function initialize(api) {
324324
}
325325
}
326326

327-
api.addPostSmallActionClassesCallback((post) => {
328-
// TODO (glimmer-post-stream): only check for .action_code once the widget code is removed
329-
const actionCode = post.action_code || post.actionCode;
330-
331-
if (actionCode.includes("assigned") && !siteSettings.assigns_public) {
332-
return ["private-assign"];
333-
}
334-
});
335-
336327
api.addAdvancedSearchOptions(
337328
api.getCurrentUser()?.can_assign
338329
? {
@@ -384,17 +375,6 @@ function initialize(api) {
384375
}
385376
);
386377

387-
api.addPostSmallActionIcon("assigned", "user-plus");
388-
api.addPostSmallActionIcon("assigned_to_post", "user-plus");
389-
api.addPostSmallActionIcon("assigned_group", "group-plus");
390-
api.addPostSmallActionIcon("assigned_group_to_post", "group-plus");
391-
api.addPostSmallActionIcon("unassigned", "user-xmark");
392-
api.addPostSmallActionIcon("unassigned_group", "group-times");
393-
api.addPostSmallActionIcon("unassigned_from_post", "user-xmark");
394-
api.addPostSmallActionIcon("unassigned_group_from_post", "group-times");
395-
api.addPostSmallActionIcon("reassigned", "user-plus");
396-
api.addPostSmallActionIcon("reassigned_group", "group-plus");
397-
398378
api.addDiscoveryQueryParam("assigned", { replace: true, refreshModel: true });
399379

400380
api.addTagsHtmlCallback((topic, params = {}) => {
@@ -487,119 +467,6 @@ function initialize(api) {
487467
return result;
488468
});
489469

490-
api.createWidget("assigned-to-post", {
491-
html(attrs) {
492-
return new RenderGlimmer(
493-
this,
494-
"p.assigned-to",
495-
hbs`
496-
<AssignedToPost @assignedToUser={{@data.assignedToUser}} @assignedToGroup={{@data.assignedToGroup}}
497-
@href={{@data.href}} @post={{@data.post}} />`,
498-
{
499-
assignedToUser: attrs.post.assigned_to_user,
500-
assignedToGroup: attrs.post.assigned_to_group,
501-
href: attrs.href,
502-
post: attrs.post,
503-
}
504-
);
505-
},
506-
});
507-
508-
api.createWidget("assigned-to-first-post", {
509-
html(attrs) {
510-
const topic = attrs.topic;
511-
const [assignedToUser, assignedToGroup, indirectlyAssignedTo] = [
512-
topic.assigned_to_user,
513-
topic.assigned_to_group,
514-
topic.indirectly_assigned_to,
515-
];
516-
const assigneeElements = [];
517-
518-
const assignedHtml = (username, path, type) => {
519-
return `<span class="assigned-to--${type}">${htmlSafe(
520-
i18n("discourse_assign.assigned_topic_to", {
521-
username,
522-
path,
523-
})
524-
)}</span>`;
525-
};
526-
527-
let displayedName = "";
528-
if (assignedToUser) {
529-
displayedName = this.siteSettings.prioritize_full_name_in_ux
530-
? assignedToUser.name || assignedToUser.username
531-
: assignedToUser.username;
532-
533-
assigneeElements.push(
534-
h(
535-
"span.assignee",
536-
new RawHtml({
537-
html: assignedHtml(
538-
displayedName,
539-
assignedToUserPath(assignedToUser),
540-
"user"
541-
),
542-
})
543-
)
544-
);
545-
}
546-
if (assignedToGroup) {
547-
assigneeElements.push(
548-
h(
549-
"span.assignee",
550-
new RawHtml({
551-
html: assignedHtml(
552-
assignedToGroup.name,
553-
assignedToGroupPath(assignedToGroup),
554-
"group"
555-
),
556-
})
557-
)
558-
);
559-
}
560-
561-
if (indirectlyAssignedTo) {
562-
Object.keys(indirectlyAssignedTo).map((postId) => {
563-
const assignee = indirectlyAssignedTo[postId].assigned_to;
564-
const postNumber = indirectlyAssignedTo[postId].post_number;
565-
566-
displayedName =
567-
this.siteSettings.prioritize_full_name_in_ux || !assignee.username
568-
? assignee.name || assignee.username
569-
: assignee.username;
570-
571-
assigneeElements.push(
572-
h("span.assignee", [
573-
h(
574-
"a",
575-
{
576-
attributes: {
577-
class: "assigned-indirectly",
578-
href: `${topic.url}/${postNumber}`,
579-
},
580-
},
581-
i18n("discourse_assign.assign_post_to_multiple", {
582-
post_number: postNumber,
583-
username: displayedName,
584-
})
585-
),
586-
])
587-
);
588-
});
589-
}
590-
591-
if (!isEmpty(assigneeElements)) {
592-
return h("p.assigned-to", [
593-
assignedToUser ? iconNode("user-plus") : iconNode("group-plus"),
594-
assignedToUser || assignedToGroup
595-
? ""
596-
: h("span.assign-text", i18n("discourse_assign.assigned")),
597-
assigneeElements,
598-
]);
599-
}
600-
},
601-
});
602-
603470
api.modifyClass(
604471
"model:group",
605472
(Superclass) =>
@@ -686,7 +553,7 @@ function initialize(api) {
686553
}
687554
);
688555

689-
customizePost(api);
556+
customizePost(api, siteSettings);
690557

691558
api.replaceIcon("notification.assigned", "user-plus");
692559

@@ -710,7 +577,7 @@ function initialize(api) {
710577
api.addKeyboardShortcut("g a", "", { path: "/my/activity/assigned" });
711578
}
712579

713-
function customizePost(api) {
580+
function customizePost(api, siteSettings) {
714581
api.addTrackedPostProperties("assigned_to_user", "assigned_to_group");
715582

716583
api.modifyClass(
@@ -740,6 +607,26 @@ function customizePost(api) {
740607
PostAssignmentsDisplay
741608
);
742609

610+
api.addPostSmallActionClassesCallback((post) => {
611+
// TODO (glimmer-post-stream): only check for .action_code once the widget code is removed
612+
const actionCode = post.action_code || post.actionCode;
613+
614+
if (actionCode.includes("assigned") && !siteSettings.assigns_public) {
615+
return ["private-assign"];
616+
}
617+
});
618+
619+
api.addPostSmallActionIcon("assigned", "user-plus");
620+
api.addPostSmallActionIcon("assigned_to_post", "user-plus");
621+
api.addPostSmallActionIcon("assigned_group", "group-plus");
622+
api.addPostSmallActionIcon("assigned_group_to_post", "group-plus");
623+
api.addPostSmallActionIcon("unassigned", "user-xmark");
624+
api.addPostSmallActionIcon("unassigned_group", "group-times");
625+
api.addPostSmallActionIcon("unassigned_from_post", "user-xmark");
626+
api.addPostSmallActionIcon("unassigned_group_from_post", "group-times");
627+
api.addPostSmallActionIcon("reassigned", "user-plus");
628+
api.addPostSmallActionIcon("reassigned_group", "group-plus");
629+
743630
withSilencedDeprecations("discourse.post-stream-widget-overrides", () =>
744631
customizeWidgetPost(api)
745632
);
@@ -820,7 +707,7 @@ function customizeWidgetPost(api) {
820707

821708
let displayedName = "";
822709
if (assignedToUser) {
823-
displayedName = !this.siteSettings.prioritize_username_in_ux
710+
displayedName = this.siteSettings.prioritize_full_name_in_ux
824711
? assignedToUser.name || assignedToUser.username
825712
: assignedToUser.username;
826713

0 commit comments

Comments
 (0)