1
1
import Component from " @glimmer/component" ;
2
- import { concat } from " @ember/helper" ;
2
+ import { concat , fn } from " @ember/helper" ;
3
+ import { on } from " @ember/modifier" ;
4
+ import { action } from " @ember/object" ;
3
5
import { LinkTo } from " @ember/routing" ;
6
+ import DToggleSwitch from " discourse/components/d-toggle-switch" ;
7
+ import { popupAjaxError } from " discourse/lib/ajax-error" ;
4
8
import icon from " discourse-common/helpers/d-icon" ;
5
9
import i18n from " discourse-common/helpers/i18n" ;
6
10
import I18n from " discourse-i18n" ;
@@ -11,6 +15,21 @@ export default class AiLlmsListEditor extends Component {
11
15
return this .args .llms .length !== 0 ;
12
16
}
13
17
18
+ @action
19
+ async toggleEnabledChatBot (llm ) {
20
+ const oldValue = llm .enabled_chat_bot ;
21
+ const newValue = ! oldValue;
22
+ try {
23
+ llm .set (" enabled_chat_bot" , newValue);
24
+ await llm .update ({
25
+ enabled_chat_bot: newValue,
26
+ });
27
+ } catch (err) {
28
+ llm .set (" enabled_chat_bot" , oldValue);
29
+ popupAjaxError (err);
30
+ }
31
+ }
32
+
14
33
<template >
15
34
<section class =" ai-llms-list-editor admin-detail pull-left" >
16
35
{{#if @ currentLlm }}
@@ -35,6 +54,7 @@ export default class AiLlmsListEditor extends Component {
35
54
<tr >
36
55
<th >{{i18n " discourse_ai.llms.display_name" }} </th >
37
56
<th >{{i18n " discourse_ai.llms.provider" }} </th >
57
+ <th >{{i18n " discourse_ai.llms.enabled_chat_bot" }} </th >
38
58
<th ></th >
39
59
</tr >
40
60
</thead >
@@ -45,6 +65,12 @@ export default class AiLlmsListEditor extends Component {
45
65
<td >{{i18n
46
66
( concat " discourse_ai.llms.providers." llm.provider )
47
67
}} </td >
68
+ <td >
69
+ <DToggleSwitch
70
+ @ state ={{llm.enabled_chat_bot }}
71
+ {{on " click" ( fn this . toggleEnabledChatBot llm ) }}
72
+ />
73
+ </td >
48
74
<td >
49
75
<LinkTo
50
76
@ route =" adminPlugins.show.discourse-ai-llms.show"
0 commit comments