@integry/sdk 4.6.40 → 4.6.41
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.
|
@@ -8,7 +8,6 @@ import { Hint } from '@/components/Tooltip';
|
|
|
8
8
|
import styles from './styles.module.scss';
|
|
9
9
|
|
|
10
10
|
// Types for our component
|
|
11
|
-
|
|
12
11
|
type Authorization = {
|
|
13
12
|
id: number;
|
|
14
13
|
display_name: string;
|
|
@@ -22,11 +21,13 @@ type FunctionFieldProps = {
|
|
|
22
21
|
description?: string;
|
|
23
22
|
field: Record<string, any>;
|
|
24
23
|
apiHandler?: any;
|
|
24
|
+
isArray?: boolean; // New prop for array support
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const FunctionField = (props: FunctionFieldProps) => {
|
|
28
|
-
const { value, label, description, field } = props;
|
|
28
|
+
const { value, label, description, field, isArray = false } = props;
|
|
29
29
|
const [isOpen, setIsOpen] = useState(false);
|
|
30
|
+
const [editingIndex, setEditingIndex] = useState<number | null>(null);
|
|
30
31
|
const [selectedFunction, setSelectedFunction] = useState<string>('');
|
|
31
32
|
const [activeTab, setActiveTab] = useState('authorization');
|
|
32
33
|
const [functionDetails, setFunctionDetails] = useState<any>(null);
|
|
@@ -38,27 +39,35 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
38
39
|
);
|
|
39
40
|
const [connectedAccounts, setConnectedAccounts] = useState<any>([]);
|
|
40
41
|
const [visibleFields, setVisibleFields] = useState<any>([]);
|
|
41
|
-
|
|
42
|
+
|
|
43
|
+
// Modified to support array of values
|
|
44
|
+
const [functionValues, setFunctionValues] = useState<any[]>(() => {
|
|
45
|
+
if (isArray && Array.isArray(value)) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
if (value) {
|
|
49
|
+
return [value];
|
|
50
|
+
}
|
|
51
|
+
return [];
|
|
52
|
+
});
|
|
53
|
+
|
|
42
54
|
const [formHasInvalidFields, setFormHasInvalidFields] = useState<boolean>(
|
|
43
55
|
false,
|
|
44
56
|
);
|
|
45
|
-
const [userFilledData, setUserFilledData] = useState<any>(
|
|
46
|
-
value?.default_arguments || {},
|
|
47
|
-
);
|
|
57
|
+
const [userFilledData, setUserFilledData] = useState<any>({});
|
|
48
58
|
|
|
49
59
|
const modalRef = useRef<HTMLDivElement | null>(null);
|
|
50
60
|
const FUNCTIONS_LIST_URL = `https://api.integry.io/functions/list/`;
|
|
51
61
|
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, [value]);
|
|
62
|
+
// Reset state when opening modal for a new action
|
|
63
|
+
const resetModalState = () => {
|
|
64
|
+
setSelectedFunction('');
|
|
65
|
+
setActiveTab('authorization');
|
|
66
|
+
setFunctionDetails(null);
|
|
67
|
+
setConnectedAccountId(null);
|
|
68
|
+
setUserFilledData({});
|
|
69
|
+
setFormHasInvalidFields(false);
|
|
70
|
+
};
|
|
62
71
|
|
|
63
72
|
// Handle clicking outside the modal to close it
|
|
64
73
|
useEffect(() => {
|
|
@@ -80,14 +89,13 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
80
89
|
};
|
|
81
90
|
}, [isOpen]);
|
|
82
91
|
|
|
92
|
+
// Open modal for adding a new action
|
|
83
93
|
const handleOpenModal = () => {
|
|
94
|
+
resetModalState();
|
|
95
|
+
setEditingIndex(null);
|
|
84
96
|
setIsOpen(true);
|
|
85
97
|
};
|
|
86
98
|
|
|
87
|
-
const handleCloseModal = () => {
|
|
88
|
-
setIsOpen(false);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
99
|
const getVisibleFields = (properties: any[]) => {
|
|
92
100
|
const response: any[] = [];
|
|
93
101
|
|
|
@@ -116,6 +124,38 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
116
124
|
return response;
|
|
117
125
|
};
|
|
118
126
|
|
|
127
|
+
// Open modal for editing an existing action
|
|
128
|
+
const handleEditAction = (index: number) => {
|
|
129
|
+
const actionToEdit = functionValues[index];
|
|
130
|
+
setEditingIndex(index);
|
|
131
|
+
setSelectedFunction(actionToEdit?.json_schema?.function.name || '');
|
|
132
|
+
setUserFilledData(actionToEdit?.default_arguments || {});
|
|
133
|
+
|
|
134
|
+
// Load function details for the selected function
|
|
135
|
+
setLoadingFunctionDetails(true);
|
|
136
|
+
props.apiHandler
|
|
137
|
+
.getFunctionDetails(actionToEdit?.json_schema?.function.name, {})
|
|
138
|
+
.then((response: any) => {
|
|
139
|
+
setFunctionDetails(response);
|
|
140
|
+
setLoadingFunctionDetails(false);
|
|
141
|
+
setConnectedAccounts(response?.meta?.app?.connected_accounts || []);
|
|
142
|
+
setVisibleFields(
|
|
143
|
+
getVisibleFields(response?.parameters?.properties || []),
|
|
144
|
+
);
|
|
145
|
+
setFormHasInvalidFields(
|
|
146
|
+
getInvalidFields(response?.parameters?.properties || []).length > 0,
|
|
147
|
+
);
|
|
148
|
+
setConnectedAccountId(actionToEdit?.meta?.connected_account_id || null);
|
|
149
|
+
setActiveTab('authorization');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
setIsOpen(true);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const handleCloseModal = () => {
|
|
156
|
+
setIsOpen(false);
|
|
157
|
+
};
|
|
158
|
+
|
|
119
159
|
const handleFunctionSelect = (val: any) => {
|
|
120
160
|
setSelectedFunction(val);
|
|
121
161
|
setActiveTab('authorization');
|
|
@@ -136,11 +176,6 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
136
176
|
setConnectedAccountId(null);
|
|
137
177
|
}
|
|
138
178
|
});
|
|
139
|
-
|
|
140
|
-
// const functionId = (e.target as HTMLSelectElement).value;
|
|
141
|
-
// const func = FUNCTION_OPTIONS.find((f) => f.id === functionId);
|
|
142
|
-
// setSelectedFunction(func || null);
|
|
143
|
-
// setConfigValues({});
|
|
144
179
|
};
|
|
145
180
|
|
|
146
181
|
const removeMeta = (obj: any): any => {
|
|
@@ -159,6 +194,7 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
159
194
|
return obj;
|
|
160
195
|
};
|
|
161
196
|
|
|
197
|
+
// Modified to handle array of values
|
|
162
198
|
const handleSave = () => {
|
|
163
199
|
if (selectedFunction && functionDetails) {
|
|
164
200
|
const schema = {
|
|
@@ -179,19 +215,40 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
179
215
|
default_arguments: userFilledData,
|
|
180
216
|
parameters_visible_to_user: {},
|
|
181
217
|
};
|
|
182
|
-
|
|
218
|
+
|
|
219
|
+
// Update or add the function value
|
|
220
|
+
let updatedValues;
|
|
221
|
+
if (editingIndex !== null) {
|
|
222
|
+
// Update existing action
|
|
223
|
+
updatedValues = [...functionValues];
|
|
224
|
+
updatedValues[editingIndex] = schema;
|
|
225
|
+
} else {
|
|
226
|
+
// Add new action
|
|
227
|
+
updatedValues = [...functionValues, schema];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
setFunctionValues(updatedValues);
|
|
231
|
+
|
|
232
|
+
// Call onChange with the updated values
|
|
183
233
|
if (props.onChange) {
|
|
184
|
-
props.onChange(
|
|
234
|
+
props.onChange(isArray ? updatedValues : updatedValues[0]);
|
|
185
235
|
}
|
|
186
|
-
|
|
187
|
-
// functionId: selectedFunction.id,
|
|
188
|
-
// functionName: selectedFunction.name,
|
|
189
|
-
// config: configValues,
|
|
190
|
-
// });
|
|
236
|
+
|
|
191
237
|
setIsOpen(false);
|
|
192
238
|
}
|
|
193
239
|
};
|
|
194
240
|
|
|
241
|
+
// Delete a specific action from the array
|
|
242
|
+
const handleDeleteAction = (index: number) => {
|
|
243
|
+
const updatedValues = functionValues.filter((_, i) => i !== index);
|
|
244
|
+
setFunctionValues(updatedValues);
|
|
245
|
+
|
|
246
|
+
// Call onChange with the updated values
|
|
247
|
+
if (props.onChange) {
|
|
248
|
+
props.onChange(isArray ? updatedValues : updatedValues[0] || null);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
195
252
|
const handleAuthCreated = (auth: Authorization) => {
|
|
196
253
|
setActiveTab('input');
|
|
197
254
|
const existingAuth = connectedAccounts.find(
|
|
@@ -210,34 +267,166 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
210
267
|
setConnectedAccountId(null);
|
|
211
268
|
};
|
|
212
269
|
|
|
213
|
-
const handleFunctionDeleted = () => {
|
|
214
|
-
setFunctionValue(null);
|
|
215
|
-
setFunctionDetails(null);
|
|
216
|
-
setSelectedFunction('');
|
|
217
|
-
setConnectedAccountId(null);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
270
|
const handleCustomaSave = (customSaveResponse: any) => {
|
|
221
271
|
setFormHasInvalidFields(customSaveResponse.hasInvalidFields);
|
|
222
272
|
setUserFilledData(customSaveResponse.data);
|
|
223
273
|
};
|
|
224
274
|
|
|
275
|
+
const handleNextTab = () => {
|
|
276
|
+
setActiveTab('input');
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const loadAuthorizationTabContent = () => {
|
|
280
|
+
let content;
|
|
281
|
+
|
|
282
|
+
if (loadingFunctionDetails) {
|
|
283
|
+
content = html`
|
|
284
|
+
<div class=${styles.loader || 'function-field-loader'}>
|
|
285
|
+
<${LargeLoader} />
|
|
286
|
+
</div>
|
|
287
|
+
`;
|
|
288
|
+
} else if (functionDetails) {
|
|
289
|
+
const selectedAuthId =
|
|
290
|
+
connectedAccountId ||
|
|
291
|
+
(functionDetails.meta.app.connected_accounts.length > 0
|
|
292
|
+
? functionDetails.meta.app.connected_accounts[0]?.id
|
|
293
|
+
: null);
|
|
294
|
+
|
|
295
|
+
content = html`
|
|
296
|
+
<${AuthSelectorV2}
|
|
297
|
+
authorizations=${connectedAccounts}
|
|
298
|
+
appName=${functionDetails.meta.app.title}
|
|
299
|
+
apiHandler=${props.apiHandler}
|
|
300
|
+
onAuthSelected=${(authId: number) => {
|
|
301
|
+
setConnectedAccountId(authId);
|
|
302
|
+
}}
|
|
303
|
+
onAuthCreated=${handleAuthCreated}
|
|
304
|
+
onAuthDeleted=${handleAuthDeleted}
|
|
305
|
+
selectedAuthId=${selectedAuthId}
|
|
306
|
+
loginUrl=${functionDetails.meta.app.login_url}
|
|
307
|
+
/>
|
|
308
|
+
`;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return content;
|
|
312
|
+
};
|
|
313
|
+
|
|
225
314
|
return html`
|
|
226
315
|
<div class=${styles.functionFieldContainer || 'function-field-container'}>
|
|
227
|
-
${label
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
316
|
+
${label
|
|
317
|
+
? html`
|
|
318
|
+
<label class=${styles.functionFieldLabel || 'function-field-label'}>
|
|
319
|
+
${label}
|
|
320
|
+
${description
|
|
321
|
+
? html`
|
|
322
|
+
<div
|
|
323
|
+
class=${styles.functionFieldDescription ||
|
|
324
|
+
'function-field-description'}
|
|
325
|
+
>
|
|
326
|
+
${description}
|
|
327
|
+
</div>
|
|
328
|
+
`
|
|
329
|
+
: null}
|
|
330
|
+
</label>
|
|
331
|
+
`
|
|
332
|
+
: null}
|
|
333
|
+
${isArray && functionValues.length > 0
|
|
334
|
+
? html`
|
|
335
|
+
<div class=${styles.functionFieldArray || 'function-field-array'}>
|
|
336
|
+
${functionValues.map(
|
|
337
|
+
(functionValue, index) => html`
|
|
338
|
+
<div
|
|
339
|
+
key=${index}
|
|
340
|
+
class=${styles.functionFieldSummary ||
|
|
341
|
+
'function-field-summary'}
|
|
342
|
+
style="margin-bottom: 8px;"
|
|
343
|
+
>
|
|
344
|
+
<div
|
|
345
|
+
class=${styles.functionFieldSelected ||
|
|
346
|
+
'function-field-selected'}
|
|
347
|
+
>
|
|
348
|
+
<div
|
|
349
|
+
class=${styles.functionFieldInfo ||
|
|
350
|
+
'function-field-info'}
|
|
351
|
+
>
|
|
352
|
+
<img
|
|
353
|
+
src=${functionValue?.meta?.app_icon_url}
|
|
354
|
+
alt=${functionValue.meta?.app_name || 'App'}
|
|
355
|
+
class=${styles.functionFieldAppIcon ||
|
|
356
|
+
'function-field-app-icon'}
|
|
357
|
+
/>
|
|
358
|
+
<div
|
|
359
|
+
class=${styles.functionFieldNameContainer ||
|
|
360
|
+
'function-field-name-container'}
|
|
361
|
+
>
|
|
362
|
+
<span
|
|
363
|
+
class=${styles.functionFieldName ||
|
|
364
|
+
'function-field-name'}
|
|
365
|
+
>
|
|
366
|
+
${functionValue.meta?.title || 'Function'}
|
|
367
|
+
</span>
|
|
368
|
+
<span
|
|
369
|
+
class=${styles.functionFieldAppName ||
|
|
370
|
+
'function-field-app-name'}
|
|
371
|
+
>
|
|
372
|
+
${functionValue.meta?.name || ''}
|
|
373
|
+
</span>
|
|
374
|
+
</div>
|
|
375
|
+
</div>
|
|
376
|
+
<div
|
|
377
|
+
class=${styles.functionFieldActions ||
|
|
378
|
+
'function-field-actions'}
|
|
379
|
+
>
|
|
380
|
+
<button
|
|
381
|
+
type="button"
|
|
382
|
+
class=${styles.functionFieldDeleteBtn ||
|
|
383
|
+
'function-field-delete-btn'}
|
|
384
|
+
onClick=${(e: any) => {
|
|
385
|
+
e.stopPropagation();
|
|
386
|
+
handleDeleteAction(index);
|
|
387
|
+
}}
|
|
388
|
+
aria-label="Delete"
|
|
389
|
+
>
|
|
390
|
+
<svg
|
|
391
|
+
width="16"
|
|
392
|
+
height="16"
|
|
393
|
+
viewBox="0 0 24 24"
|
|
394
|
+
fill="none"
|
|
395
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
396
|
+
>
|
|
397
|
+
<path
|
|
398
|
+
d="M3 6H5H21"
|
|
399
|
+
stroke="currentColor"
|
|
400
|
+
stroke-width="2"
|
|
401
|
+
stroke-linecap="round"
|
|
402
|
+
stroke-linejoin="round"
|
|
403
|
+
/>
|
|
404
|
+
<path
|
|
405
|
+
d="M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z"
|
|
406
|
+
stroke="currentColor"
|
|
407
|
+
stroke-width="2"
|
|
408
|
+
stroke-linecap="round"
|
|
409
|
+
stroke-linejoin="round"
|
|
410
|
+
/>
|
|
411
|
+
</svg>
|
|
412
|
+
</button>
|
|
413
|
+
<button
|
|
414
|
+
type="button"
|
|
415
|
+
class=${styles.functionFieldEditBtn ||
|
|
416
|
+
'function-field-edit-btn'}
|
|
417
|
+
onClick=${() => handleEditAction(index)}
|
|
418
|
+
>
|
|
419
|
+
Edit
|
|
420
|
+
</button>
|
|
421
|
+
</div>
|
|
422
|
+
</div>
|
|
423
|
+
</div>
|
|
424
|
+
`,
|
|
425
|
+
)}
|
|
426
|
+
</div>
|
|
427
|
+
`
|
|
428
|
+
: null}
|
|
429
|
+
${!isArray && functionValues.length > 0
|
|
241
430
|
? html`
|
|
242
431
|
<div
|
|
243
432
|
class=${styles.functionFieldSummary || 'function-field-summary'}
|
|
@@ -248,8 +437,8 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
248
437
|
>
|
|
249
438
|
<div class=${styles.functionFieldInfo || 'function-field-info'}>
|
|
250
439
|
<img
|
|
251
|
-
src=${
|
|
252
|
-
alt=${
|
|
440
|
+
src=${functionValues[0]?.meta?.app_icon_url}
|
|
441
|
+
alt=${functionValues[0].meta?.app_name || 'App'}
|
|
253
442
|
class=${styles.functionFieldAppIcon ||
|
|
254
443
|
'function-field-app-icon'}
|
|
255
444
|
/>
|
|
@@ -260,13 +449,13 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
260
449
|
<span
|
|
261
450
|
class=${styles.functionFieldName || 'function-field-name'}
|
|
262
451
|
>
|
|
263
|
-
${
|
|
452
|
+
${functionValues[0].meta?.title || 'Function'}
|
|
264
453
|
</span>
|
|
265
454
|
<span
|
|
266
455
|
class=${styles.functionFieldAppName ||
|
|
267
456
|
'function-field-app-name'}
|
|
268
457
|
>
|
|
269
|
-
${
|
|
458
|
+
${functionValues[0].meta?.name || ''}
|
|
270
459
|
</span>
|
|
271
460
|
</div>
|
|
272
461
|
</div>
|
|
@@ -280,7 +469,7 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
280
469
|
'function-field-delete-btn'}
|
|
281
470
|
onClick=${(e: any) => {
|
|
282
471
|
e.stopPropagation();
|
|
283
|
-
|
|
472
|
+
handleDeleteAction(0);
|
|
284
473
|
}}
|
|
285
474
|
aria-label="Delete"
|
|
286
475
|
>
|
|
@@ -311,7 +500,7 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
311
500
|
type="button"
|
|
312
501
|
class=${styles.functionFieldEditBtn ||
|
|
313
502
|
'function-field-edit-btn'}
|
|
314
|
-
onClick=${
|
|
503
|
+
onClick=${() => handleEditAction(0)}
|
|
315
504
|
>
|
|
316
505
|
Edit
|
|
317
506
|
</button>
|
|
@@ -319,91 +508,101 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
319
508
|
</div>
|
|
320
509
|
</div>
|
|
321
510
|
`
|
|
322
|
-
:
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
class=${styles.functionFieldAddBtn || 'function-field-add-btn'}
|
|
326
|
-
onClick=${handleOpenModal}
|
|
327
|
-
>
|
|
328
|
-
Add action
|
|
329
|
-
</button>
|
|
330
|
-
`}
|
|
331
|
-
${isOpen &&
|
|
332
|
-
html`
|
|
333
|
-
<div class=${styles.functionFieldOverlay || 'function-field-overlay'}>
|
|
334
|
-
<div
|
|
335
|
-
class=${styles.functionFieldModal || 'function-field-modal'}
|
|
336
|
-
ref=${modalRef}
|
|
337
|
-
>
|
|
511
|
+
: null}
|
|
512
|
+
${isArray || functionValues.length === 0
|
|
513
|
+
? html`
|
|
338
514
|
<div
|
|
339
|
-
class=${styles.
|
|
340
|
-
|
|
515
|
+
class=${styles.functionFieldActions || 'function-field-actions'}
|
|
516
|
+
style="margin-top: ${functionValues.length > 0 ? '8px' : '0'}"
|
|
341
517
|
>
|
|
342
|
-
<h3
|
|
343
|
-
class=${styles.functionFieldModalTitle ||
|
|
344
|
-
'function-field-modal-title'}
|
|
345
|
-
>
|
|
346
|
-
Add action
|
|
347
|
-
</h3>
|
|
348
|
-
<p
|
|
349
|
-
class=${styles.functionFieldModalDescription ||
|
|
350
|
-
'function-field-modal-description'}
|
|
351
|
-
>
|
|
352
|
-
The AI will use this action
|
|
353
|
-
</p>
|
|
354
518
|
<button
|
|
355
519
|
type="button"
|
|
356
|
-
class=${styles.
|
|
357
|
-
|
|
358
|
-
onClick=${handleCloseModal}
|
|
520
|
+
class=${styles.functionFieldAddBtn || 'function-field-add-btn'}
|
|
521
|
+
onClick=${handleOpenModal}
|
|
359
522
|
>
|
|
360
|
-
|
|
523
|
+
${isArray && functionValues.length > 0
|
|
524
|
+
? 'Add another'
|
|
525
|
+
: 'Add action'}
|
|
361
526
|
</button>
|
|
362
527
|
</div>
|
|
363
|
-
|
|
528
|
+
`
|
|
529
|
+
: null}
|
|
530
|
+
${isOpen
|
|
531
|
+
? html`
|
|
364
532
|
<div
|
|
365
|
-
class=${styles.
|
|
366
|
-
'function-field-modal-body'}
|
|
533
|
+
class=${styles.functionFieldOverlay || 'function-field-overlay'}
|
|
367
534
|
>
|
|
368
535
|
<div
|
|
369
|
-
class=${styles.
|
|
370
|
-
|
|
536
|
+
class=${styles.functionFieldModal || 'function-field-modal'}
|
|
537
|
+
ref=${modalRef}
|
|
371
538
|
>
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
</div>
|
|
539
|
+
<div
|
|
540
|
+
class=${styles.functionFieldModalHeader ||
|
|
541
|
+
'function-field-modal-header'}
|
|
542
|
+
>
|
|
543
|
+
<h3
|
|
544
|
+
class=${styles.functionFieldModalTitle ||
|
|
545
|
+
'function-field-modal-title'}
|
|
546
|
+
>
|
|
547
|
+
${editingIndex !== null ? 'Edit action' : 'Add action'}
|
|
548
|
+
</h3>
|
|
549
|
+
<p
|
|
550
|
+
class=${styles.functionFieldModalDescription ||
|
|
551
|
+
'function-field-modal-description'}
|
|
552
|
+
>
|
|
553
|
+
The AI will use this action
|
|
554
|
+
</p>
|
|
555
|
+
<button
|
|
556
|
+
type="button"
|
|
557
|
+
class=${styles.functionFieldCloseBtn ||
|
|
558
|
+
'function-field-close-btn'}
|
|
559
|
+
onClick=${handleCloseModal}
|
|
560
|
+
>
|
|
561
|
+
×
|
|
562
|
+
</button>
|
|
563
|
+
</div>
|
|
398
564
|
|
|
399
|
-
${selectedFunction &&
|
|
400
|
-
html`
|
|
401
565
|
<div
|
|
402
|
-
class=${styles.
|
|
566
|
+
class=${styles.functionFieldModalBody ||
|
|
567
|
+
'function-field-modal-body'}
|
|
403
568
|
>
|
|
404
569
|
<div
|
|
405
|
-
class=${styles.
|
|
570
|
+
class=${styles.functionFieldInlineGroup ||
|
|
571
|
+
'function-field-inline-group'}
|
|
406
572
|
>
|
|
573
|
+
<${ListBox}
|
|
574
|
+
key=${field.activity_field?.id}
|
|
575
|
+
fieldId=${field.activity_field?.id ||
|
|
576
|
+
field.id ||
|
|
577
|
+
field?.activity_field?.machine_name}
|
|
578
|
+
title=${`Action`}
|
|
579
|
+
placeholder=${`Select an action to use`}
|
|
580
|
+
isRequired=${true}
|
|
581
|
+
isHidden=${false}
|
|
582
|
+
isSearchable=${true}
|
|
583
|
+
value=${selectedFunction}
|
|
584
|
+
onChange=${handleFunctionSelect}
|
|
585
|
+
isDynamic=${true}
|
|
586
|
+
endpointUrl=${FUNCTIONS_LIST_URL}
|
|
587
|
+
endpointData=${`{"include": "meta"}`}
|
|
588
|
+
apiHandler=${props.apiHandler}
|
|
589
|
+
optionKeyPath=${`name`}
|
|
590
|
+
valueKeyPath=${`meta.ui.title`}
|
|
591
|
+
enableServerSideSearch=${true}
|
|
592
|
+
serverSideSearchParamName=${`search`}
|
|
593
|
+
iconKeyPath=${`meta.app.icon_url`}
|
|
594
|
+
optionDescriptionKeyPath=${`description`}
|
|
595
|
+
/>
|
|
596
|
+
</div>
|
|
597
|
+
|
|
598
|
+
${selectedFunction
|
|
599
|
+
? html`
|
|
600
|
+
<div class=${
|
|
601
|
+
styles.functionFieldConfig || 'function-field-config'
|
|
602
|
+
}>
|
|
603
|
+
<div class=${
|
|
604
|
+
styles.functionFieldTabs || 'function-field-tabs'
|
|
605
|
+
}>
|
|
407
606
|
<button
|
|
408
607
|
type="button"
|
|
409
608
|
class=${`${
|
|
@@ -420,9 +619,11 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
420
619
|
</button>
|
|
421
620
|
<${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
|
|
422
621
|
<button
|
|
423
|
-
data-hint=${
|
|
424
|
-
|
|
425
|
-
|
|
622
|
+
data-hint=${
|
|
623
|
+
connectedAccountId
|
|
624
|
+
? ''
|
|
625
|
+
: `Please connect your account to proceed.`
|
|
626
|
+
}
|
|
426
627
|
type="button"
|
|
427
628
|
class=${`${
|
|
428
629
|
styles.functionFieldTab || 'function-field-tab'
|
|
@@ -439,125 +640,108 @@ const FunctionField = (props: FunctionFieldProps) => {
|
|
|
439
640
|
}}
|
|
440
641
|
>
|
|
441
642
|
Input
|
|
442
|
-
${
|
|
443
|
-
|
|
444
|
-
|
|
643
|
+
${
|
|
644
|
+
visibleFields.length > 0
|
|
645
|
+
? ` (${visibleFields.length})`
|
|
646
|
+
: ''
|
|
647
|
+
}
|
|
445
648
|
</button>
|
|
446
|
-
|
|
649
|
+
</${Hint}>
|
|
447
650
|
</div>
|
|
448
651
|
|
|
449
|
-
<div
|
|
450
|
-
|
|
451
|
-
'function-field-tab-content'
|
|
452
|
-
>
|
|
453
|
-
${
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
selectedAuthId=${connectedAccountId ||
|
|
479
|
-
functionDetails.meta.app.connected_accounts
|
|
480
|
-
.length > 0
|
|
481
|
-
? functionDetails.meta.app
|
|
482
|
-
.connected_accounts[0]?.id
|
|
483
|
-
: null}
|
|
484
|
-
loginUrl=${functionDetails.meta.app.login_url}
|
|
485
|
-
><//>`}
|
|
486
|
-
</div>
|
|
487
|
-
`
|
|
488
|
-
: html`
|
|
489
|
-
<div
|
|
490
|
-
class=${styles.functionFieldInputContent ||
|
|
491
|
-
'function-field-input-content'}
|
|
492
|
-
>
|
|
493
|
-
<${FunctionForm}
|
|
494
|
-
functionName=${selectedFunction}
|
|
495
|
-
apiHandler=${props.apiHandler}
|
|
496
|
-
functionArguments=${userFilledData}
|
|
497
|
-
connectedAccountId=${connectedAccountId}
|
|
498
|
-
customSaveCallback=${handleCustomaSave}
|
|
499
|
-
><//>
|
|
500
|
-
</div>
|
|
501
|
-
`}
|
|
652
|
+
<div class=${
|
|
653
|
+
styles.functionFieldTabContent ||
|
|
654
|
+
'function-field-tab-content'
|
|
655
|
+
}>
|
|
656
|
+
${
|
|
657
|
+
activeTab === 'authorization'
|
|
658
|
+
? html`
|
|
659
|
+
<div
|
|
660
|
+
class=${styles.functionFieldAuthContent ||
|
|
661
|
+
'function-field-auth-content'}
|
|
662
|
+
>
|
|
663
|
+
${html`${loadAuthorizationTabContent()}`}
|
|
664
|
+
</div>
|
|
665
|
+
`
|
|
666
|
+
: html`
|
|
667
|
+
<div
|
|
668
|
+
class=${styles.functionFieldInputContent ||
|
|
669
|
+
'function-field-input-content'}
|
|
670
|
+
>
|
|
671
|
+
<${FunctionForm}
|
|
672
|
+
functionName=${selectedFunction}
|
|
673
|
+
apiHandler=${props.apiHandler}
|
|
674
|
+
functionArguments=${userFilledData}
|
|
675
|
+
connectedAccountId=${connectedAccountId}
|
|
676
|
+
customSaveCallback=${handleCustomaSave}
|
|
677
|
+
/>
|
|
678
|
+
</div>
|
|
679
|
+
`
|
|
680
|
+
}
|
|
502
681
|
</div>
|
|
503
682
|
</div>
|
|
504
|
-
`
|
|
505
|
-
|
|
683
|
+
`
|
|
684
|
+
: null}
|
|
685
|
+
</div>
|
|
506
686
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
687
|
+
${activeTab === 'input'
|
|
688
|
+
? html`
|
|
689
|
+
<div
|
|
690
|
+
class=${styles.functionFieldModalFooter ||
|
|
691
|
+
'function-field-modal-footer'}
|
|
692
|
+
>
|
|
693
|
+
<button
|
|
694
|
+
type="button"
|
|
695
|
+
class=${styles.functionFieldCancelBtn ||
|
|
696
|
+
'function-field-cancel-btn'}
|
|
697
|
+
onClick=${handleCloseModal}
|
|
698
|
+
>
|
|
699
|
+
Cancel
|
|
700
|
+
</button>
|
|
701
|
+
<button
|
|
702
|
+
type="button"
|
|
703
|
+
class=${styles.functionFieldSaveBtn ||
|
|
704
|
+
'function-field-save-btn'}
|
|
705
|
+
onClick=${handleSave}
|
|
706
|
+
disabled=${!selectedFunction ||
|
|
707
|
+
formHasInvalidFields ||
|
|
708
|
+
!connectedAccountId}
|
|
709
|
+
>
|
|
710
|
+
Save
|
|
711
|
+
</button>
|
|
712
|
+
</div>
|
|
713
|
+
`
|
|
714
|
+
: null}
|
|
715
|
+
${activeTab === 'authorization' && selectedFunction
|
|
716
|
+
? html`
|
|
717
|
+
<div
|
|
718
|
+
class=${styles.functionFieldModalFooter ||
|
|
719
|
+
'function-field-modal-footer'}
|
|
720
|
+
>
|
|
721
|
+
<button
|
|
722
|
+
type="button"
|
|
723
|
+
class=${styles.functionFieldCancelBtn ||
|
|
724
|
+
'function-field-cancel-btn'}
|
|
725
|
+
onClick=${handleCloseModal}
|
|
726
|
+
>
|
|
727
|
+
Cancel
|
|
728
|
+
</button>
|
|
729
|
+
<button
|
|
730
|
+
type="button"
|
|
731
|
+
class=${styles.functionFieldSaveBtn ||
|
|
732
|
+
'function-field-save-btn'}
|
|
733
|
+
onClick=${handleNextTab}
|
|
734
|
+
disabled=${!selectedFunction || !connectedAccountId}
|
|
735
|
+
>
|
|
736
|
+
Next
|
|
737
|
+
</button>
|
|
738
|
+
</div>
|
|
739
|
+
`
|
|
740
|
+
: null}
|
|
741
|
+
</div>
|
|
742
|
+
</div>
|
|
743
|
+
`
|
|
744
|
+
: null}
|
|
561
745
|
</div>
|
|
562
746
|
`;
|
|
563
747
|
};
|