11import Component from " @glimmer/component" ;
22import { concat } from " @ember/helper" ;
3- import { gt } from " truth-helpers " ;
3+ import { action } from " @ember/object " ;
44import DButton from " discourse/components/d-button" ;
55import { 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 >
0 commit comments