11import Component from " @glimmer/component" ;
22import { tracked } from " @glimmer/tracking" ;
3- import { fn , hash } from " @ember/helper" ;
3+ import { array , fn , hash } from " @ember/helper" ;
44import { action } from " @ember/object" ;
55import { service } from " @ember/service" ;
6+ import { gt } from " truth-helpers" ;
67import Form from " discourse/components/form" ;
78import { popupAjaxError } from " discourse/lib/ajax-error" ;
89import { i18n } from " discourse-i18n" ;
@@ -28,12 +29,15 @@ export default class AiToolEditorForm extends Component {
2829 ];
2930
3031 get formData () {
32+ // TODO: add enumData only if parameters.enum is true
3133 return {
3234 name: this .args .editingModel .name || " " ,
3335 tool_name: this .args .editingModel .tool_name || " " ,
3436 description: this .args .editingModel .description || " " ,
3537 summary: this .args .editingModel .summary || " " ,
36- parameters: this .args .editingModel .parameters || [],
38+ parameters: this .args .editingModel .parameters || [
39+ { enumData: [" foo" , " bar" ] },
40+ ],
3741 script: this .args .editingModel .script || " " ,
3842 rag_uploads: this .args .editingModel .rag_uploads || [],
3943 };
@@ -237,7 +241,38 @@ export default class AiToolEditorForm extends Component {
237241 </row.Col >
238242
239243 {{#if collectionData.enum }}
240- HANDLE IS ENUM
244+ <row.Col @ size ={{ 8 }} >
245+ <collection.Collection @ name =" enumData" as | child childIndex | >
246+ <form.Container class =" ai-tool-parameter__enum-values" >
247+ <child.Field
248+ @ name =" enumValue"
249+ @ title ={{i18n " discourse_ai.tools.enum_value" }}
250+ as | field |
251+ >
252+ <field.Input />
253+ </child.Field >
254+
255+ {{#if ( gt collectionData.enumData.length 1 ) }}
256+ <form.Button
257+ class =" btn-danger"
258+ @ icon =" trash-can"
259+ @ action ={{fn child.remove childIndex }}
260+ />
261+ {{/if }}
262+
263+ <form.Button
264+ @ icon =" plus"
265+ @ label =" discourse_ai.tools.add_enum_value"
266+ @ action ={{fn
267+ form.addItemToCollection
268+ " enumData"
269+ ( array " " )
270+ }}
271+ />
272+ </form.Container >
273+
274+ </collection.Collection >
275+ </row.Col >
241276 {{/if }}
242277 </form.Row >
243278 <form.Row as | row | >
0 commit comments