diff --git a/assets/javascripts/discourse/components/solved-unaccept-answer-button.gjs b/assets/javascripts/discourse/components/solved-unaccept-answer-button.gjs index 2c0b862..5f125d5 100644 --- a/assets/javascripts/discourse/components/solved-unaccept-answer-button.gjs +++ b/assets/javascripts/discourse/components/solved-unaccept-answer-button.gjs @@ -1,11 +1,14 @@ import Component from "@glimmer/component"; import { action } from "@ember/object"; import { service } from "@ember/service"; +import { htmlSafe } from "@ember/template"; import DButton from "discourse/components/d-button"; import icon from "discourse/helpers/d-icon"; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; +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 @@ -41,23 +44,61 @@ function unacceptPost(post) { export default class SolvedUnacceptAnswerButton extends Component { @service appEvents; + @service siteSettings; @action unacceptAnswer() { unacceptAnswer(this.args.post, this.appEvents); } + get solvedBy() { + if (!this.siteSettings.show_who_marked_solved) { + return; + } + + const username = this.args.post.topic.accepted_answer.accepter_username; + const name = this.args.post.topic.accepted_answer.accepter_name; + const displayedName = + this.siteSettings.display_name_on_posts && name + ? name + : formatUsername(username); + if (this.args.post.topic.accepted_answer.accepter_username) { + return i18n("solved.marked_solved_by", { + username: displayedName, + username_lower: username, + }); + } + } +