@flowuent-org/diagramming-core 1.2.0 → 1.2.1
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 +1 -1
- package/packages/diagrams/src/lib/components/automation/AutomationApiNode.tsx +788 -794
- package/packages/diagrams/src/lib/components/automation/AutomationEndNode.tsx +600 -606
- package/packages/diagrams/src/lib/components/automation/AutomationFormattingNode.tsx +825 -831
- package/packages/diagrams/src/lib/components/automation/AutomationNoteNode.tsx +414 -420
- package/packages/diagrams/src/lib/components/automation/AutomationSheetsNode.tsx +1112 -1118
- package/packages/diagrams/src/lib/components/automation/AutomationStartNode.tsx +503 -509
- package/packages/diagrams/src/lib/components/automation/NodeActionButtons.tsx +145 -146
- package/packages/diagrams/src/lib/components/automation/index.ts +12 -20
- package/packages/diagrams/src/lib/components/automation/NodeAIAssistantPopup.tsx +0 -504
- package/packages/diagrams/src/lib/utils/nodeAIAssistantConfig.ts +0 -54
|
@@ -1,606 +1,600 @@
|
|
|
1
|
-
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import { Handle, Position, useNodeId } from '@xyflow/react';
|
|
4
|
-
import { Box, Typography, Chip, IconButton, Card, CardContent, Button } from '@mui/material';
|
|
5
|
-
import { AccessTime as AccessTimeIcon, Visibility as VisibilityIcon, Save as SaveIcon, Send as SendIcon, Lightbulb as LightbulbIcon } from '@mui/icons-material';
|
|
6
|
-
import { RiCloseLine, RiUser2Line } from 'react-icons/ri';
|
|
7
|
-
import ReactJson from 'react-json-view';
|
|
8
|
-
import { getIconByName } from '../../utils/iconMapper';
|
|
9
|
-
import { useTranslation } from 'react-i18next';
|
|
10
|
-
import { useDiagram } from '../../contexts/DiagramProvider';
|
|
11
|
-
import { AISuggestion } from './AISuggestionsModal';
|
|
12
|
-
import { AISuggestionsPanel } from './AISuggestionsPanel';
|
|
13
|
-
import { NodeActionButtons } from './NodeActionButtons';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const [
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
rootRef.current
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
rootRef.current
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
{
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
{
|
|
260
|
-
|
|
261
|
-
{
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
{
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
{
|
|
337
|
-
|
|
338
|
-
<
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
{/*
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
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
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
{
|
|
584
|
-
id: '
|
|
585
|
-
title: '
|
|
586
|
-
description: '
|
|
587
|
-
tags: ['classification', 'enhancement'],
|
|
588
|
-
},
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
onClose={() => setShowSuggestions(false)}
|
|
602
|
-
/>
|
|
603
|
-
)}
|
|
604
|
-
</Box>
|
|
605
|
-
);
|
|
606
|
-
};
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { Handle, Position, useNodeId } from '@xyflow/react';
|
|
4
|
+
import { Box, Typography, Chip, IconButton, Card, CardContent, Button } from '@mui/material';
|
|
5
|
+
import { AccessTime as AccessTimeIcon, Visibility as VisibilityIcon, Save as SaveIcon, Send as SendIcon, Lightbulb as LightbulbIcon } from '@mui/icons-material';
|
|
6
|
+
import { RiCloseLine, RiUser2Line } from 'react-icons/ri';
|
|
7
|
+
import ReactJson from 'react-json-view';
|
|
8
|
+
import { getIconByName } from '../../utils/iconMapper';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { useDiagram } from '../../contexts/DiagramProvider';
|
|
11
|
+
import { AISuggestion } from './AISuggestionsModal';
|
|
12
|
+
import { AISuggestionsPanel } from './AISuggestionsPanel';
|
|
13
|
+
import { NodeActionButtons } from './NodeActionButtons';
|
|
14
|
+
|
|
15
|
+
interface AutomationEndNodeProps {
|
|
16
|
+
data: {
|
|
17
|
+
label: string;
|
|
18
|
+
description: string;
|
|
19
|
+
status: 'Ready' | 'Running' | 'Completed' | 'Error';
|
|
20
|
+
outputType: 'display' | 'store' | 'send';
|
|
21
|
+
outputConfig?: {
|
|
22
|
+
format: 'table' | 'json' | 'csv';
|
|
23
|
+
destination?: string;
|
|
24
|
+
showInConsole: boolean;
|
|
25
|
+
showInUI: boolean;
|
|
26
|
+
};
|
|
27
|
+
lastRun: string;
|
|
28
|
+
backgroundColor: string;
|
|
29
|
+
textColor: string;
|
|
30
|
+
borderColor: string;
|
|
31
|
+
iconName?: string; // Add iconName to the interface
|
|
32
|
+
formData?: {
|
|
33
|
+
aiSuggestionsCount?: number; // Number of AI suggestions available
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}; // Include formData for configuration
|
|
36
|
+
};
|
|
37
|
+
selected?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const AutomationEndNode: React.FC<AutomationEndNodeProps> = ({ data, selected }) => {
|
|
41
|
+
const { t } = useTranslation();
|
|
42
|
+
const [isJsonOpen, setIsJsonOpen] = useState(false);
|
|
43
|
+
const [showSuggestions, setShowSuggestions] = useState(false);
|
|
44
|
+
const rootRef = useRef<any>(null);
|
|
45
|
+
const portalRef = useRef<HTMLDivElement | null>(null);
|
|
46
|
+
const nodeRef = useRef<HTMLDivElement | null>(null);
|
|
47
|
+
const nodeId = useNodeId();
|
|
48
|
+
const setSelectedNode = useDiagram((state) => state.setSelectedNode);
|
|
49
|
+
const enableJson = useDiagram((state) => state.enableNodeJsonPopover ?? true);
|
|
50
|
+
const onNodesChange = useDiagram((state) => state.onNodesChange);
|
|
51
|
+
const nodes = useDiagram((state) => state.nodes);
|
|
52
|
+
const setNodes = useDiagram((state) => state.setNodes);
|
|
53
|
+
|
|
54
|
+
// Get the icon component based on the iconName
|
|
55
|
+
const IconComponent = getIconByName(data.iconName);
|
|
56
|
+
|
|
57
|
+
const handleJsonClick = () => {
|
|
58
|
+
if (nodeId) setSelectedNode(nodeId);
|
|
59
|
+
if (!enableJson) return;
|
|
60
|
+
setIsJsonOpen(!isJsonOpen);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleClose = () => {
|
|
64
|
+
setIsJsonOpen(false);
|
|
65
|
+
// Clean up portal
|
|
66
|
+
if (rootRef.current) {
|
|
67
|
+
rootRef.current.unmount();
|
|
68
|
+
rootRef.current = null;
|
|
69
|
+
}
|
|
70
|
+
if (portalRef.current) {
|
|
71
|
+
document.body.removeChild(portalRef.current);
|
|
72
|
+
portalRef.current = null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
78
|
+
if (isJsonOpen && !(event.target as Element).closest('#automation-json-popover')) {
|
|
79
|
+
handleClose();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
83
|
+
return () => {
|
|
84
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
85
|
+
};
|
|
86
|
+
}, [isJsonOpen]);
|
|
87
|
+
|
|
88
|
+
// Debug logging for node dimensions
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (nodeRef.current) {
|
|
91
|
+
const rect = nodeRef.current.getBoundingClientRect();
|
|
92
|
+
const computedStyle = window.getComputedStyle(nodeRef.current);
|
|
93
|
+
// Debug information available but not logged
|
|
94
|
+
}
|
|
95
|
+
}, [data.label]);
|
|
96
|
+
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (isJsonOpen) {
|
|
99
|
+
const portalRoot = document.createElement('div');
|
|
100
|
+
document.body.appendChild(portalRoot);
|
|
101
|
+
portalRef.current = portalRoot;
|
|
102
|
+
|
|
103
|
+
const root = createRoot(portalRoot);
|
|
104
|
+
rootRef.current = root;
|
|
105
|
+
|
|
106
|
+
root.render(
|
|
107
|
+
<Card
|
|
108
|
+
id="automation-json-popover"
|
|
109
|
+
sx={{
|
|
110
|
+
position: 'fixed',
|
|
111
|
+
top: 0,
|
|
112
|
+
right: 0,
|
|
113
|
+
zIndex: 9999,
|
|
114
|
+
width: '400px',
|
|
115
|
+
height: '100vh',
|
|
116
|
+
overflow: 'auto',
|
|
117
|
+
bgcolor: '#242424',
|
|
118
|
+
color: '#fff',
|
|
119
|
+
border: '1px solid #333',
|
|
120
|
+
'&::-webkit-scrollbar': {
|
|
121
|
+
width: '6px',
|
|
122
|
+
},
|
|
123
|
+
'&::-webkit-scrollbar-track': {
|
|
124
|
+
background: 'transparent',
|
|
125
|
+
},
|
|
126
|
+
'&::-webkit-scrollbar-thumb': {
|
|
127
|
+
background: '#444',
|
|
128
|
+
borderRadius: '3px',
|
|
129
|
+
'&:hover': {
|
|
130
|
+
background: '#666',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<CardContent sx={{ bgcolor: '#242424', color: '#fff' }}>
|
|
136
|
+
<IconButton
|
|
137
|
+
aria-label="close"
|
|
138
|
+
onClick={handleClose}
|
|
139
|
+
sx={{
|
|
140
|
+
color: '#999',
|
|
141
|
+
'&:hover': {
|
|
142
|
+
color: '#fff',
|
|
143
|
+
bgcolor: 'rgba(255, 255, 255, 0.1)',
|
|
144
|
+
},
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
<RiCloseLine />
|
|
148
|
+
</IconButton>
|
|
149
|
+
{/* Show execution result prominently if available */}
|
|
150
|
+
{data.formData?.executionResult && (
|
|
151
|
+
<Box sx={{ mb: 2 }}>
|
|
152
|
+
<Typography variant="h6" sx={{ color: '#fff', mb: 1 }}>
|
|
153
|
+
{t('automation.common.executionResult')}
|
|
154
|
+
</Typography>
|
|
155
|
+
<Box sx={{
|
|
156
|
+
bgcolor: data.formData.executionResult.success ? '#1e3a8a' : '#dc2626',
|
|
157
|
+
p: 1,
|
|
158
|
+
borderRadius: 1,
|
|
159
|
+
mb: 1
|
|
160
|
+
}}>
|
|
161
|
+
<Typography variant="body2" sx={{ color: '#fff' }}>
|
|
162
|
+
{t('automation.common.status')}: {data.formData.executionResult.success ? t('automation.common.success') : t('automation.common.failed')}
|
|
163
|
+
</Typography>
|
|
164
|
+
<Typography variant="body2" sx={{ color: '#fff' }}>
|
|
165
|
+
{t('automation.common.timestamp')}: {new Date(data.formData.executionResult.timestamp).toLocaleString()}
|
|
166
|
+
</Typography>
|
|
167
|
+
{data.formData.executionResult.error && (
|
|
168
|
+
<Typography variant="body2" sx={{ color: '#fff' }}>
|
|
169
|
+
{t('automation.common.error')}: {data.formData.executionResult.error}
|
|
170
|
+
</Typography>
|
|
171
|
+
)}
|
|
172
|
+
</Box>
|
|
173
|
+
<Typography variant="h6" sx={{ color: '#fff', mb: 1 }}>
|
|
174
|
+
{t('automation.endNode.finalOutput')}
|
|
175
|
+
</Typography>
|
|
176
|
+
<ReactJson
|
|
177
|
+
theme={'monokai'}
|
|
178
|
+
src={data.formData.executionResult.data}
|
|
179
|
+
collapsed={false}
|
|
180
|
+
/>
|
|
181
|
+
</Box>
|
|
182
|
+
)}
|
|
183
|
+
|
|
184
|
+
{/* Show full node data */}
|
|
185
|
+
<Typography variant="h6" sx={{ color: '#fff', mb: 1 }}>
|
|
186
|
+
{t('automation.common.fullNodeData')}
|
|
187
|
+
</Typography>
|
|
188
|
+
<ReactJson theme={'monokai'} src={data.formData || data} collapsed={false} />
|
|
189
|
+
</CardContent>
|
|
190
|
+
</Card>
|
|
191
|
+
);
|
|
192
|
+
} else {
|
|
193
|
+
// Clean up when closing
|
|
194
|
+
if (rootRef.current) {
|
|
195
|
+
rootRef.current.unmount();
|
|
196
|
+
rootRef.current = null;
|
|
197
|
+
}
|
|
198
|
+
if (portalRef.current) {
|
|
199
|
+
document.body.removeChild(portalRef.current);
|
|
200
|
+
portalRef.current = null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}, [isJsonOpen, data]);
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<Box
|
|
207
|
+
sx={{
|
|
208
|
+
position: 'relative',
|
|
209
|
+
width: '336px',
|
|
210
|
+
overflow: 'visible',
|
|
211
|
+
}}
|
|
212
|
+
>
|
|
213
|
+
<Box
|
|
214
|
+
ref={nodeRef}
|
|
215
|
+
sx={{
|
|
216
|
+
width: '336px',
|
|
217
|
+
minHeight: '150px',
|
|
218
|
+
backgroundColor: '#181C25', // New background color from image
|
|
219
|
+
border: selected ? '2px solid #3b82f6' : '1px solid #1e293b',
|
|
220
|
+
borderRadius: '12px',
|
|
221
|
+
color: '#ffffff',
|
|
222
|
+
position: 'relative',
|
|
223
|
+
boxShadow: selected ? '0 0 0 2px rgba(59, 130, 246, 0.5)' : '0 4px 8px rgba(0, 0, 0, 0.3)',
|
|
224
|
+
transition: 'all 0.2s ease',
|
|
225
|
+
cursor: 'pointer',
|
|
226
|
+
overflow: 'hidden',
|
|
227
|
+
...(data.status === 'Running' && {
|
|
228
|
+
animation: 'pulse-glow 2s ease-in-out infinite',
|
|
229
|
+
'@keyframes pulse-glow': {
|
|
230
|
+
'0%, 100%': {
|
|
231
|
+
boxShadow: '0 0 20px rgba(59, 130, 246, 0.4), 0 0 40px rgba(59, 130, 246, 0.2)',
|
|
232
|
+
borderColor: 'rgba(59, 130, 246, 0.6)',
|
|
233
|
+
},
|
|
234
|
+
'50%': {
|
|
235
|
+
boxShadow: '0 0 30px rgba(59, 130, 246, 0.6), 0 0 60px rgba(59, 130, 246, 0.3)',
|
|
236
|
+
borderColor: 'rgba(59, 130, 246, 0.9)',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
}),
|
|
240
|
+
}}
|
|
241
|
+
onClick={handleJsonClick}
|
|
242
|
+
>
|
|
243
|
+
{/* Top Header Section */}
|
|
244
|
+
<Box sx={{
|
|
245
|
+
backgroundColor: "rgba(67, 93, 132, 0.1)",
|
|
246
|
+
padding: '8px 16px',
|
|
247
|
+
borderRadius: '12px 12px 0 0'
|
|
248
|
+
}}>
|
|
249
|
+
<Typography variant="body2" sx={{
|
|
250
|
+
color: '#ffffff',
|
|
251
|
+
fontSize: '12px',
|
|
252
|
+
fontWeight: 500
|
|
253
|
+
}}>
|
|
254
|
+
{data.formData?.description || t('automation.endNode.headerDescription')}
|
|
255
|
+
</Typography>
|
|
256
|
+
</Box>
|
|
257
|
+
|
|
258
|
+
{/* Main Content */}
|
|
259
|
+
<Box sx={{ padding: '16px' }}>
|
|
260
|
+
{/* Title Section */}
|
|
261
|
+
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 2 }}>
|
|
262
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
|
|
263
|
+
<Box
|
|
264
|
+
sx={{
|
|
265
|
+
width: '32px',
|
|
266
|
+
height: '32px',
|
|
267
|
+
backgroundColor: '#0ea5e9', // Blue-green color like in image
|
|
268
|
+
borderRadius: '50%',
|
|
269
|
+
display: 'flex',
|
|
270
|
+
alignItems: 'center',
|
|
271
|
+
justifyContent: 'center',
|
|
272
|
+
}}
|
|
273
|
+
>
|
|
274
|
+
<IconComponent sx={{ color: 'white', fontSize: '18px' }} />
|
|
275
|
+
</Box>
|
|
276
|
+
<Typography variant="h6" sx={{ fontWeight: 600, fontSize: '16px' }}>
|
|
277
|
+
{data.label}
|
|
278
|
+
</Typography>
|
|
279
|
+
</Box>
|
|
280
|
+
<Chip
|
|
281
|
+
label={data.status || 'Ready'}
|
|
282
|
+
size="small"
|
|
283
|
+
sx={{
|
|
284
|
+
backgroundColor: data.status === 'Completed'
|
|
285
|
+
? 'rgba(37, 99, 235, 0.1)'
|
|
286
|
+
: data.status === 'Running'
|
|
287
|
+
? 'rgba(251, 191, 36, 0.1)'
|
|
288
|
+
: data.status === 'Error'
|
|
289
|
+
? 'rgba(239, 68, 68, 0.1)'
|
|
290
|
+
: 'rgba(16, 185, 129, 0.1)',
|
|
291
|
+
color: data.status === 'Completed'
|
|
292
|
+
? '#93C5FD'
|
|
293
|
+
: data.status === 'Running'
|
|
294
|
+
? '#FCD34D'
|
|
295
|
+
: data.status === 'Error'
|
|
296
|
+
? '#FCA5A5'
|
|
297
|
+
: '#86EFAC',
|
|
298
|
+
fontWeight: 500,
|
|
299
|
+
fontSize: '12px',
|
|
300
|
+
height: '24px',
|
|
301
|
+
borderRadius: '12px',
|
|
302
|
+
}}
|
|
303
|
+
/>
|
|
304
|
+
</Box>
|
|
305
|
+
|
|
306
|
+
{/* Description Box */}
|
|
307
|
+
<Box sx={{
|
|
308
|
+
backgroundColor: '#1F2937',
|
|
309
|
+
borderRadius: '8px',
|
|
310
|
+
padding: '12px',
|
|
311
|
+
mb: 2,
|
|
312
|
+
border: '1px solid #374151'
|
|
313
|
+
}}>
|
|
314
|
+
{/* Inner text boundary box */}
|
|
315
|
+
<Box sx={{
|
|
316
|
+
backgroundColor: 'transparent',
|
|
317
|
+
borderRadius: '4px',
|
|
318
|
+
padding: '8px',
|
|
319
|
+
border: '1px solid #4B5563', // Light grey border for inner box
|
|
320
|
+
minHeight: '40px',
|
|
321
|
+
display: 'flex',
|
|
322
|
+
alignItems: 'center'
|
|
323
|
+
}}>
|
|
324
|
+
<Typography variant="body2" sx={{
|
|
325
|
+
color: '#9CA3AF',
|
|
326
|
+
fontSize: '12px',
|
|
327
|
+
lineHeight: 1.4,
|
|
328
|
+
margin: 0
|
|
329
|
+
}}>
|
|
330
|
+
{data.description}
|
|
331
|
+
</Typography>
|
|
332
|
+
</Box>
|
|
333
|
+
</Box>
|
|
334
|
+
|
|
335
|
+
{/* Last Run Info */}
|
|
336
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, mt: 1 }}>
|
|
337
|
+
<AccessTimeIcon sx={{ fontSize: '14px', color: '#9CA3AF' }} />
|
|
338
|
+
<Typography variant="body2" sx={{ color: '#9CA3AF', fontSize: '11px' }}>
|
|
339
|
+
{t('automation.common.lastRan')}: {data.lastRun}
|
|
340
|
+
</Typography>
|
|
341
|
+
</Box>
|
|
342
|
+
</Box>
|
|
343
|
+
|
|
344
|
+
{/* Connection Handles - Bidirectional (source + target at each position) */}
|
|
345
|
+
{/* Top - Source */}
|
|
346
|
+
<Handle
|
|
347
|
+
type="source"
|
|
348
|
+
position={Position.Top}
|
|
349
|
+
id="top-source"
|
|
350
|
+
className="connection-handle"
|
|
351
|
+
style={{
|
|
352
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
353
|
+
width: '14px',
|
|
354
|
+
height: '14px',
|
|
355
|
+
border: '3px solid #10B981',
|
|
356
|
+
top: '-8px',
|
|
357
|
+
opacity: selected ? 1 : 0,
|
|
358
|
+
transition: 'all 0.2s ease-in-out',
|
|
359
|
+
cursor: 'crosshair',
|
|
360
|
+
zIndex: 10,
|
|
361
|
+
}}
|
|
362
|
+
/>
|
|
363
|
+
{/* Top - Target (hidden but functional) */}
|
|
364
|
+
<Handle
|
|
365
|
+
type="target"
|
|
366
|
+
position={Position.Top}
|
|
367
|
+
id="top-target"
|
|
368
|
+
style={{
|
|
369
|
+
background: 'transparent',
|
|
370
|
+
width: '14px',
|
|
371
|
+
height: '14px',
|
|
372
|
+
border: 'none',
|
|
373
|
+
top: '-8px',
|
|
374
|
+
opacity: 0,
|
|
375
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
376
|
+
}}
|
|
377
|
+
/>
|
|
378
|
+
{/* Bottom - Source */}
|
|
379
|
+
<Handle
|
|
380
|
+
type="source"
|
|
381
|
+
position={Position.Bottom}
|
|
382
|
+
id="bottom-source"
|
|
383
|
+
className="connection-handle"
|
|
384
|
+
style={{
|
|
385
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
386
|
+
width: '14px',
|
|
387
|
+
height: '14px',
|
|
388
|
+
border: '3px solid #10B981',
|
|
389
|
+
bottom: '-8px',
|
|
390
|
+
opacity: selected ? 1 : 0,
|
|
391
|
+
transition: 'all 0.2s ease-in-out',
|
|
392
|
+
cursor: 'crosshair',
|
|
393
|
+
zIndex: 10,
|
|
394
|
+
}}
|
|
395
|
+
/>
|
|
396
|
+
{/* Bottom - Target (hidden but functional) */}
|
|
397
|
+
<Handle
|
|
398
|
+
type="target"
|
|
399
|
+
position={Position.Bottom}
|
|
400
|
+
id="bottom-target"
|
|
401
|
+
style={{
|
|
402
|
+
background: 'transparent',
|
|
403
|
+
width: '14px',
|
|
404
|
+
height: '14px',
|
|
405
|
+
border: 'none',
|
|
406
|
+
bottom: '-8px',
|
|
407
|
+
opacity: 0,
|
|
408
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
409
|
+
}}
|
|
410
|
+
/>
|
|
411
|
+
{/* Left - Source */}
|
|
412
|
+
<Handle
|
|
413
|
+
type="source"
|
|
414
|
+
position={Position.Left}
|
|
415
|
+
id="left-source"
|
|
416
|
+
className="connection-handle"
|
|
417
|
+
style={{
|
|
418
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
419
|
+
width: '14px',
|
|
420
|
+
height: '14px',
|
|
421
|
+
border: '3px solid #10B981',
|
|
422
|
+
left: '-8px',
|
|
423
|
+
opacity: selected ? 1 : 0,
|
|
424
|
+
transition: 'all 0.2s ease-in-out',
|
|
425
|
+
cursor: 'crosshair',
|
|
426
|
+
zIndex: 10,
|
|
427
|
+
}}
|
|
428
|
+
/>
|
|
429
|
+
{/* Left - Target (hidden but functional) */}
|
|
430
|
+
<Handle
|
|
431
|
+
type="target"
|
|
432
|
+
position={Position.Left}
|
|
433
|
+
id="left-target"
|
|
434
|
+
style={{
|
|
435
|
+
background: 'transparent',
|
|
436
|
+
width: '14px',
|
|
437
|
+
height: '14px',
|
|
438
|
+
border: 'none',
|
|
439
|
+
left: '-8px',
|
|
440
|
+
opacity: 0,
|
|
441
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
442
|
+
}}
|
|
443
|
+
/>
|
|
444
|
+
{/* Right - Source */}
|
|
445
|
+
<Handle
|
|
446
|
+
type="source"
|
|
447
|
+
position={Position.Right}
|
|
448
|
+
id="right-source"
|
|
449
|
+
className="connection-handle"
|
|
450
|
+
style={{
|
|
451
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
452
|
+
width: '14px',
|
|
453
|
+
height: '14px',
|
|
454
|
+
border: '3px solid #10B981',
|
|
455
|
+
right: '-8px',
|
|
456
|
+
opacity: selected ? 1 : 0,
|
|
457
|
+
transition: 'all 0.2s ease-in-out',
|
|
458
|
+
cursor: 'crosshair',
|
|
459
|
+
zIndex: 10,
|
|
460
|
+
}}
|
|
461
|
+
/>
|
|
462
|
+
{/* Right - Target (hidden but functional) */}
|
|
463
|
+
<Handle
|
|
464
|
+
type="target"
|
|
465
|
+
position={Position.Right}
|
|
466
|
+
id="right-target"
|
|
467
|
+
style={{
|
|
468
|
+
background: 'transparent',
|
|
469
|
+
width: '14px',
|
|
470
|
+
height: '14px',
|
|
471
|
+
border: 'none',
|
|
472
|
+
right: '-8px',
|
|
473
|
+
opacity: 0,
|
|
474
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
475
|
+
}}
|
|
476
|
+
/>
|
|
477
|
+
|
|
478
|
+
</Box>
|
|
479
|
+
|
|
480
|
+
{/* Node Action Buttons - Shows when selected */}
|
|
481
|
+
<NodeActionButtons
|
|
482
|
+
selected={selected}
|
|
483
|
+
onDelete={() => {
|
|
484
|
+
if (nodeId && onNodesChange) {
|
|
485
|
+
onNodesChange([{ id: nodeId, type: 'remove' }]);
|
|
486
|
+
}
|
|
487
|
+
}}
|
|
488
|
+
onDuplicate={() => {
|
|
489
|
+
if (nodeId) {
|
|
490
|
+
const currentNode = nodes.find(n => n.id === nodeId);
|
|
491
|
+
if (currentNode) {
|
|
492
|
+
const newNode = {
|
|
493
|
+
...currentNode,
|
|
494
|
+
id: `${currentNode.id}-copy-${Date.now()}`,
|
|
495
|
+
position: {
|
|
496
|
+
x: currentNode.position.x + 50,
|
|
497
|
+
y: currentNode.position.y + 50,
|
|
498
|
+
},
|
|
499
|
+
selected: false,
|
|
500
|
+
};
|
|
501
|
+
setNodes([...nodes, newNode]);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}}
|
|
505
|
+
/>
|
|
506
|
+
|
|
507
|
+
{/* AI Suggestions Button - Positioned below the node box */}
|
|
508
|
+
{data.formData?.aiSuggestionsCount !== undefined && data.formData.aiSuggestionsCount > 0 && (
|
|
509
|
+
<Box
|
|
510
|
+
sx={{
|
|
511
|
+
position: 'absolute',
|
|
512
|
+
top: '100%',
|
|
513
|
+
left: '50%',
|
|
514
|
+
transform: 'translateX(-50%)',
|
|
515
|
+
marginTop: '12px',
|
|
516
|
+
zIndex: 10,
|
|
517
|
+
whiteSpace: 'nowrap',
|
|
518
|
+
}}
|
|
519
|
+
onClick={(e) => {
|
|
520
|
+
e.stopPropagation();
|
|
521
|
+
// Toggle AI Suggestions panel
|
|
522
|
+
setShowSuggestions(!showSuggestions);
|
|
523
|
+
}}
|
|
524
|
+
>
|
|
525
|
+
<Button
|
|
526
|
+
variant="contained"
|
|
527
|
+
startIcon={<LightbulbIcon sx={{ fontSize: '12px' }} />}
|
|
528
|
+
sx={{
|
|
529
|
+
backgroundColor: '#2563EB',
|
|
530
|
+
color: '#ffffff',
|
|
531
|
+
borderRadius: '20px',
|
|
532
|
+
textTransform: 'none',
|
|
533
|
+
fontSize: '10px',
|
|
534
|
+
fontWeight: 400,
|
|
535
|
+
padding: '8px 16px',
|
|
536
|
+
whiteSpace: 'nowrap',
|
|
537
|
+
display: 'inline-flex',
|
|
538
|
+
alignItems: 'center',
|
|
539
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.3)',
|
|
540
|
+
'&:hover': {
|
|
541
|
+
backgroundColor: '#2563eb',
|
|
542
|
+
},
|
|
543
|
+
'& .MuiButton-startIcon': {
|
|
544
|
+
marginRight: '8px',
|
|
545
|
+
}
|
|
546
|
+
}}
|
|
547
|
+
>
|
|
548
|
+
AI Suggestions
|
|
549
|
+
<Box
|
|
550
|
+
component="span"
|
|
551
|
+
sx={{
|
|
552
|
+
marginLeft: '8px',
|
|
553
|
+
backgroundColor: '#FFFFFF26',
|
|
554
|
+
color: '#ffffff',
|
|
555
|
+
fontSize: '10px',
|
|
556
|
+
fontWeight: 400,
|
|
557
|
+
minWidth: '18px',
|
|
558
|
+
height: '18px',
|
|
559
|
+
borderRadius: '9px',
|
|
560
|
+
display: 'inline-flex',
|
|
561
|
+
alignItems: 'center',
|
|
562
|
+
justifyContent: 'center',
|
|
563
|
+
padding: '0 6px',
|
|
564
|
+
border: '1px solid rgba(255, 255, 255, 0.2)',
|
|
565
|
+
}}
|
|
566
|
+
>
|
|
567
|
+
{data.formData.aiSuggestionsCount}
|
|
568
|
+
</Box>
|
|
569
|
+
</Button>
|
|
570
|
+
</Box>
|
|
571
|
+
)}
|
|
572
|
+
|
|
573
|
+
{/* AI Suggestions Panel - Rendered on canvas below the button */}
|
|
574
|
+
{showSuggestions && data.formData?.aiSuggestionsCount !== undefined && data.formData.aiSuggestionsCount > 0 && nodeId && (
|
|
575
|
+
<AISuggestionsPanel
|
|
576
|
+
suggestions={data.formData?.aiSuggestions || [
|
|
577
|
+
{
|
|
578
|
+
id: '1',
|
|
579
|
+
title: 'Add Citation Extraction',
|
|
580
|
+
description: 'Automatically extract and format citations from article content.',
|
|
581
|
+
tags: ['classification', 'enhancement'],
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
id: '2',
|
|
585
|
+
title: 'Generate Bullet Summary',
|
|
586
|
+
description: 'Create a concise bullet-point summary of the article\'s main points.',
|
|
587
|
+
tags: ['classification', 'enhancement'],
|
|
588
|
+
},
|
|
589
|
+
]}
|
|
590
|
+
parentNodeId={nodeId}
|
|
591
|
+
onSuggestionClick={(suggestion) => {
|
|
592
|
+
console.log('Suggestion clicked:', suggestion);
|
|
593
|
+
// Handle suggestion selection here
|
|
594
|
+
}}
|
|
595
|
+
onClose={() => setShowSuggestions(false)}
|
|
596
|
+
/>
|
|
597
|
+
)}
|
|
598
|
+
</Box>
|
|
599
|
+
);
|
|
600
|
+
};
|