diff --git a/assets/javascripts/discourse/components/topic-level-assign-menu.js b/assets/javascripts/discourse/components/topic-level-assign-menu.js
index adc1d56..f3d01b1 100644
--- a/assets/javascripts/discourse/components/topic-level-assign-menu.js
+++ b/assets/javascripts/discourse/components/topic-level-assign-menu.js
@@ -62,13 +62,7 @@ export default {
},
noneItem() {
- const topic = this.topic;
-
- if (topic.assigned_to_user || topic.hasAssignedPosts()) {
- return unassignUsersButton(topic.uniqueAssignees());
- } else if (topic.assigned_to_group) {
- return unassignGroupButton(topic.assigned_to_group);
- }
+ return topicLevelUnassignButton(this.topic.uniqueAssignees());
},
content() {
const content = [];
@@ -99,39 +93,6 @@ export default {
},
};
-function unassignGroupButton(group) {
- const label = I18n.t("discourse_assign.unassign.title");
- return {
- id: null,
- name: I18n.t("discourse_assign.reassign_modal.title"),
- label: htmlSafe(
- `${label} @${group.name}...`
- ),
- };
-}
-
-function unassignUsersButton(users) {
- let avatars = "";
- if (users.length === 1) {
- avatars = avatarHtml(users[0], "tiny");
- } else if (users.length > 1) {
- avatars =
- avatarHtml(users[0], "tiny", "overlap") + avatarHtml(users[1], "tiny");
- }
-
- const label = `${I18n.t(
- "discourse_assign.topic_level_menu.unassign_with_ellipsis"
- )}`;
-
- return {
- id: null,
- name: htmlSafe(
- I18n.t("discourse_assign.topic_level_menu.unassign_with_ellipsis")
- ),
- label: htmlSafe(`${avatars}${label}`),
- };
-}
-
function avatarHtml(user, size, classes) {
return renderAvatar(user, {
imageSize: size,
@@ -225,3 +186,31 @@ function unassignFromPostButton(postId, assignment) {
label: htmlSafe(`${icon} ${label}`),
};
}
+
+function topicLevelUnassignButton(assignees) {
+ const avatars = topicLevelUnassignButtonAvatars(assignees);
+ const label = `${I18n.t(
+ "discourse_assign.topic_level_menu.unassign_with_ellipsis"
+ )}`;
+
+ return {
+ id: null,
+ name: htmlSafe(
+ I18n.t("discourse_assign.topic_level_menu.unassign_with_ellipsis")
+ ),
+ label: htmlSafe(`${avatars}${label}`),
+ };
+}
+
+function topicLevelUnassignButtonAvatars(assignees) {
+ const users = assignees.filter((a) => a.username);
+ let avatars = "";
+ if (users.length === 1) {
+ avatars = avatarHtml(users[0], "tiny");
+ } else if (users.length > 1) {
+ avatars =
+ avatarHtml(users[0], "tiny", "overlap") + avatarHtml(users[1], "tiny");
+ }
+
+ return avatars;
+}