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

Commit 812a33a

Browse files
authored
DEV: Remove the legacy widget post menu code (#650)
1 parent bf2a4bd commit 812a33a

File tree

3 files changed

+12
-63
lines changed

3 files changed

+12
-63
lines changed

.discourse-compatibility

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
< 3.5.0.beta2-dev: bf2a4bdb3ea4e26ec493d8dbc1f4cc8680f6c543
12
< 3.5.0.beta1-dev: 698b5be85cc1a31707d528fe0d3c3c07c939c1df
23
< 3.4.0.beta4-dev: 654f197003f9cdf1926b07137fc2214b21c91a79
34
< 3.4.0.beta3-dev: 6472f4593e1a4abbb457288db012ddb10f0b16f5

assets/javascripts/discourse/components/assign-button.gjs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ export default class AssignButton extends Component {
2929
}
3030

3131
@action
32-
acceptAnswer() {
32+
async acceptAnswer() {
3333
if (this.isAssigned) {
34-
unassignPost(this.args.post, this.taskActions);
34+
const post = this.args.post;
35+
36+
await this.taskActions.unassign(post.id, "Post");
37+
delete post.topic.indirectly_assigned_to[post.id];
3538
} else {
36-
assignPost(this.args.post, this.taskActions);
39+
this.taskActions.showAssignModal(this.args.post, {
40+
isAssigned: false,
41+
targetType: "Post",
42+
});
3743
}
3844
}
3945

@@ -51,16 +57,3 @@ export default class AssignButton extends Component {
5157
/>
5258
</template>
5359
}
54-
55-
// TODO (glimmer-post-menu): Remove these exported functions and move the code into the button action after the widget code is removed
56-
export function assignPost(post, taskActions) {
57-
taskActions.showAssignModal(post, {
58-
isAssigned: false,
59-
targetType: "Post",
60-
});
61-
}
62-
63-
export async function unassignPost(post, taskActions) {
64-
await taskActions.unassign(post.id, "Post");
65-
delete post.topic.indirectly_assigned_to[post.id];
66-
}

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

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { hbs } from "ember-cli-htmlbars";
66
import { h } from "virtual-dom";
77
import { renderAvatar } from "discourse/helpers/user-avatar";
88
import discourseComputed from "discourse/lib/decorators";
9-
import { withSilencedDeprecations } from "discourse/lib/deprecated";
109
import getURL from "discourse/lib/get-url";
1110
import { iconHTML, iconNode } from "discourse/lib/icon-library";
1211
import { withPluginApi } from "discourse/lib/plugin-api";
@@ -16,10 +15,7 @@ import { escapeExpression } from "discourse/lib/utilities";
1615
import RawHtml from "discourse/widgets/raw-html";
1716
import RenderGlimmer from "discourse/widgets/render-glimmer";
1817
import { i18n } from "discourse-i18n";
19-
import AssignButton, {
20-
assignPost,
21-
unassignPost,
22-
} from "../components/assign-button";
18+
import AssignButton from "../components/assign-button";
2319
import BulkActionsAssignUser from "../components/bulk-actions/bulk-assign-user";
2420
import EditTopicAssignments from "../components/modal/edit-topic-assignments";
2521
import TopicLevelAssignMenu from "../components/topic-level-assign-menu";
@@ -778,7 +774,7 @@ function initialize(api) {
778774
}
779775

780776
function customizePostMenu(api) {
781-
const transformerRegistered = api.registerValueTransformer(
777+
api.registerValueTransformer(
782778
"post-menu-buttons",
783779
({
784780
value: dag,
@@ -804,47 +800,6 @@ function customizePostMenu(api) {
804800
);
805801
}
806802
);
807-
808-
const silencedKey =
809-
transformerRegistered && "discourse.post-menu-widget-overrides";
810-
811-
withSilencedDeprecations(silencedKey, () => customizeWidgetPostMenu(api));
812-
}
813-
814-
function customizeWidgetPostMenu(api) {
815-
api.addPostMenuButton("assign", (post) => {
816-
if (post.firstPost) {
817-
return;
818-
}
819-
if (post.assigned_to_user || post.assigned_to_group) {
820-
return {
821-
action: "unassignPost",
822-
icon: "user-xmark",
823-
className: "unassign-post",
824-
title: "discourse_assign.unassign_post.title",
825-
position:
826-
post.assigned_to_user?.id === api.getCurrentUser().id
827-
? "first"
828-
: "second-last-hidden",
829-
};
830-
} else {
831-
return {
832-
action: "assignPost",
833-
icon: "user-plus",
834-
className: "assign-post",
835-
title: "discourse_assign.assign_post.title",
836-
position: "second-last-hidden",
837-
};
838-
}
839-
});
840-
841-
api.attachWidgetAction("post", "assignPost", function () {
842-
assignPost(this.model, getOwner(this).lookup("service:task-actions"));
843-
});
844-
845-
api.attachWidgetAction("post", "unassignPost", function () {
846-
unassignPost(this.model, getOwner(this).lookup("service:task-actions"));
847-
});
848803
}
849804

850805
const REGEXP_USERNAME_PREFIX = /^(assigned:)/gi;

0 commit comments

Comments
 (0)