From 4be24d6c3181922219d7d879b5aec8c669db2e5f Mon Sep 17 00:00:00 2001 From: Juan David Martinez Date: Mon, 10 Mar 2025 23:43:28 -0500 Subject: [PATCH] further user name display changes --- .../components/topic-level-assign-menu.js | 16 +++++++++++++--- lib/assigner.rb | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/assets/javascripts/discourse/components/topic-level-assign-menu.js b/assets/javascripts/discourse/components/topic-level-assign-menu.js index 4425c42..247b1e7 100644 --- a/assets/javascripts/discourse/components/topic-level-assign-menu.js +++ b/assets/javascripts/discourse/components/topic-level-assign-menu.js @@ -72,7 +72,12 @@ export default { const content = []; if (this.topic.isAssigned()) { - content.push(unassignFromTopicButton(this.topic)); + content.push( + unassignFromTopicButton( + this.topic, + this.siteSettings.prioritize_full_name_in_ux + ) + ); } if (this.topic.hasAssignedPosts()) { @@ -131,9 +136,14 @@ function reassignToSelfButton() { }; } -function unassignFromTopicButton(topic) { - const username = +function unassignFromTopicButton(topic, prioritize_full_name_in_ux) { + let username = topic.assigned_to_user?.username || topic.assigned_to_group?.name; + + if (topic.assigned_to_user && prioritize_full_name_in_ux) { + username = topic.assigned_to_user?.name || topic.assigned_to_user?.username; + } + const icon = topic.assigned_to_user ? avatarHtml(topic.assigned_to_user, "small") : iconHTML("user-xmark"); diff --git a/lib/assigner.rb b/lib/assigner.rb index 7b2460a..e50d568 100644 --- a/lib/assigner.rb +++ b/lib/assigner.rb @@ -405,9 +405,7 @@ class ::Assigner if SiteSetting.unassign_creates_tracking_post && !silent post_type = SiteSetting.assigns_public ? Post.types[:small_action] : Post.types[:whisper] - custom_fields = { - "action_code_who" => assigned_to.is_a?(User) ? assigned_to.username : assigned_to.name, - } + custom_fields = small_action_username_or_name(assigned_to) if post_target? custom_fields.merge!("action_code_path" => "/p/#{@target.id}") @@ -493,10 +491,19 @@ class ::Assigner Jobs.enqueue(:assign_notification, assignment_id: assignment.id) end + def small_action_username_or_name(assign_to) + if assign_to.is_a?(User) && SiteSetting.prioritize_full_name_in_ux && !assign_to.username + custom_fields = { "action_code_who" => assign_to.name || assign_to.username } + else + custom_fields = { + "action_code_who" => assign_to.is_a?(User) ? assign_to.username : assign_to.name, + } + end + custom_fields + end + def add_small_action_post(action_code, assign_to, text) - custom_fields = { - "action_code_who" => assign_to.is_a?(User) ? assign_to.username : assign_to.name, - } + custom_fields = small_action_username_or_name(assign_to) if post_target? custom_fields.merge!(