DEV: Remove the legacy widget post menu code (#650)
This commit is contained in:
parent
bf2a4bdb3e
commit
812a33a085
|
|
@ -1,3 +1,4 @@
|
||||||
|
< 3.5.0.beta2-dev: bf2a4bdb3ea4e26ec493d8dbc1f4cc8680f6c543
|
||||||
< 3.5.0.beta1-dev: 698b5be85cc1a31707d528fe0d3c3c07c939c1df
|
< 3.5.0.beta1-dev: 698b5be85cc1a31707d528fe0d3c3c07c939c1df
|
||||||
< 3.4.0.beta4-dev: 654f197003f9cdf1926b07137fc2214b21c91a79
|
< 3.4.0.beta4-dev: 654f197003f9cdf1926b07137fc2214b21c91a79
|
||||||
< 3.4.0.beta3-dev: 6472f4593e1a4abbb457288db012ddb10f0b16f5
|
< 3.4.0.beta3-dev: 6472f4593e1a4abbb457288db012ddb10f0b16f5
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,17 @@ export default class AssignButton extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
acceptAnswer() {
|
async acceptAnswer() {
|
||||||
if (this.isAssigned) {
|
if (this.isAssigned) {
|
||||||
unassignPost(this.args.post, this.taskActions);
|
const post = this.args.post;
|
||||||
|
|
||||||
|
await this.taskActions.unassign(post.id, "Post");
|
||||||
|
delete post.topic.indirectly_assigned_to[post.id];
|
||||||
} else {
|
} else {
|
||||||
assignPost(this.args.post, this.taskActions);
|
this.taskActions.showAssignModal(this.args.post, {
|
||||||
|
isAssigned: false,
|
||||||
|
targetType: "Post",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,16 +57,3 @@ export default class AssignButton extends Component {
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO (glimmer-post-menu): Remove these exported functions and move the code into the button action after the widget code is removed
|
|
||||||
export function assignPost(post, taskActions) {
|
|
||||||
taskActions.showAssignModal(post, {
|
|
||||||
isAssigned: false,
|
|
||||||
targetType: "Post",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function unassignPost(post, taskActions) {
|
|
||||||
await taskActions.unassign(post.id, "Post");
|
|
||||||
delete post.topic.indirectly_assigned_to[post.id];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import { hbs } from "ember-cli-htmlbars";
|
||||||
import { h } from "virtual-dom";
|
import { h } from "virtual-dom";
|
||||||
import { renderAvatar } from "discourse/helpers/user-avatar";
|
import { renderAvatar } from "discourse/helpers/user-avatar";
|
||||||
import discourseComputed from "discourse/lib/decorators";
|
import discourseComputed from "discourse/lib/decorators";
|
||||||
import { withSilencedDeprecations } from "discourse/lib/deprecated";
|
|
||||||
import getURL from "discourse/lib/get-url";
|
import getURL from "discourse/lib/get-url";
|
||||||
import { iconHTML, iconNode } from "discourse/lib/icon-library";
|
import { iconHTML, iconNode } from "discourse/lib/icon-library";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
|
|
@ -16,10 +15,7 @@ import { escapeExpression } from "discourse/lib/utilities";
|
||||||
import RawHtml from "discourse/widgets/raw-html";
|
import RawHtml from "discourse/widgets/raw-html";
|
||||||
import RenderGlimmer from "discourse/widgets/render-glimmer";
|
import RenderGlimmer from "discourse/widgets/render-glimmer";
|
||||||
import { i18n } from "discourse-i18n";
|
import { i18n } from "discourse-i18n";
|
||||||
import AssignButton, {
|
import AssignButton from "../components/assign-button";
|
||||||
assignPost,
|
|
||||||
unassignPost,
|
|
||||||
} from "../components/assign-button";
|
|
||||||
import BulkActionsAssignUser from "../components/bulk-actions/bulk-assign-user";
|
import BulkActionsAssignUser from "../components/bulk-actions/bulk-assign-user";
|
||||||
import EditTopicAssignments from "../components/modal/edit-topic-assignments";
|
import EditTopicAssignments from "../components/modal/edit-topic-assignments";
|
||||||
import TopicLevelAssignMenu from "../components/topic-level-assign-menu";
|
import TopicLevelAssignMenu from "../components/topic-level-assign-menu";
|
||||||
|
|
@ -778,7 +774,7 @@ function initialize(api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function customizePostMenu(api) {
|
function customizePostMenu(api) {
|
||||||
const transformerRegistered = api.registerValueTransformer(
|
api.registerValueTransformer(
|
||||||
"post-menu-buttons",
|
"post-menu-buttons",
|
||||||
({
|
({
|
||||||
value: dag,
|
value: dag,
|
||||||
|
|
@ -804,47 +800,6 @@ function customizePostMenu(api) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const silencedKey =
|
|
||||||
transformerRegistered && "discourse.post-menu-widget-overrides";
|
|
||||||
|
|
||||||
withSilencedDeprecations(silencedKey, () => customizeWidgetPostMenu(api));
|
|
||||||
}
|
|
||||||
|
|
||||||
function customizeWidgetPostMenu(api) {
|
|
||||||
api.addPostMenuButton("assign", (post) => {
|
|
||||||
if (post.firstPost) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (post.assigned_to_user || post.assigned_to_group) {
|
|
||||||
return {
|
|
||||||
action: "unassignPost",
|
|
||||||
icon: "user-xmark",
|
|
||||||
className: "unassign-post",
|
|
||||||
title: "discourse_assign.unassign_post.title",
|
|
||||||
position:
|
|
||||||
post.assigned_to_user?.id === api.getCurrentUser().id
|
|
||||||
? "first"
|
|
||||||
: "second-last-hidden",
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
action: "assignPost",
|
|
||||||
icon: "user-plus",
|
|
||||||
className: "assign-post",
|
|
||||||
title: "discourse_assign.assign_post.title",
|
|
||||||
position: "second-last-hidden",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
api.attachWidgetAction("post", "assignPost", function () {
|
|
||||||
assignPost(this.model, getOwner(this).lookup("service:task-actions"));
|
|
||||||
});
|
|
||||||
|
|
||||||
api.attachWidgetAction("post", "unassignPost", function () {
|
|
||||||
unassignPost(this.model, getOwner(this).lookup("service:task-actions"));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const REGEXP_USERNAME_PREFIX = /^(assigned:)/gi;
|
const REGEXP_USERNAME_PREFIX = /^(assigned:)/gi;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue