mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-07-28 23:53:26 +00:00
DEV: Add gjs implementation of solved topic status (#327)
This commit is contained in:
parent
3f724bf311
commit
a73bfa228e
@ -1,3 +1,4 @@
|
|||||||
|
< 3.4.0.beta4-dev: 3f724bf3114cc7877fa757bc8035f13a7390c739
|
||||||
< 3.4.0.beta2-dev: 1bbdfd8f5681171dc3f0e9ea93cd56997dc7938a
|
< 3.4.0.beta2-dev: 1bbdfd8f5681171dc3f0e9ea93cd56997dc7938a
|
||||||
< 3.4.0.beta1-dev: dc1ef92be23332a54854751a23b9029463584845
|
< 3.4.0.beta1-dev: dc1ef92be23332a54854751a23b9029463584845
|
||||||
< 3.3.0.beta2-dev: a18ce6d712fafed286bcc99543dd173110c6dfb8
|
< 3.3.0.beta2-dev: a18ce6d712fafed286bcc99543dd173110c6dfb8
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
import Component from "@glimmer/component";
|
||||||
|
import { service } from "@ember/service";
|
||||||
|
import { and } from "truth-helpers";
|
||||||
|
import icon from "discourse/helpers/d-icon";
|
||||||
|
import { i18n } from "discourse-i18n";
|
||||||
|
|
||||||
|
export default class SolvedStatus extends Component {
|
||||||
|
@service siteSettings;
|
||||||
|
|
||||||
|
<template>
|
||||||
|
{{~#if @outletArgs.topic.has_accepted_answer~}}
|
||||||
|
<span
|
||||||
|
title={{i18n "topic_statuses.solved.help"}}
|
||||||
|
class="topic-status"
|
||||||
|
>{{icon "far-square-check"}}</span>
|
||||||
|
{{~else if
|
||||||
|
(and
|
||||||
|
@outletArgs.topic.can_have_answer
|
||||||
|
this.siteSettings.solved_enabled
|
||||||
|
this.siteSettings.empty_box_on_unsolved
|
||||||
|
)
|
||||||
|
~}}
|
||||||
|
<span
|
||||||
|
title={{i18n "solved.has_no_accepted_answer"}}
|
||||||
|
class="topic-status"
|
||||||
|
>{{icon "far-square"}}</span>
|
||||||
|
{{~/if~}}
|
||||||
|
</template>
|
||||||
|
}
|
@ -1,10 +1,9 @@
|
|||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
import TopicStatusIcons from "discourse/helpers/topic-status-icons";
|
import discourseComputed from "discourse/lib/decorators";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import { formatUsername } from "discourse/lib/utilities";
|
import { formatUsername } from "discourse/lib/utilities";
|
||||||
import Topic from "discourse/models/topic";
|
import Topic from "discourse/models/topic";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import TopicStatus from "discourse/raw-views/topic-status";
|
|
||||||
import PostCooked from "discourse/widgets/post-cooked";
|
import PostCooked from "discourse/widgets/post-cooked";
|
||||||
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
||||||
import { iconHTML, iconNode } from "discourse-common/lib/icon-library";
|
import { iconHTML, iconNode } from "discourse-common/lib/icon-library";
|
||||||
@ -19,12 +18,6 @@ import SolvedUnacceptAnswerButton, {
|
|||||||
function initializeWithApi(api) {
|
function initializeWithApi(api) {
|
||||||
customizePostMenu(api);
|
customizePostMenu(api);
|
||||||
|
|
||||||
TopicStatusIcons.addObject([
|
|
||||||
"has_accepted_answer",
|
|
||||||
"far-square-check",
|
|
||||||
"solved",
|
|
||||||
]);
|
|
||||||
|
|
||||||
api.includePostAttributes(
|
api.includePostAttributes(
|
||||||
"can_accept_answer",
|
"can_accept_answer",
|
||||||
"can_unaccept_answer",
|
"can_unaccept_answer",
|
||||||
@ -205,9 +198,27 @@ export default {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
TopicStatus.reopen({
|
withPluginApi("2.0.0", (api) => {
|
||||||
statuses: computed(function () {
|
withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
|
||||||
const results = this._super(...arguments);
|
let topicStatusIcons;
|
||||||
|
try {
|
||||||
|
topicStatusIcons =
|
||||||
|
require("discourse/helpers/topic-status-icons").default;
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
topicStatusIcons?.addObject([
|
||||||
|
"has_accepted_answer",
|
||||||
|
"far-square-check",
|
||||||
|
"solved",
|
||||||
|
]);
|
||||||
|
|
||||||
|
api.modifyClass(
|
||||||
|
"raw-view:topic-status",
|
||||||
|
(Superclass) =>
|
||||||
|
class extends Superclass {
|
||||||
|
@discourseComputed("topic.{has_accepted_answer,can_have_answer}")
|
||||||
|
statuses() {
|
||||||
|
const results = super.statuses;
|
||||||
|
|
||||||
if (this.topic.has_accepted_answer) {
|
if (this.topic.has_accepted_answer) {
|
||||||
results.push({
|
results.push({
|
||||||
@ -229,8 +240,12 @@ export default {
|
|||||||
icon: "far-square",
|
icon: "far-square",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}),
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
withPluginApi("1.34.0", initializeWithApi);
|
withPluginApi("1.34.0", initializeWithApi);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user