This reverts commit a3c6938cb3
.
This commit is contained in:
parent
e1a0eb6131
commit
51494db236
|
@ -1,57 +0,0 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { service } from "@ember/service";
|
||||
import BasicTopicList from "discourse/components/basic-topic-list";
|
||||
import concatClass from "discourse/helpers/concat-class";
|
||||
import i18n from "discourse-common/helpers/i18n";
|
||||
|
||||
const LIST_ID = "related-topics";
|
||||
|
||||
export default class extends Component {
|
||||
static shouldRender(args) {
|
||||
return args.model.related_topics?.length;
|
||||
}
|
||||
|
||||
@service store;
|
||||
@service moreTopicsPreferenceTracking;
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.moreTopicsPreferenceTracking.registerTopicList({
|
||||
name: i18n("discourse_ai.related_topics.pill"),
|
||||
id: LIST_ID,
|
||||
icon: "discourse-sparkles",
|
||||
});
|
||||
}
|
||||
|
||||
willDestroy() {
|
||||
super.willDestroy(...arguments);
|
||||
this.moreTopicsPreferenceTracking.removeTopicList(LIST_ID);
|
||||
}
|
||||
|
||||
get hidden() {
|
||||
return this.moreTopicsPreferenceTracking.selectedTab !== LIST_ID;
|
||||
}
|
||||
|
||||
get relatedTopics() {
|
||||
return this.args.outletArgs.model.related_topics.map((topic) =>
|
||||
this.store.createRecord("topic", topic)
|
||||
);
|
||||
}
|
||||
|
||||
<template>
|
||||
<div
|
||||
role="complementary"
|
||||
aria-labelledby="related-topics-title"
|
||||
id="related-topics"
|
||||
class={{concatClass "more-topics__list" (if this.hidden "hidden")}}
|
||||
>
|
||||
<h3 id="related-topics-title" class="more-topics__list-title">
|
||||
{{i18n "discourse_ai.related_topics.title"}}
|
||||
</h3>
|
||||
|
||||
<div class="topics">
|
||||
<BasicTopicList @topics={{this.relatedTopics}} />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<div
|
||||
id="related-topics"
|
||||
class="more-topics__list {{if this.hidden 'hidden'}}"
|
||||
role="complementary"
|
||||
aria-labelledby="related-topics-title"
|
||||
{{did-insert this.registerList}}
|
||||
{{will-destroy this.removeList}}
|
||||
>
|
||||
<h3 id="related-topics-title" class="more-topics__list-title">
|
||||
{{i18n "discourse_ai.related_topics.title"}}
|
||||
</h3>
|
||||
<div class="topics">
|
||||
<BasicTopicList @topics={{this.relatedTopics}} />
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,41 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { action, computed } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default class extends Component {
|
||||
static shouldRender(args) {
|
||||
return (args.model.related_topics?.length || 0) > 0;
|
||||
}
|
||||
|
||||
@service store;
|
||||
@service site;
|
||||
@service moreTopicsPreferenceTracking;
|
||||
|
||||
listId = "related-topics";
|
||||
|
||||
@computed("moreTopicsPreferenceTracking.selectedTab")
|
||||
get hidden() {
|
||||
return this.moreTopicsPreferenceTracking.selectedTab !== this.listId;
|
||||
}
|
||||
|
||||
get relatedTopics() {
|
||||
return this.args.outletArgs.model.related_topics.map((topic) =>
|
||||
this.store.createRecord("topic", topic)
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
registerList() {
|
||||
this.moreTopicsPreferenceTracking.registerTopicList({
|
||||
name: I18n.t("discourse_ai.related_topics.pill"),
|
||||
id: this.listId,
|
||||
icon: "discourse-sparkles",
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
removeList() {
|
||||
this.moreTopicsPreferenceTracking.removeTopicList(this.listId);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue