@truedat/ai 7.3.3 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/api.js +5 -0
- package/src/components/TranslationModal.js +613 -0
- package/src/components/__tests__/TranslationModal.spec.js +351 -0
- package/src/components/constants.js +4 -0
- package/src/components/index.js +2 -1
- package/src/components/prompts/PromptEditor.js +33 -8
- package/src/components/prompts/__tests__/PromptEditor.spec.js +12 -0
- package/src/components/prompts/__tests__/__snapshots__/PromptEditor.spec.js.snap +296 -0
- package/src/hooks/useTranslations.js +18 -0
- package/src/styles/translationModal.less +5 -0
|
@@ -1,5 +1,245 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`<PromptEditor /> matches snapshot for translation resource type 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<form
|
|
6
|
+
class="ui form"
|
|
7
|
+
>
|
|
8
|
+
<h3
|
|
9
|
+
class="ui dividing header"
|
|
10
|
+
>
|
|
11
|
+
prompt1
|
|
12
|
+
</h3>
|
|
13
|
+
<div
|
|
14
|
+
class="required field"
|
|
15
|
+
>
|
|
16
|
+
<label>
|
|
17
|
+
prompts.form.name
|
|
18
|
+
</label>
|
|
19
|
+
<div
|
|
20
|
+
class="ui input"
|
|
21
|
+
>
|
|
22
|
+
<input
|
|
23
|
+
autocomplete="off"
|
|
24
|
+
placeholder="prompts.form.name"
|
|
25
|
+
required=""
|
|
26
|
+
type="text"
|
|
27
|
+
value="prompt1"
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<div
|
|
32
|
+
class="required field"
|
|
33
|
+
>
|
|
34
|
+
<label>
|
|
35
|
+
prompts.form.resource_type
|
|
36
|
+
</label>
|
|
37
|
+
<div
|
|
38
|
+
aria-expanded="false"
|
|
39
|
+
class="ui selection dropdown"
|
|
40
|
+
role="listbox"
|
|
41
|
+
tabindex="0"
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
aria-atomic="true"
|
|
45
|
+
aria-live="polite"
|
|
46
|
+
class="divider text"
|
|
47
|
+
role="alert"
|
|
48
|
+
>
|
|
49
|
+
resourceMappings.resourceType.translation
|
|
50
|
+
</div>
|
|
51
|
+
<i
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
class="dropdown icon"
|
|
54
|
+
/>
|
|
55
|
+
<div
|
|
56
|
+
class="menu transition"
|
|
57
|
+
>
|
|
58
|
+
<div
|
|
59
|
+
aria-checked="false"
|
|
60
|
+
aria-selected="false"
|
|
61
|
+
class="item"
|
|
62
|
+
role="option"
|
|
63
|
+
style="pointer-events: all;"
|
|
64
|
+
>
|
|
65
|
+
<span
|
|
66
|
+
class="text"
|
|
67
|
+
>
|
|
68
|
+
resourceMappings.resourceType.data_structure
|
|
69
|
+
</span>
|
|
70
|
+
</div>
|
|
71
|
+
<div
|
|
72
|
+
aria-checked="false"
|
|
73
|
+
aria-selected="false"
|
|
74
|
+
class="item"
|
|
75
|
+
role="option"
|
|
76
|
+
style="pointer-events: all;"
|
|
77
|
+
>
|
|
78
|
+
<span
|
|
79
|
+
class="text"
|
|
80
|
+
>
|
|
81
|
+
resourceMappings.resourceType.business_concept
|
|
82
|
+
</span>
|
|
83
|
+
</div>
|
|
84
|
+
<div
|
|
85
|
+
aria-checked="true"
|
|
86
|
+
aria-selected="true"
|
|
87
|
+
class="active selected item"
|
|
88
|
+
role="option"
|
|
89
|
+
style="pointer-events: all;"
|
|
90
|
+
>
|
|
91
|
+
<span
|
|
92
|
+
class="text"
|
|
93
|
+
>
|
|
94
|
+
resourceMappings.resourceType.translation
|
|
95
|
+
</span>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
<div
|
|
101
|
+
class="required field"
|
|
102
|
+
data-tooltip="Language is disabled for translations type prompts"
|
|
103
|
+
>
|
|
104
|
+
<label>
|
|
105
|
+
prompts.form.language
|
|
106
|
+
</label>
|
|
107
|
+
<div
|
|
108
|
+
aria-disabled="true"
|
|
109
|
+
aria-expanded="false"
|
|
110
|
+
class="ui disabled selection dropdown"
|
|
111
|
+
role="listbox"
|
|
112
|
+
tabindex="-1"
|
|
113
|
+
>
|
|
114
|
+
<i
|
|
115
|
+
aria-hidden="true"
|
|
116
|
+
class="dropdown icon"
|
|
117
|
+
/>
|
|
118
|
+
<div
|
|
119
|
+
class="menu transition"
|
|
120
|
+
>
|
|
121
|
+
<div
|
|
122
|
+
aria-checked="false"
|
|
123
|
+
aria-selected="true"
|
|
124
|
+
class="selected item"
|
|
125
|
+
role="option"
|
|
126
|
+
style="pointer-events: all;"
|
|
127
|
+
>
|
|
128
|
+
<span
|
|
129
|
+
class="text"
|
|
130
|
+
>
|
|
131
|
+
es
|
|
132
|
+
</span>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
<div
|
|
138
|
+
class="required field"
|
|
139
|
+
>
|
|
140
|
+
<label>
|
|
141
|
+
prompts.form.system_prompt
|
|
142
|
+
</label>
|
|
143
|
+
<textarea
|
|
144
|
+
autocomplete="off"
|
|
145
|
+
placeholder="prompts.form.system_prompt"
|
|
146
|
+
required=""
|
|
147
|
+
rows="3"
|
|
148
|
+
>
|
|
149
|
+
system_prompt
|
|
150
|
+
</textarea>
|
|
151
|
+
</div>
|
|
152
|
+
<div
|
|
153
|
+
class="required field"
|
|
154
|
+
>
|
|
155
|
+
<label>
|
|
156
|
+
prompts.form.user_prompt_template
|
|
157
|
+
</label>
|
|
158
|
+
<textarea
|
|
159
|
+
autocomplete="off"
|
|
160
|
+
placeholder="prompts.form.user_prompt_template"
|
|
161
|
+
required=""
|
|
162
|
+
rows="3"
|
|
163
|
+
>
|
|
164
|
+
user_prompt
|
|
165
|
+
</textarea>
|
|
166
|
+
</div>
|
|
167
|
+
<div
|
|
168
|
+
class="required field"
|
|
169
|
+
>
|
|
170
|
+
<label>
|
|
171
|
+
prompts.form.provider
|
|
172
|
+
</label>
|
|
173
|
+
<div
|
|
174
|
+
aria-expanded="false"
|
|
175
|
+
class="ui selection dropdown"
|
|
176
|
+
role="listbox"
|
|
177
|
+
tabindex="0"
|
|
178
|
+
>
|
|
179
|
+
<div
|
|
180
|
+
aria-atomic="true"
|
|
181
|
+
aria-live="polite"
|
|
182
|
+
class="divider text"
|
|
183
|
+
role="alert"
|
|
184
|
+
>
|
|
185
|
+
Provider1
|
|
186
|
+
</div>
|
|
187
|
+
<i
|
|
188
|
+
aria-hidden="true"
|
|
189
|
+
class="dropdown icon"
|
|
190
|
+
/>
|
|
191
|
+
<div
|
|
192
|
+
class="menu transition"
|
|
193
|
+
>
|
|
194
|
+
<div
|
|
195
|
+
aria-checked="true"
|
|
196
|
+
aria-selected="true"
|
|
197
|
+
class="active selected item"
|
|
198
|
+
role="option"
|
|
199
|
+
style="pointer-events: all;"
|
|
200
|
+
>
|
|
201
|
+
<span
|
|
202
|
+
class="text"
|
|
203
|
+
>
|
|
204
|
+
Provider1
|
|
205
|
+
</span>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
<div
|
|
211
|
+
class="ui hidden divider"
|
|
212
|
+
/>
|
|
213
|
+
<div
|
|
214
|
+
class="ui right aligned container"
|
|
215
|
+
>
|
|
216
|
+
<button
|
|
217
|
+
class="ui primary disabled button"
|
|
218
|
+
disabled=""
|
|
219
|
+
tabindex="-1"
|
|
220
|
+
>
|
|
221
|
+
actions.save
|
|
222
|
+
</button>
|
|
223
|
+
<button
|
|
224
|
+
class="ui primary button"
|
|
225
|
+
>
|
|
226
|
+
actions.set_active
|
|
227
|
+
</button>
|
|
228
|
+
<button
|
|
229
|
+
class="ui button"
|
|
230
|
+
>
|
|
231
|
+
actions.cancel
|
|
232
|
+
</button>
|
|
233
|
+
<button
|
|
234
|
+
class="ui red button"
|
|
235
|
+
>
|
|
236
|
+
actions.delete
|
|
237
|
+
</button>
|
|
238
|
+
</div>
|
|
239
|
+
</form>
|
|
240
|
+
</div>
|
|
241
|
+
`;
|
|
242
|
+
|
|
3
243
|
exports[`<PromptEditor /> matches snapshot without onDelete 1`] = `
|
|
4
244
|
<div>
|
|
5
245
|
<form
|
|
@@ -81,6 +321,19 @@ exports[`<PromptEditor /> matches snapshot without onDelete 1`] = `
|
|
|
81
321
|
resourceMappings.resourceType.business_concept
|
|
82
322
|
</span>
|
|
83
323
|
</div>
|
|
324
|
+
<div
|
|
325
|
+
aria-checked="false"
|
|
326
|
+
aria-selected="false"
|
|
327
|
+
class="item"
|
|
328
|
+
role="option"
|
|
329
|
+
style="pointer-events: all;"
|
|
330
|
+
>
|
|
331
|
+
<span
|
|
332
|
+
class="text"
|
|
333
|
+
>
|
|
334
|
+
resourceMappings.resourceType.translation
|
|
335
|
+
</span>
|
|
336
|
+
</div>
|
|
84
337
|
</div>
|
|
85
338
|
</div>
|
|
86
339
|
</div>
|
|
@@ -91,6 +344,7 @@ exports[`<PromptEditor /> matches snapshot without onDelete 1`] = `
|
|
|
91
344
|
prompts.form.language
|
|
92
345
|
</label>
|
|
93
346
|
<div
|
|
347
|
+
aria-disabled="false"
|
|
94
348
|
aria-expanded="false"
|
|
95
349
|
class="ui selection dropdown"
|
|
96
350
|
role="listbox"
|
|
@@ -303,6 +557,19 @@ exports[`<PromptEditor /> matches the latest snapshot 1`] = `
|
|
|
303
557
|
resourceMappings.resourceType.business_concept
|
|
304
558
|
</span>
|
|
305
559
|
</div>
|
|
560
|
+
<div
|
|
561
|
+
aria-checked="false"
|
|
562
|
+
aria-selected="false"
|
|
563
|
+
class="item"
|
|
564
|
+
role="option"
|
|
565
|
+
style="pointer-events: all;"
|
|
566
|
+
>
|
|
567
|
+
<span
|
|
568
|
+
class="text"
|
|
569
|
+
>
|
|
570
|
+
resourceMappings.resourceType.translation
|
|
571
|
+
</span>
|
|
572
|
+
</div>
|
|
306
573
|
</div>
|
|
307
574
|
</div>
|
|
308
575
|
</div>
|
|
@@ -313,6 +580,7 @@ exports[`<PromptEditor /> matches the latest snapshot 1`] = `
|
|
|
313
580
|
prompts.form.language
|
|
314
581
|
</label>
|
|
315
582
|
<div
|
|
583
|
+
aria-disabled="false"
|
|
316
584
|
aria-expanded="false"
|
|
317
585
|
class="ui selection dropdown"
|
|
318
586
|
role="listbox"
|
|
@@ -528,6 +796,19 @@ exports[`<PromptEditor /> test cancel button with confirm 1`] = `
|
|
|
528
796
|
resourceMappings.resourceType.business_concept
|
|
529
797
|
</span>
|
|
530
798
|
</div>
|
|
799
|
+
<div
|
|
800
|
+
aria-checked="false"
|
|
801
|
+
aria-selected="false"
|
|
802
|
+
class="item"
|
|
803
|
+
role="option"
|
|
804
|
+
style="pointer-events: all;"
|
|
805
|
+
>
|
|
806
|
+
<span
|
|
807
|
+
class="text"
|
|
808
|
+
>
|
|
809
|
+
resourceMappings.resourceType.translation
|
|
810
|
+
</span>
|
|
811
|
+
</div>
|
|
531
812
|
</div>
|
|
532
813
|
</div>
|
|
533
814
|
</div>
|
|
@@ -538,6 +819,7 @@ exports[`<PromptEditor /> test cancel button with confirm 1`] = `
|
|
|
538
819
|
prompts.form.language
|
|
539
820
|
</label>
|
|
540
821
|
<div
|
|
822
|
+
aria-disabled="false"
|
|
541
823
|
aria-expanded="false"
|
|
542
824
|
class="ui selection dropdown"
|
|
543
825
|
role="listbox"
|
|
@@ -753,6 +1035,19 @@ exports[`<PromptEditor /> test delete button 1`] = `
|
|
|
753
1035
|
resourceMappings.resourceType.business_concept
|
|
754
1036
|
</span>
|
|
755
1037
|
</div>
|
|
1038
|
+
<div
|
|
1039
|
+
aria-checked="false"
|
|
1040
|
+
aria-selected="false"
|
|
1041
|
+
class="item"
|
|
1042
|
+
role="option"
|
|
1043
|
+
style="pointer-events: all;"
|
|
1044
|
+
>
|
|
1045
|
+
<span
|
|
1046
|
+
class="text"
|
|
1047
|
+
>
|
|
1048
|
+
resourceMappings.resourceType.translation
|
|
1049
|
+
</span>
|
|
1050
|
+
</div>
|
|
756
1051
|
</div>
|
|
757
1052
|
</div>
|
|
758
1053
|
</div>
|
|
@@ -763,6 +1058,7 @@ exports[`<PromptEditor /> test delete button 1`] = `
|
|
|
763
1058
|
prompts.form.language
|
|
764
1059
|
</label>
|
|
765
1060
|
<div
|
|
1061
|
+
aria-disabled="false"
|
|
766
1062
|
aria-expanded="false"
|
|
767
1063
|
class="ui selection dropdown"
|
|
768
1064
|
role="listbox"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import useSWRMutations from "swr/mutation";
|
|
2
|
+
import { apiJsonPost } from "@truedat/core/services/api";
|
|
3
|
+
import {
|
|
4
|
+
API_TRANSLATIONS_AVAILABILITY_CHECK,
|
|
5
|
+
API_TRANSLATIONS_REQUEST,
|
|
6
|
+
} from "../api";
|
|
7
|
+
|
|
8
|
+
export const useAvailabilityCheck = () => {
|
|
9
|
+
return useSWRMutations(API_TRANSLATIONS_AVAILABILITY_CHECK, (url, { arg }) =>
|
|
10
|
+
apiJsonPost(url, arg)
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const useRequestTranslation = () => {
|
|
15
|
+
return useSWRMutations(API_TRANSLATIONS_REQUEST, (url, { arg }) =>
|
|
16
|
+
apiJsonPost(url, arg)
|
|
17
|
+
);
|
|
18
|
+
};
|