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

Commit 3e40cc3

Browse files
committed
show groups, we lost them
1 parent 8a86c46 commit 3e40cc3

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

assets/javascripts/discourse/components/ai-features-list.gjs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Component from "@glimmer/component";
22
import { concat } from "@ember/helper";
3-
import { gt } from "truth-helpers";
3+
import { action } from "@ember/object";
44
import DButton from "discourse/components/d-button";
55
import { i18n } from "discourse-i18n";
66

@@ -13,6 +13,30 @@ export default class AiFeaturesList extends Component {
1313
});
1414
}
1515

16+
@action
17+
hasGroups(feature) {
18+
return this.groupList(feature).length > 0;
19+
}
20+
21+
@action
22+
groupList(feature) {
23+
const groups = [];
24+
const groupIds = new Set();
25+
if (feature.personas) {
26+
feature.personas.forEach((persona) => {
27+
if (persona.allowed_groups) {
28+
persona.allowed_groups.forEach((group) => {
29+
if (!groupIds.has(group.id)) {
30+
groupIds.add(group.id);
31+
groups.push(group);
32+
}
33+
});
34+
}
35+
});
36+
}
37+
return groups;
38+
}
39+
1640
<template>
1741
<div class="ai-features-list">
1842
{{#each this.sortedModules as |module|}}
@@ -92,12 +116,12 @@ export default class AiFeaturesList extends Component {
92116
{{i18n "discourse_ai.features.no_llm"}}
93117
{{/if}}
94118
</div>
95-
{{#if feature.persona}}
119+
{{#if feature.personas}}
96120
<div class="ai-feature-card__groups">
97121
<span>{{i18n "discourse_ai.features.groups"}}</span>
98-
{{#if (gt feature.persona.allowed_groups.length 0)}}
122+
{{#if (this.hasGroups feature)}}
99123
<ul class="ai-feature-card__item-groups">
100-
{{#each feature.persona.allowed_groups as |group|}}
124+
{{#each (this.groupList feature) as |group|}}
101125
<li>{{group.name}}</li>
102126
{{/each}}
103127
</ul>

spec/system/admin_ai_features_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
ai_features_page.toggle_unconfigured
2929

30-
expect(ai_features_page).to have_listed_modules(5)
30+
# this changes as we add more AI features
31+
expect(ai_features_page).to have_listed_modules(6)
3132
end
3233

3334
it "lists the persona used for the corresponding AI feature" do

0 commit comments

Comments
 (0)