Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ export default class SolvedAcceptAnswerButton extends Component {

@action
acceptAnswer() {
acceptAnswer(this.args.post, this.appEvents, this.currentUser);
const post = this.args.post;

acceptPost(post, this.currentUser);

this.appEvents.trigger("discourse-solved:solution-toggled", post);

post.get("topic.postStream.posts").forEach((p) => {
p.set("topic_accepted_answer", true);
this.appEvents.trigger("post-stream:refresh", { id: p.id });
});
}

<template>
Expand All @@ -34,18 +43,6 @@ export default class SolvedAcceptAnswerButton extends Component {
</template>
}

export function acceptAnswer(post, appEvents, acceptingUser) {
// TODO (glimmer-post-menu): Remove this exported function and move the code into the button action after the widget code is removed
acceptPost(post, acceptingUser);

appEvents.trigger("discourse-solved:solution-toggled", post);

post.get("topic.postStream.posts").forEach((p) => {
p.set("topic_accepted_answer", true);
appEvents.trigger("post-stream:refresh", { id: p.id });
});
}

function acceptPost(post, acceptingUser) {
const topic = post.topic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ import { formatUsername } from "discourse/lib/utilities";
import { i18n } from "discourse-i18n";
import DTooltip from "float-kit/components/d-tooltip";

export function unacceptAnswer(post, appEvents) {
// TODO (glimmer-post-menu): Remove this exported function and move the code into the button action after the widget code is removed
unacceptPost(post);

appEvents.trigger("discourse-solved:solution-toggled", post);

post.get("topic.postStream.posts").forEach((p) => {
p.set("topic_accepted_answer", false);
appEvents.trigger("post-stream:refresh", { id: p.id });
});
}

function unacceptPost(post) {
if (!post.can_unaccept_answer) {
return;
Expand All @@ -48,7 +36,16 @@ export default class SolvedUnacceptAnswerButton extends Component {

@action
unacceptAnswer() {
unacceptAnswer(this.args.post, this.appEvents);
const post = this.args.post;

unacceptPost(post);

this.appEvents.trigger("discourse-solved:solution-toggled", post);

post.get("topic.postStream.posts").forEach((p) => {
p.set("topic_accepted_answer", false);
this.appEvents.trigger("post-stream:refresh", { id: p.id });
});
}

get solvedBy() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { computed } from "@ember/object";
import discourseComputed from "discourse/lib/decorators";
import { withSilencedDeprecations } from "discourse/lib/deprecated";
import { iconHTML, iconNode } from "discourse/lib/icon-library";
import { iconHTML } from "discourse/lib/icon-library";
import { withPluginApi } from "discourse/lib/plugin-api";
import { formatUsername } from "discourse/lib/utilities";
import Topic from "discourse/models/topic";
Expand Down Expand Up @@ -72,7 +72,7 @@ function initializeWithApi(api) {
}

function customizePostMenu(api) {
const transformerRegistered = api.registerValueTransformer(
api.registerValueTransformer(
"post-menu-buttons",
({
value: dag,
Expand Down Expand Up @@ -109,59 +109,6 @@ function customizePostMenu(api) {
);
}
);

const silencedKey =
transformerRegistered && "discourse.post-menu-widget-overrides";

withSilencedDeprecations(silencedKey, () => customizeWidgetPostMenu(api));
}

function customizeWidgetPostMenu(api) {
const currentUser = api.getCurrentUser();

api.addPostMenuButton("solved", (attrs) => {
if (attrs.can_accept_answer) {
const isOp = currentUser?.id === attrs.topicCreatedById;

return {
action: "acceptAnswer",
icon: "far-square-check",
className: "unaccepted",
title: "solved.accept_answer",
label: isOp ? "solved.solution" : null,
position: attrs.topic_accepted_answer ? "second-last-hidden" : "first",
};
} else if (attrs.accepted_answer) {
if (attrs.can_unaccept_answer) {
return {
action: "unacceptAnswer",
icon: "square-check",
title: "solved.unaccept_answer",
className: "accepted fade-out",
position: "first",
label: "solved.solution",
};
} else {
return {
className: "hidden",
disabled: "true",
position: "first",
beforeButton(h) {
return h(
"span.accepted-text",
{
title: i18n("solved.accepted_description"),
},
[
h("span", iconNode("check")),
h("span.accepted-label", i18n("solved.solution")),
]
);
},
};
}
}
});
}

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ acceptance(
needs.user({ admin: true });

needs.settings({
glimmer_post_menu_mode: "enabled",
solved_enabled: true,
allow_solved_on_all_topics: true,
});
Expand Down

This file was deleted.