Skip to content

Commit 2824e5f

Browse files
Show the menu when topic isn't assigned but there are assigned posts
1 parent 7f2190f commit 2824e5f

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,17 @@ function defaultTitle(topic) {
3737
}
3838
}
3939

40-
function includeIsAssignedOnTopic(api) {
40+
function extendTopicModel(api) {
4141
api.modifyClass("model:topic", {
4242
pluginId: PLUGIN_ID,
4343
isAssigned() {
4444
return this.assigned_to_user || this.assigned_to_group;
4545
},
46+
47+
hasAssignedPosts() {
48+
// fixme andrei implement
49+
return true;
50+
}
4651
});
4752
}
4853

@@ -793,7 +798,7 @@ export default {
793798
}
794799

795800
withPluginApi("0.13.0", (api) => {
796-
includeIsAssignedOnTopic(api);
801+
extendTopicModel(api);
797802
initialize(api);
798803
registerTopicFooterButtons(api);
799804

assets/javascripts/discourse/lib/topic-level-assign-menu.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,22 @@ export default {
8989
}
9090
},
9191
content() {
92-
const content = [
93-
unassignFromTopicButton(this.topic),
94-
...unassignFromPostButtons(this.topic),
95-
];
92+
const content = [];
9693

97-
if (showReassignSelfButton(this.topic, this.currentUser)) {
98-
content.push(reassignToSelfButton());
94+
if (this.topic.isAssigned()) {
95+
content.push(unassignFromTopicButton(this.topic));
96+
}
97+
98+
if (this.topic.hasAssignedPosts()) {
99+
content.push(...unassignFromPostButtons(this.topic));
100+
}
101+
102+
if (this.topic.isAssigned()) {
103+
if (showReassignSelfButton(this.topic, this.currentUser)) {
104+
content.push(reassignToSelfButton());
105+
}
106+
content.push(reassignButton());
99107
}
100-
content.push(reassignButton());
101108

102109
return content;
103110
},
@@ -106,7 +113,7 @@ export default {
106113
return (
107114
this.currentUser?.can_assign &&
108115
!this.site.mobileView &&
109-
this.topic.isAssigned()
116+
(this.topic.isAssigned() || this.topic.hasAssignedPosts())
110117
);
111118
},
112119
};
@@ -165,10 +172,6 @@ function unassignFromTopicButton(topic) {
165172
}
166173

167174
function unassignFromPostButtons(topic) {
168-
if (!topic.indirectly_assigned_to) {
169-
return [];
170-
}
171-
172175
return Object.entries(topic.indirectly_assigned_to).map(
173176
([postId, assignment]) => unassignFromPostButton(postId, assignment)
174177
);

0 commit comments

Comments
 (0)