Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 3351306

Browse files
committed
DEV: Updates
1 parent 7320f86 commit 3351306

File tree

11 files changed

+355
-474
lines changed

11 files changed

+355
-474
lines changed

assets/javascripts/discourse/components/ai-split-topic-suggester.gjs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ export default class AiSplitTopicSuggester extends Component {
5454
suggestions.includes(item.name.toLowerCase())
5555
);
5656
this.suggestions = suggestedCategories;
57-
} else {
58-
this.suggestions = result.assistant.map((s) => s.name);
57+
} else if (this.args.mode === this.SUGGESTION_TYPES.tag) {
58+
this.suggestions = result.assistant.map((s) => {
59+
return {
60+
name: s.name,
61+
count: s.count,
62+
};
63+
});
5964
}
6065
})
6166
.catch(popupAjaxError)
@@ -132,6 +137,17 @@ export default class AiSplitTopicSuggester extends Component {
132137
{{on "click" (fn this.applySuggestion suggestion menu)}}
133138
>
134139
{{categoryBadge suggestion}}
140+
<span class="topic-count">x
141+
{{suggestion.totalTopicCount}}</span>
142+
</li>
143+
{{else if (eq @mode "suggest_tags")}}
144+
<li data-name={{suggestion.name}} data-value={{index}}>
145+
<DButton
146+
@translatedLabel={{suggestion.name}}
147+
@action={{fn this.applySuggestion suggestion.name menu}}
148+
>
149+
<span class="topic-count">x{{suggestion.count}}</span>
150+
</DButton>
135151
</li>
136152
{{else}}
137153
<li data-name={{suggestion}} data-value={{index}}>

assets/javascripts/discourse/components/ai-suggestion-dropdown.gjs

Lines changed: 0 additions & 251 deletions
This file was deleted.

assets/javascripts/discourse/components/suggestion-menus/ai-category-suggester.gjs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { tracked } from "@glimmer/tracking";
33
import { fn } from "@ember/helper";
44
import { on } from "@ember/modifier";
55
import { action } from "@ember/object";
6-
import { inject as service } from "@ember/service";
6+
import { service } from "@ember/service";
77
import DButton from "discourse/components/d-button";
88
import DropdownMenu from "discourse/components/dropdown-menu";
99
import categoryBadge from "discourse/helpers/category-badge";
1010
import { ajax } from "discourse/lib/ajax";
1111
import { popupAjaxError } from "discourse/lib/ajax-error";
1212
import i18n from "discourse-common/helpers/i18n";
1313
import DMenu from "float-kit/components/d-menu";
14+
import { MIN_CHARACTER_COUNT } from "../../lib/ai-helper-suggestions";
1415

1516
export default class AiCategorySuggester extends Component {
1617
@service siteSettings;
@@ -19,23 +20,9 @@ export default class AiCategorySuggester extends Component {
1920
@tracked untriggers = [];
2021
@tracked triggerIcon = "discourse-sparkles";
2122

22-
get referenceText() {
23-
if (this.args.composer?.reply) {
24-
return this.args.composer.reply;
25-
}
26-
27-
console.log(this.args);
28-
ajax(`/raw/${this.args.topic.id}/1.json`).then((response) => {
29-
console.log(response);
30-
});
31-
32-
return "abcdefhg";
33-
}
34-
3523
get showSuggestionButton() {
36-
const MIN_CHARACTER_COUNT = 40;
3724
const composerFields = document.querySelector(".composer-fields");
38-
const showTrigger = this.referenceText.length > MIN_CHARACTER_COUNT;
25+
const showTrigger = this.args.composer.reply?.length > MIN_CHARACTER_COUNT;
3926

4027
if (composerFields) {
4128
if (showTrigger) {
@@ -127,7 +114,7 @@ export default class AiCategorySuggester extends Component {
127114
>
128115
<div class="category-status">
129116
{{categoryBadge suggestion}}
130-
<span class="topic-count" aria-label="">x
117+
<span class="topic-count">x
131118
{{suggestion.topicCount}}</span>
132119
</div>
133120
</DButton>

0 commit comments

Comments
 (0)