@flowuent-org/diagramming-core 1.2.1 → 1.2.2
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/apps/diagramming/src/AutomationDiagramData.ts +65 -1
- package/package.json +1 -1
- package/packages/diagrams/src/lib/components/CanvasSearchBar.tsx +281 -0
- package/packages/diagrams/src/lib/components/automation/AutomationApiNode.tsx +796 -788
- package/packages/diagrams/src/lib/components/automation/AutomationEndNode.tsx +608 -600
- package/packages/diagrams/src/lib/components/automation/AutomationFormattingNode.tsx +833 -825
- package/packages/diagrams/src/lib/components/automation/AutomationNavigationNode.tsx +584 -0
- package/packages/diagrams/src/lib/components/automation/AutomationNoteNode.tsx +422 -414
- package/packages/diagrams/src/lib/components/automation/AutomationSheetsNode.tsx +1120 -1112
- package/packages/diagrams/src/lib/components/automation/AutomationStartNode.tsx +511 -503
- package/packages/diagrams/src/lib/components/automation/NodeAIAssistantPopup.tsx +504 -0
- package/packages/diagrams/src/lib/components/automation/NodeActionButtons.tsx +146 -145
- package/packages/diagrams/src/lib/components/automation/index.ts +21 -12
- package/packages/diagrams/src/lib/contexts/SearchContext.tsx +78 -0
- package/packages/diagrams/src/lib/templates/DiagramContainer.tsx +79 -76
- package/packages/diagrams/src/lib/templates/DiagramContent.tsx +276 -61
- package/packages/diagrams/src/lib/types/automation-node-data-types.ts +22 -2
- package/packages/diagrams/src/lib/types/node-types.ts +2 -0
- package/packages/diagrams/src/lib/utils/highlightText.tsx +93 -0
- package/packages/diagrams/src/lib/utils/nodeAIAssistantConfig.ts +54 -0
|
@@ -1,1112 +1,1120 @@
|
|
|
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 {
|
|
6
|
-
TableChart as TableChartIcon,
|
|
7
|
-
AccessTime as AccessTimeIcon,
|
|
8
|
-
Save as SaveIcon,
|
|
9
|
-
Send as SendIcon,
|
|
10
|
-
Settings as SettingsIcon,
|
|
11
|
-
TableRows as TableRowsIcon,
|
|
12
|
-
Email as EmailIcon,
|
|
13
|
-
Description as DescriptionIcon,
|
|
14
|
-
Drafts as DraftsIcon,
|
|
15
|
-
Add as AddIcon,
|
|
16
|
-
CheckCircle as CheckCircleIcon,
|
|
17
|
-
Settings as ConfigureIcon,
|
|
18
|
-
Error as ErrorIcon,
|
|
19
|
-
ArrowForwardIos as ArrowForwardIcon,
|
|
20
|
-
WhatsApp as WhatsAppIcon,
|
|
21
|
-
Phone as PhoneIcon,
|
|
22
|
-
Lightbulb as LightbulbIcon
|
|
23
|
-
} from '@mui/icons-material';
|
|
24
|
-
import { RiCloseLine } from 'react-icons/ri';
|
|
25
|
-
import ReactJson from 'react-json-view';
|
|
26
|
-
import { getIconByName } from '../../utils/iconMapper';
|
|
27
|
-
import { useTranslation } from 'react-i18next';
|
|
28
|
-
import { useDiagram } from '../../contexts/DiagramProvider';
|
|
29
|
-
import { AISuggestion } from './AISuggestionsModal';
|
|
30
|
-
import { AISuggestionsPanel } from './AISuggestionsPanel';
|
|
31
|
-
import { NodeActionButtons } from './NodeActionButtons';
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
//
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
);
|
|
126
|
-
const
|
|
127
|
-
exportOptions
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
exportOptions.
|
|
131
|
-
exportOptions.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
exportOptions.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
exportOptions.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (data
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (!
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const
|
|
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
|
-
root
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
'
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
'&::-webkit-scrollbar
|
|
346
|
-
|
|
347
|
-
},
|
|
348
|
-
'&::-webkit-scrollbar-
|
|
349
|
-
background: '
|
|
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
|
-
<Typography variant="body2" sx={{ color: '#fff' }}>
|
|
387
|
-
{t('automation.common.
|
|
388
|
-
</Typography>
|
|
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
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
{
|
|
769
|
-
</
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
{
|
|
825
|
-
{
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
'
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
'
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
'
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
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 {
|
|
6
|
+
TableChart as TableChartIcon,
|
|
7
|
+
AccessTime as AccessTimeIcon,
|
|
8
|
+
Save as SaveIcon,
|
|
9
|
+
Send as SendIcon,
|
|
10
|
+
Settings as SettingsIcon,
|
|
11
|
+
TableRows as TableRowsIcon,
|
|
12
|
+
Email as EmailIcon,
|
|
13
|
+
Description as DescriptionIcon,
|
|
14
|
+
Drafts as DraftsIcon,
|
|
15
|
+
Add as AddIcon,
|
|
16
|
+
CheckCircle as CheckCircleIcon,
|
|
17
|
+
Settings as ConfigureIcon,
|
|
18
|
+
Error as ErrorIcon,
|
|
19
|
+
ArrowForwardIos as ArrowForwardIcon,
|
|
20
|
+
WhatsApp as WhatsAppIcon,
|
|
21
|
+
Phone as PhoneIcon,
|
|
22
|
+
Lightbulb as LightbulbIcon
|
|
23
|
+
} from '@mui/icons-material';
|
|
24
|
+
import { RiCloseLine } from 'react-icons/ri';
|
|
25
|
+
import ReactJson from 'react-json-view';
|
|
26
|
+
import { getIconByName } from '../../utils/iconMapper';
|
|
27
|
+
import { useTranslation } from 'react-i18next';
|
|
28
|
+
import { useDiagram } from '../../contexts/DiagramProvider';
|
|
29
|
+
import { AISuggestion } from './AISuggestionsModal';
|
|
30
|
+
import { AISuggestionsPanel } from './AISuggestionsPanel';
|
|
31
|
+
import { NodeActionButtons } from './NodeActionButtons';
|
|
32
|
+
import { showNodeAIAssistantPopup } from './NodeAIAssistantPopup';
|
|
33
|
+
import { useSearch } from '../../contexts/SearchContext';
|
|
34
|
+
|
|
35
|
+
interface AutomationSheetsNodeProps {
|
|
36
|
+
data: {
|
|
37
|
+
label: string;
|
|
38
|
+
description: string;
|
|
39
|
+
status: 'Ready' | 'Running' | 'Completed' | 'Error';
|
|
40
|
+
inputVariable: string;
|
|
41
|
+
lastRun?: string;
|
|
42
|
+
iconName?: string;
|
|
43
|
+
sheetsConfig: {
|
|
44
|
+
spreadsheetId: string;
|
|
45
|
+
sheetName: string;
|
|
46
|
+
range: string;
|
|
47
|
+
credentials: {
|
|
48
|
+
type: 'service-account' | 'oauth' | 'api-key';
|
|
49
|
+
serviceAccountKey?: string;
|
|
50
|
+
oauthToken?: string;
|
|
51
|
+
apiKey?: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
dataMapping: {
|
|
55
|
+
headers: Array<{
|
|
56
|
+
column: string;
|
|
57
|
+
sourceField: string;
|
|
58
|
+
dataType: 'string' | 'number' | 'date' | 'boolean';
|
|
59
|
+
}>;
|
|
60
|
+
appendMode: boolean;
|
|
61
|
+
clearSheet: boolean;
|
|
62
|
+
};
|
|
63
|
+
exportOptions: {
|
|
64
|
+
emailRecipients: string[];
|
|
65
|
+
fileName: string;
|
|
66
|
+
exportFormat: 'sheets' | 'excel' | 'both';
|
|
67
|
+
includeHeaders: boolean;
|
|
68
|
+
sendEmailNotification: boolean;
|
|
69
|
+
// Optional fields for Gmail output configuration (may live under formData.exportOptions)
|
|
70
|
+
emailSendEnabled?: boolean;
|
|
71
|
+
emailSender?: string;
|
|
72
|
+
emailSubject?: string;
|
|
73
|
+
emailMessage?: string;
|
|
74
|
+
// WhatsApp configuration
|
|
75
|
+
whatsapp?: {
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
phoneNumber: string;
|
|
78
|
+
messageTemplate: string;
|
|
79
|
+
includeDataMode: 'json' | 'summary' | 'custom';
|
|
80
|
+
// Twilio configuration
|
|
81
|
+
twilio?: {
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
accountSid: string;
|
|
84
|
+
authToken: string;
|
|
85
|
+
fromNumber: string;
|
|
86
|
+
isSandbox: boolean;
|
|
87
|
+
templateSid?: string;
|
|
88
|
+
templateVariables?: Record<string, string>;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
formData?: {
|
|
93
|
+
aiSuggestionsCount?: number; // Number of AI suggestions available
|
|
94
|
+
[key: string]: any;
|
|
95
|
+
};
|
|
96
|
+
// Optional per-output-method statuses supplied by engine
|
|
97
|
+
outputStatuses?: {
|
|
98
|
+
googleSheets?: 'not-set' | 'configured' | 'running' | 'connected' | 'failed';
|
|
99
|
+
gmail?: 'not-set' | 'configured' | 'running' | 'connected' | 'failed';
|
|
100
|
+
whatsapp?: 'not-set' | 'configured' | 'running' | 'connected' | 'failed';
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
selected?: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const AutomationSheetsNode: React.FC<AutomationSheetsNodeProps> = ({ data, selected }) => {
|
|
107
|
+
const { t } = useTranslation();
|
|
108
|
+
const { highlightText } = useSearch();
|
|
109
|
+
const [isJsonOpen, setIsJsonOpen] = useState(false);
|
|
110
|
+
const [showSuggestions, setShowSuggestions] = useState(false);
|
|
111
|
+
const rootRef = useRef<any>(null);
|
|
112
|
+
const portalRef = useRef<HTMLDivElement | null>(null);
|
|
113
|
+
const nodeRef = useRef<HTMLDivElement | null>(null);
|
|
114
|
+
const nodeId = useNodeId();
|
|
115
|
+
const setSelectedNode = useDiagram((state) => state.setSelectedNode);
|
|
116
|
+
const enableJson = useDiagram((state) => state.enableNodeJsonPopover ?? true);
|
|
117
|
+
const onNodesChange = useDiagram((state) => state.onNodesChange);
|
|
118
|
+
const nodes = useDiagram((state) => state.nodes);
|
|
119
|
+
const setNodes = useDiagram((state) => state.setNodes);
|
|
120
|
+
|
|
121
|
+
// Get the icon component based on the iconName
|
|
122
|
+
const IconComponent = getIconByName(data.iconName || 'TableChart');
|
|
123
|
+
|
|
124
|
+
// Resolve export options from formData or data
|
|
125
|
+
const exportOptions = (data.formData?.exportOptions || (data as any).exportOptions) || {};
|
|
126
|
+
const showSheets = Boolean(
|
|
127
|
+
exportOptions?.exportFormat === 'sheets' || exportOptions?.exportFormat === 'both'
|
|
128
|
+
);
|
|
129
|
+
const showGmail = Boolean(
|
|
130
|
+
exportOptions.emailSendEnabled &&
|
|
131
|
+
exportOptions.emailSender &&
|
|
132
|
+
(exportOptions.emailRecipients?.length || 0) > 0 &&
|
|
133
|
+
exportOptions.emailSubject &&
|
|
134
|
+
exportOptions.emailMessage
|
|
135
|
+
);
|
|
136
|
+
const showSlack = Boolean(
|
|
137
|
+
exportOptions.slack?.enabled &&
|
|
138
|
+
exportOptions.slack?.webhookUrl &&
|
|
139
|
+
exportOptions.slack?.channel
|
|
140
|
+
);
|
|
141
|
+
const showWhatsApp = Boolean(
|
|
142
|
+
exportOptions.whatsapp?.enabled &&
|
|
143
|
+
exportOptions.whatsapp?.phoneNumber
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// Determine Google Sheets status from provided data and execution result
|
|
147
|
+
const determineGoogleSheetsStatus = (): 'not-set' | 'configured' | 'running' | 'connected' | 'failed' => {
|
|
148
|
+
// Prefer status provided by engine
|
|
149
|
+
if (data.outputStatuses?.googleSheets) return data.outputStatuses.googleSheets;
|
|
150
|
+
|
|
151
|
+
// Required config check (accepts either spreadsheetId or OAuth clientId that can create one)
|
|
152
|
+
const cfg = (data.formData?.sheetsConfig || data.sheetsConfig) || {};
|
|
153
|
+
const creds = cfg.credentials || {};
|
|
154
|
+
const hasRequired = Boolean((cfg.spreadsheetId || creds.clientId) && cfg.sheetName && creds.type);
|
|
155
|
+
if (!hasRequired) return 'not-set';
|
|
156
|
+
|
|
157
|
+
// Running inferred from node status
|
|
158
|
+
if (data.status === 'Running') return 'running';
|
|
159
|
+
|
|
160
|
+
// Execution result inference
|
|
161
|
+
const exec = data.formData?.executionResult || (data as any).executionResult;
|
|
162
|
+
if (exec?.success === true) return 'connected';
|
|
163
|
+
if (exec?.success === false || data.status === 'Error') return 'failed';
|
|
164
|
+
return 'configured';
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Determine Gmail status
|
|
168
|
+
const determineGmailStatus = (): 'not-set' | 'configured' | 'running' | 'connected' | 'failed' => {
|
|
169
|
+
// Prefer status provided by engine
|
|
170
|
+
if (data.outputStatuses?.gmail) return data.outputStatuses.gmail;
|
|
171
|
+
|
|
172
|
+
const ex = (data.formData?.exportOptions || data.exportOptions) || {};
|
|
173
|
+
const hasRequired = Boolean(
|
|
174
|
+
ex.emailSendEnabled && ex.emailSender && (ex.emailRecipients?.length || 0) > 0 && ex.emailSubject && ex.emailMessage
|
|
175
|
+
);
|
|
176
|
+
if (!hasRequired) return 'not-set';
|
|
177
|
+
|
|
178
|
+
if (data.status === 'Running') return 'running';
|
|
179
|
+
|
|
180
|
+
const exec = data.formData?.executionResult || (data as any).executionResult;
|
|
181
|
+
if (exec?.success === true) return 'connected';
|
|
182
|
+
if (exec?.success === false || data.status === 'Error') return 'failed';
|
|
183
|
+
return 'configured';
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// Determine Slack status
|
|
187
|
+
const determineSlackStatus = (): 'not-set' | 'configured' | 'running' | 'connected' | 'failed' => {
|
|
188
|
+
if ((data as any).outputStatuses?.slack) return (data as any).outputStatuses.slack;
|
|
189
|
+
const slack = (data.formData?.exportOptions?.slack || (data as any).exportOptions?.slack) || {};
|
|
190
|
+
if (!slack.enabled || !slack.webhookUrl || !slack.channel) return 'not-set';
|
|
191
|
+
if (data.status === 'Running') return 'running';
|
|
192
|
+
const exec = data.formData?.executionResult || (data as any).executionResult;
|
|
193
|
+
if (exec?.success === true) return 'connected';
|
|
194
|
+
if (exec?.success === false || data.status === 'Error') return 'failed';
|
|
195
|
+
return 'configured';
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// Determine WhatsApp status
|
|
199
|
+
const determineWhatsAppStatus = (): 'not-set' | 'configured' | 'running' | 'connected' | 'failed' => {
|
|
200
|
+
if (data.outputStatuses?.whatsapp) return data.outputStatuses.whatsapp;
|
|
201
|
+
|
|
202
|
+
const whatsapp = (data.formData?.exportOptions?.whatsapp || data.exportOptions?.whatsapp) || {};
|
|
203
|
+
|
|
204
|
+
// Check if Twilio is configured
|
|
205
|
+
if (whatsapp.twilio?.enabled) {
|
|
206
|
+
const twilioConfig = whatsapp.twilio;
|
|
207
|
+
const hasRequiredTwilio = Boolean(
|
|
208
|
+
twilioConfig.accountSid &&
|
|
209
|
+
twilioConfig.authToken &&
|
|
210
|
+
twilioConfig.fromNumber &&
|
|
211
|
+
whatsapp.phoneNumber
|
|
212
|
+
);
|
|
213
|
+
if (!hasRequiredTwilio) return 'not-set';
|
|
214
|
+
} else {
|
|
215
|
+
// Fallback to basic WhatsApp Web check
|
|
216
|
+
if (!whatsapp.enabled || !whatsapp.phoneNumber) return 'not-set';
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (data.status === 'Running') return 'running';
|
|
220
|
+
|
|
221
|
+
const exec = data.formData?.executionResult || (data as any).executionResult;
|
|
222
|
+
if (exec?.success === true) return 'connected';
|
|
223
|
+
if (exec?.success === false || data.status === 'Error') return 'failed';
|
|
224
|
+
return 'configured';
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const getNodeStatus = (): string => {
|
|
228
|
+
const gs = determineGoogleSheetsStatus();
|
|
229
|
+
const gm = determineGmailStatus();
|
|
230
|
+
const sl = determineSlackStatus();
|
|
231
|
+
const wa = determineWhatsAppStatus();
|
|
232
|
+
if (gs === 'failed' || gm === 'failed' || sl === 'failed' || wa === 'failed') return 'Failed';
|
|
233
|
+
if (gs === 'running' || gm === 'running' || sl === 'running' || wa === 'running') return 'Running';
|
|
234
|
+
if (
|
|
235
|
+
(gs === 'connected' || gs === 'not-set') &&
|
|
236
|
+
(gm === 'connected' || gm === 'not-set') &&
|
|
237
|
+
(sl === 'connected' || sl === 'not-set') &&
|
|
238
|
+
(wa === 'connected' || wa === 'not-set')
|
|
239
|
+
) return 'Success';
|
|
240
|
+
if (
|
|
241
|
+
(gs === 'configured' || gs === 'not-set') &&
|
|
242
|
+
(gm === 'configured' || gm === 'not-set') &&
|
|
243
|
+
(sl === 'configured' || sl === 'not-set') &&
|
|
244
|
+
(wa === 'configured' || wa === 'not-set')
|
|
245
|
+
) return 'Ready';
|
|
246
|
+
return 'Mixed Status';
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// Status badge (shared)
|
|
250
|
+
const StatusBadge = ({ status }: { status: 'not-set' | 'configured' | 'running' | 'connected' | 'failed' }) => {
|
|
251
|
+
const cfg = (
|
|
252
|
+
status === 'not-set' ? { icon: <ErrorIcon sx={{ fontSize: '12px' }} />, label: t('automation.sheetsNode.status.notSet'), bg: '#6b7280' } :
|
|
253
|
+
status === 'configured' ? { icon: <ConfigureIcon sx={{ fontSize: '12px' }} />, label: t('automation.sheetsNode.status.configured'), bg: '#3b82f6' } :
|
|
254
|
+
status === 'running' ? { icon: <SettingsIcon sx={{ fontSize: '12px' }} />, label: t('automation.sheetsNode.status.running'), bg: '#f59e0b' } :
|
|
255
|
+
status === 'connected' ? { icon: <CheckCircleIcon sx={{ fontSize: '12px' }} />, label: t('automation.sheetsNode.status.connected'), bg: '#10b981' } :
|
|
256
|
+
{ icon: <ErrorIcon sx={{ fontSize: '12px' }} />, label: t('automation.sheetsNode.status.failed'), bg: '#ef4444' }
|
|
257
|
+
);
|
|
258
|
+
return (
|
|
259
|
+
<Chip
|
|
260
|
+
icon={cfg.icon}
|
|
261
|
+
label={cfg.label}
|
|
262
|
+
size="small"
|
|
263
|
+
sx={{
|
|
264
|
+
backgroundColor: cfg.bg,
|
|
265
|
+
color: 'white',
|
|
266
|
+
fontSize: '11px',
|
|
267
|
+
height: '20px',
|
|
268
|
+
'& .MuiChip-icon': { fontSize: '12px' },
|
|
269
|
+
}}
|
|
270
|
+
/>
|
|
271
|
+
);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
// WhatsApp message sending function
|
|
275
|
+
const sendWhatsAppMessage = (phoneNumber: string, data: any) => {
|
|
276
|
+
const message = `
|
|
277
|
+
Automation Result:
|
|
278
|
+
------------------
|
|
279
|
+
Name: ${data.name || 'Automation Workflow'}
|
|
280
|
+
Score: ${data.score || 'N/A'}
|
|
281
|
+
Status: ${data.status || 'Completed'}
|
|
282
|
+
Timestamp: ${new Date().toLocaleString()}
|
|
283
|
+
Data: ${JSON.stringify(data, null, 2)}
|
|
284
|
+
`;
|
|
285
|
+
const encodedMsg = encodeURIComponent(message);
|
|
286
|
+
const url = `https://wa.me/${phoneNumber}?text=${encodedMsg}`;
|
|
287
|
+
window.open(url, '_blank');
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const handleJsonClick = () => {
|
|
291
|
+
if (nodeId) setSelectedNode(nodeId);
|
|
292
|
+
if (!enableJson) return;
|
|
293
|
+
setIsJsonOpen(!isJsonOpen);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const handleClose = () => {
|
|
297
|
+
setIsJsonOpen(false);
|
|
298
|
+
// Clean up portal
|
|
299
|
+
if (rootRef.current) {
|
|
300
|
+
rootRef.current.unmount();
|
|
301
|
+
rootRef.current = null;
|
|
302
|
+
}
|
|
303
|
+
if (portalRef.current) {
|
|
304
|
+
document.body.removeChild(portalRef.current);
|
|
305
|
+
portalRef.current = null;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
311
|
+
if (isJsonOpen && !(event.target as Element).closest('#automation-json-popover')) {
|
|
312
|
+
handleClose();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
316
|
+
return () => {
|
|
317
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
318
|
+
};
|
|
319
|
+
}, [isJsonOpen]);
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
useEffect(() => {
|
|
323
|
+
if (isJsonOpen) {
|
|
324
|
+
const portalRoot = document.createElement('div');
|
|
325
|
+
document.body.appendChild(portalRoot);
|
|
326
|
+
portalRef.current = portalRoot;
|
|
327
|
+
|
|
328
|
+
const root = createRoot(portalRoot);
|
|
329
|
+
rootRef.current = root;
|
|
330
|
+
|
|
331
|
+
root.render(
|
|
332
|
+
<Card
|
|
333
|
+
id="automation-json-popover"
|
|
334
|
+
sx={{
|
|
335
|
+
position: 'fixed',
|
|
336
|
+
top: 0,
|
|
337
|
+
right: 0,
|
|
338
|
+
zIndex: 9999,
|
|
339
|
+
width: '400px',
|
|
340
|
+
height: '100vh',
|
|
341
|
+
overflow: 'auto',
|
|
342
|
+
bgcolor: '#242424',
|
|
343
|
+
color: '#fff',
|
|
344
|
+
border: '1px solid #333',
|
|
345
|
+
'&::-webkit-scrollbar': {
|
|
346
|
+
width: '6px',
|
|
347
|
+
},
|
|
348
|
+
'&::-webkit-scrollbar-track': {
|
|
349
|
+
background: 'transparent',
|
|
350
|
+
},
|
|
351
|
+
'&::-webkit-scrollbar-thumb': {
|
|
352
|
+
background: '#444',
|
|
353
|
+
borderRadius: '3px',
|
|
354
|
+
'&:hover': {
|
|
355
|
+
background: '#666',
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
}}
|
|
359
|
+
>
|
|
360
|
+
<CardContent sx={{ bgcolor: '#242424', color: '#fff' }}>
|
|
361
|
+
<IconButton
|
|
362
|
+
aria-label="close"
|
|
363
|
+
onClick={handleClose}
|
|
364
|
+
sx={{
|
|
365
|
+
color: '#999',
|
|
366
|
+
'&:hover': {
|
|
367
|
+
color: '#fff',
|
|
368
|
+
bgcolor: 'rgba(255, 255, 255, 0.1)',
|
|
369
|
+
},
|
|
370
|
+
}}
|
|
371
|
+
>
|
|
372
|
+
<RiCloseLine />
|
|
373
|
+
</IconButton>
|
|
374
|
+
{/* Show execution result prominently if available */}
|
|
375
|
+
{data.formData?.executionResult && (
|
|
376
|
+
<Box sx={{ mb: 2 }}>
|
|
377
|
+
<Typography variant="h6" sx={{ color: '#fff', mb: 1 }}>
|
|
378
|
+
{t('automation.common.executionResult')}
|
|
379
|
+
</Typography>
|
|
380
|
+
<Box sx={{
|
|
381
|
+
bgcolor: data.formData.executionResult.success ? '#1e3a8a' : '#dc2626',
|
|
382
|
+
p: 1,
|
|
383
|
+
borderRadius: 1,
|
|
384
|
+
mb: 1
|
|
385
|
+
}}>
|
|
386
|
+
<Typography variant="body2" sx={{ color: '#fff' }}>
|
|
387
|
+
{t('automation.common.status')}: {data.formData.executionResult.success ? t('automation.common.success') : t('automation.common.failed')}
|
|
388
|
+
</Typography>
|
|
389
|
+
<Typography variant="body2" sx={{ color: '#fff' }}>
|
|
390
|
+
{t('automation.common.timestamp')}: {new Date(data.formData.executionResult.timestamp).toLocaleString()}
|
|
391
|
+
</Typography>
|
|
392
|
+
{data.formData.executionResult.error && (
|
|
393
|
+
<Typography variant="body2" sx={{ color: '#fff' }}>
|
|
394
|
+
{t('automation.common.error')}: {data.formData.executionResult.error}
|
|
395
|
+
</Typography>
|
|
396
|
+
)}
|
|
397
|
+
</Box>
|
|
398
|
+
<Typography variant="h6" sx={{ color: '#fff', mb: 1 }}>
|
|
399
|
+
Sheets Data
|
|
400
|
+
</Typography>
|
|
401
|
+
<ReactJson
|
|
402
|
+
theme={'monokai'}
|
|
403
|
+
src={data.formData.executionResult.data}
|
|
404
|
+
collapsed={false}
|
|
405
|
+
/>
|
|
406
|
+
</Box>
|
|
407
|
+
)}
|
|
408
|
+
|
|
409
|
+
{/* Show full node data */}
|
|
410
|
+
<Typography variant="h6" sx={{ color: '#fff', mb: 1 }}>
|
|
411
|
+
Full Node Data
|
|
412
|
+
</Typography>
|
|
413
|
+
<ReactJson theme={'monokai'} src={data.formData || data} collapsed={false} />
|
|
414
|
+
</CardContent>
|
|
415
|
+
</Card>
|
|
416
|
+
);
|
|
417
|
+
} else {
|
|
418
|
+
// Clean up when closing
|
|
419
|
+
if (rootRef.current) {
|
|
420
|
+
rootRef.current.unmount();
|
|
421
|
+
rootRef.current = null;
|
|
422
|
+
}
|
|
423
|
+
if (portalRef.current) {
|
|
424
|
+
document.body.removeChild(portalRef.current);
|
|
425
|
+
portalRef.current = null;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}, [isJsonOpen, data]);
|
|
429
|
+
|
|
430
|
+
// Output Method Component for Google Sheets
|
|
431
|
+
const GoogleSheetsOutputMethod = () => (
|
|
432
|
+
<Box sx={{
|
|
433
|
+
display: 'flex',
|
|
434
|
+
alignItems: 'center',
|
|
435
|
+
justifyContent: 'space-between',
|
|
436
|
+
py: 2,
|
|
437
|
+
px: 2,
|
|
438
|
+
borderBottom: '1px solid #334155',
|
|
439
|
+
'&:hover': {
|
|
440
|
+
backgroundColor: 'rgba(255, 255, 255, 0.05)',
|
|
441
|
+
},
|
|
442
|
+
cursor: 'pointer',
|
|
443
|
+
}}>
|
|
444
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
|
445
|
+
{/* Google Sheets Icon */}
|
|
446
|
+
<Box sx={{
|
|
447
|
+
width: '32px',
|
|
448
|
+
height: '32px',
|
|
449
|
+
backgroundColor: '#10b981',
|
|
450
|
+
borderRadius: '6px',
|
|
451
|
+
display: 'flex',
|
|
452
|
+
alignItems: 'center',
|
|
453
|
+
justifyContent: 'center',
|
|
454
|
+
}}>
|
|
455
|
+
<TableChartIcon sx={{ color: 'white', fontSize: '18px' }} />
|
|
456
|
+
</Box>
|
|
457
|
+
|
|
458
|
+
<Box>
|
|
459
|
+
<Typography variant="body2" sx={{
|
|
460
|
+
color: '#ffffff',
|
|
461
|
+
fontSize: '14px',
|
|
462
|
+
fontWeight: 600,
|
|
463
|
+
mb: 0.5
|
|
464
|
+
}}>
|
|
465
|
+
{t('automation.sheetsNode.googleSheets')}
|
|
466
|
+
</Typography>
|
|
467
|
+
<Typography variant="body2" sx={{
|
|
468
|
+
color: '#94a3b8',
|
|
469
|
+
fontSize: '12px',
|
|
470
|
+
mb: 0.5
|
|
471
|
+
}}>
|
|
472
|
+
{t('automation.sheetsNode.readWriteRows')}
|
|
473
|
+
</Typography>
|
|
474
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
|
475
|
+
<DescriptionIcon sx={{ fontSize: '12px', color: '#94a3b8' }} />
|
|
476
|
+
<Typography variant="body2" sx={{
|
|
477
|
+
color: '#94a3b8',
|
|
478
|
+
fontSize: '11px'
|
|
479
|
+
}}>
|
|
480
|
+
{t('automation.sheetsNode.sheet')}: {data.sheetsConfig?.sheetName || data.formData?.sheetsConfig?.sheetName || 'Sheet'}
|
|
481
|
+
</Typography>
|
|
482
|
+
</Box>
|
|
483
|
+
</Box>
|
|
484
|
+
</Box>
|
|
485
|
+
|
|
486
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
487
|
+
{/* Status Badge */}
|
|
488
|
+
<StatusBadge status={determineGoogleSheetsStatus()} />
|
|
489
|
+
<ArrowForwardIcon sx={{ fontSize: '14px', color: '#94a3b8' }} />
|
|
490
|
+
</Box>
|
|
491
|
+
</Box>
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
// Output Method Component for Gmail
|
|
495
|
+
const GmailOutputMethod = () => (
|
|
496
|
+
<Box sx={{
|
|
497
|
+
display: 'flex',
|
|
498
|
+
alignItems: 'center',
|
|
499
|
+
justifyContent: 'space-between',
|
|
500
|
+
py: 2,
|
|
501
|
+
px: 2,
|
|
502
|
+
borderBottom: '1px solid #334155',
|
|
503
|
+
'&:hover': {
|
|
504
|
+
backgroundColor: 'rgba(255, 255, 255, 0.05)',
|
|
505
|
+
},
|
|
506
|
+
cursor: 'pointer',
|
|
507
|
+
}}>
|
|
508
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
|
509
|
+
{/* Gmail Icon */}
|
|
510
|
+
<Box sx={{
|
|
511
|
+
width: '32px',
|
|
512
|
+
height: '32px',
|
|
513
|
+
backgroundColor: '#dc2626',
|
|
514
|
+
borderRadius: '6px',
|
|
515
|
+
display: 'flex',
|
|
516
|
+
alignItems: 'center',
|
|
517
|
+
justifyContent: 'center',
|
|
518
|
+
}}>
|
|
519
|
+
<EmailIcon sx={{ color: 'white', fontSize: '18px' }} />
|
|
520
|
+
</Box>
|
|
521
|
+
|
|
522
|
+
<Box>
|
|
523
|
+
<Typography variant="body2" sx={{
|
|
524
|
+
color: '#ffffff',
|
|
525
|
+
fontSize: '14px',
|
|
526
|
+
fontWeight: 600,
|
|
527
|
+
mb: 0.5
|
|
528
|
+
}}>
|
|
529
|
+
{t('automation.sheetsNode.gmail')}
|
|
530
|
+
</Typography>
|
|
531
|
+
<Typography variant="body2" sx={{
|
|
532
|
+
color: '#94a3b8',
|
|
533
|
+
fontSize: '12px',
|
|
534
|
+
mb: 0.5
|
|
535
|
+
}}>
|
|
536
|
+
{t('automation.sheetsNode.sendEmail')}
|
|
537
|
+
</Typography>
|
|
538
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
|
539
|
+
<DraftsIcon sx={{ fontSize: '12px', color: '#94a3b8' }} />
|
|
540
|
+
<Typography variant="body2" sx={{
|
|
541
|
+
color: '#94a3b8',
|
|
542
|
+
fontSize: '11px'
|
|
543
|
+
}}>
|
|
544
|
+
{t('automation.sheetsNode.drafts')}: {data.exportOptions?.emailRecipients?.length || 0}
|
|
545
|
+
</Typography>
|
|
546
|
+
</Box>
|
|
547
|
+
</Box>
|
|
548
|
+
</Box>
|
|
549
|
+
|
|
550
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
551
|
+
{/* Status Badge */}
|
|
552
|
+
<StatusBadge status={determineGmailStatus()} />
|
|
553
|
+
<ArrowForwardIcon sx={{ fontSize: '14px', color: '#94a3b8' }} />
|
|
554
|
+
</Box>
|
|
555
|
+
</Box>
|
|
556
|
+
);
|
|
557
|
+
|
|
558
|
+
// Output Method Component for Slack
|
|
559
|
+
const SlackOutputMethod = () => {
|
|
560
|
+
const slack = (data.formData?.exportOptions?.slack || (data as any).exportOptions?.slack) || {};
|
|
561
|
+
return (
|
|
562
|
+
<Box sx={{
|
|
563
|
+
display: 'flex',
|
|
564
|
+
alignItems: 'center',
|
|
565
|
+
justifyContent: 'space-between',
|
|
566
|
+
py: 2,
|
|
567
|
+
px: 2,
|
|
568
|
+
borderBottom: '1px solid #334155',
|
|
569
|
+
'&:hover': {
|
|
570
|
+
backgroundColor: 'rgba(255, 255, 255, 0.05)',
|
|
571
|
+
},
|
|
572
|
+
cursor: 'pointer',
|
|
573
|
+
}}>
|
|
574
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
|
575
|
+
{/* Slack Icon-like box */}
|
|
576
|
+
<Box sx={{
|
|
577
|
+
width: '32px',
|
|
578
|
+
height: '32px',
|
|
579
|
+
backgroundColor: '#4A154B',
|
|
580
|
+
borderRadius: '6px',
|
|
581
|
+
display: 'flex',
|
|
582
|
+
alignItems: 'center',
|
|
583
|
+
justifyContent: 'center',
|
|
584
|
+
}}>
|
|
585
|
+
<SendIcon sx={{ color: 'white', fontSize: '18px' }} />
|
|
586
|
+
</Box>
|
|
587
|
+
|
|
588
|
+
<Box>
|
|
589
|
+
<Typography variant="body2" sx={{
|
|
590
|
+
color: '#ffffff',
|
|
591
|
+
fontSize: '14px',
|
|
592
|
+
fontWeight: 600,
|
|
593
|
+
mb: 0.5
|
|
594
|
+
}}>
|
|
595
|
+
{t('automation.sheetsNode.slack')}
|
|
596
|
+
</Typography>
|
|
597
|
+
<Typography variant="body2" sx={{
|
|
598
|
+
color: '#94a3b8',
|
|
599
|
+
fontSize: '12px',
|
|
600
|
+
mb: 0.5
|
|
601
|
+
}}>
|
|
602
|
+
{t('automation.sheetsNode.sendMessage')}
|
|
603
|
+
</Typography>
|
|
604
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
|
605
|
+
<TableRowsIcon sx={{ fontSize: '12px', color: '#94a3b8' }} />
|
|
606
|
+
<Typography variant="body2" sx={{
|
|
607
|
+
color: '#94a3b8',
|
|
608
|
+
fontSize: '11px'
|
|
609
|
+
}}>
|
|
610
|
+
{t('automation.sheetsNode.channel')}: {slack.channel ? `#${slack.channel}` : t('automation.sheetsNode.notSet')}
|
|
611
|
+
</Typography>
|
|
612
|
+
</Box>
|
|
613
|
+
</Box>
|
|
614
|
+
</Box>
|
|
615
|
+
|
|
616
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
617
|
+
<StatusBadge status={determineSlackStatus()} />
|
|
618
|
+
<ArrowForwardIcon sx={{ fontSize: '14px', color: '#94a3b8' }} />
|
|
619
|
+
</Box>
|
|
620
|
+
</Box>
|
|
621
|
+
);
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
// Output Method Component for WhatsApp
|
|
625
|
+
const WhatsAppOutputMethod = () => {
|
|
626
|
+
const whatsapp = (data.formData?.exportOptions?.whatsapp || data.exportOptions?.whatsapp) || {};
|
|
627
|
+
const isTwilioEnabled = whatsapp.twilio?.enabled;
|
|
628
|
+
|
|
629
|
+
return (
|
|
630
|
+
<Box sx={{
|
|
631
|
+
display: 'flex',
|
|
632
|
+
alignItems: 'center',
|
|
633
|
+
justifyContent: 'space-between',
|
|
634
|
+
py: 2,
|
|
635
|
+
px: 2,
|
|
636
|
+
borderBottom: '1px solid #334155',
|
|
637
|
+
'&:hover': {
|
|
638
|
+
backgroundColor: 'rgba(255, 255, 255, 0.05)',
|
|
639
|
+
},
|
|
640
|
+
cursor: 'pointer',
|
|
641
|
+
}}
|
|
642
|
+
onClick={() => {
|
|
643
|
+
if (whatsapp.enabled && whatsapp.phoneNumber && !isTwilioEnabled) {
|
|
644
|
+
const executionData = data.formData?.executionResult || {};
|
|
645
|
+
sendWhatsAppMessage(whatsapp.phoneNumber, executionData);
|
|
646
|
+
}
|
|
647
|
+
}}>
|
|
648
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
|
649
|
+
{/* WhatsApp Icon */}
|
|
650
|
+
<Box sx={{
|
|
651
|
+
width: '32px',
|
|
652
|
+
height: '32px',
|
|
653
|
+
backgroundColor: '#25D366',
|
|
654
|
+
borderRadius: '6px',
|
|
655
|
+
display: 'flex',
|
|
656
|
+
alignItems: 'center',
|
|
657
|
+
justifyContent: 'center',
|
|
658
|
+
}}>
|
|
659
|
+
<WhatsAppIcon sx={{ color: 'white', fontSize: '18px' }} />
|
|
660
|
+
</Box>
|
|
661
|
+
|
|
662
|
+
<Box>
|
|
663
|
+
<Typography variant="body2" sx={{
|
|
664
|
+
color: '#ffffff',
|
|
665
|
+
fontSize: '14px',
|
|
666
|
+
fontWeight: 600,
|
|
667
|
+
mb: 0.5
|
|
668
|
+
}}>
|
|
669
|
+
{isTwilioEnabled ? t('automation.sheetsNode.whatsappTwilio') : t('automation.sheetsNode.whatsappWeb')}
|
|
670
|
+
</Typography>
|
|
671
|
+
<Typography variant="body2" sx={{
|
|
672
|
+
color: '#94a3b8',
|
|
673
|
+
fontSize: '12px',
|
|
674
|
+
mb: 0.5
|
|
675
|
+
}}>
|
|
676
|
+
{isTwilioEnabled ? t('automation.sheetsNode.apiSend') : t('automation.sheetsNode.sendMessage')}
|
|
677
|
+
</Typography>
|
|
678
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
|
679
|
+
<PhoneIcon sx={{ fontSize: '12px', color: '#94a3b8' }} />
|
|
680
|
+
<Typography variant="body2" sx={{
|
|
681
|
+
color: '#94a3b8',
|
|
682
|
+
fontSize: '11px'
|
|
683
|
+
}}>
|
|
684
|
+
{t('automation.sheetsNode.phone')}: {whatsapp.phoneNumber || t('automation.sheetsNode.notSet')}
|
|
685
|
+
</Typography>
|
|
686
|
+
</Box>
|
|
687
|
+
{isTwilioEnabled && (
|
|
688
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, mt: 0.5 }}>
|
|
689
|
+
<Typography variant="body2" sx={{
|
|
690
|
+
color: whatsapp.twilio?.isSandbox ? '#f59e0b' : '#10b981',
|
|
691
|
+
fontSize: '10px',
|
|
692
|
+
fontWeight: 500
|
|
693
|
+
}}>
|
|
694
|
+
{whatsapp.twilio?.isSandbox ? t('automation.sheetsNode.sandboxMode') : t('automation.sheetsNode.productionMode')}
|
|
695
|
+
</Typography>
|
|
696
|
+
</Box>
|
|
697
|
+
)}
|
|
698
|
+
</Box>
|
|
699
|
+
</Box>
|
|
700
|
+
|
|
701
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
702
|
+
<StatusBadge status={determineWhatsAppStatus()} />
|
|
703
|
+
<ArrowForwardIcon sx={{ fontSize: '14px', color: '#94a3b8' }} />
|
|
704
|
+
</Box>
|
|
705
|
+
</Box>
|
|
706
|
+
);
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
return (
|
|
710
|
+
<Box
|
|
711
|
+
sx={{
|
|
712
|
+
position: 'relative',
|
|
713
|
+
width: '380px',
|
|
714
|
+
overflow: 'visible',
|
|
715
|
+
}}
|
|
716
|
+
>
|
|
717
|
+
<Box
|
|
718
|
+
ref={nodeRef}
|
|
719
|
+
sx={{
|
|
720
|
+
width: '380px',
|
|
721
|
+
minHeight: '280px',
|
|
722
|
+
backgroundColor: '#181C25', // Darker background like in image
|
|
723
|
+
border: selected ? '2px solid #3b82f6' : '1px solid #1e293b',
|
|
724
|
+
borderRadius: '12px',
|
|
725
|
+
padding: '0',
|
|
726
|
+
color: '#ffffff',
|
|
727
|
+
position: 'relative',
|
|
728
|
+
boxShadow: selected ? '0 0 0 2px rgba(59, 130, 246, 0.5)' : '0 4px 8px rgba(0, 0, 0, 0.3)',
|
|
729
|
+
transition: 'all 0.2s ease',
|
|
730
|
+
cursor: 'pointer',
|
|
731
|
+
overflow: 'hidden',
|
|
732
|
+
...(data.status === 'Running' && {
|
|
733
|
+
animation: 'pulse-glow 2s ease-in-out infinite',
|
|
734
|
+
'@keyframes pulse-glow': {
|
|
735
|
+
'0%, 100%': {
|
|
736
|
+
boxShadow: '0 0 20px rgba(59, 130, 246, 0.4), 0 0 40px rgba(59, 130, 246, 0.2)',
|
|
737
|
+
borderColor: 'rgba(59, 130, 246, 0.6)',
|
|
738
|
+
},
|
|
739
|
+
'50%': {
|
|
740
|
+
boxShadow: '0 0 30px rgba(59, 130, 246, 0.6), 0 0 60px rgba(59, 130, 246, 0.3)',
|
|
741
|
+
borderColor: 'rgba(59, 130, 246, 0.9)',
|
|
742
|
+
},
|
|
743
|
+
},
|
|
744
|
+
}),
|
|
745
|
+
}}
|
|
746
|
+
onClick={handleJsonClick}
|
|
747
|
+
>
|
|
748
|
+
{/* Header */}
|
|
749
|
+
<Box sx={{
|
|
750
|
+
display: 'flex',
|
|
751
|
+
alignItems: 'center',
|
|
752
|
+
justifyContent: 'space-between',
|
|
753
|
+
p: 3,
|
|
754
|
+
borderBottom: '1px solid #334155'
|
|
755
|
+
}}>
|
|
756
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
|
|
757
|
+
<Box
|
|
758
|
+
sx={{
|
|
759
|
+
width: '32px',
|
|
760
|
+
height: '32px',
|
|
761
|
+
backgroundColor: '#3b82f6', // Blue color like in image
|
|
762
|
+
borderRadius: '6px',
|
|
763
|
+
display: 'flex',
|
|
764
|
+
alignItems: 'center',
|
|
765
|
+
justifyContent: 'center',
|
|
766
|
+
}}
|
|
767
|
+
>
|
|
768
|
+
<IconComponent sx={{ color: 'white', fontSize: '18px' }} />
|
|
769
|
+
</Box>
|
|
770
|
+
<Typography variant="h6" sx={{ fontWeight: 600, fontSize: '16px' }}>
|
|
771
|
+
{highlightText(data.label)}
|
|
772
|
+
</Typography>
|
|
773
|
+
</Box>
|
|
774
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
775
|
+
{/* Status Chip */}
|
|
776
|
+
<Chip
|
|
777
|
+
label={(() => {
|
|
778
|
+
// Map node status to standard status values
|
|
779
|
+
const nodeStatus = getNodeStatus();
|
|
780
|
+
if (nodeStatus === 'Failed' || data.status === 'Error') return 'Error';
|
|
781
|
+
if (nodeStatus === 'Running' || data.status === 'Running') return 'Running';
|
|
782
|
+
if (nodeStatus === 'Success' || data.status === 'Completed') return 'Completed';
|
|
783
|
+
return data.status || 'Ready';
|
|
784
|
+
})()}
|
|
785
|
+
size="small"
|
|
786
|
+
sx={{
|
|
787
|
+
backgroundColor: (() => {
|
|
788
|
+
const status = data.status || 'Ready';
|
|
789
|
+
return status === 'Completed'
|
|
790
|
+
? 'rgba(37, 99, 235, 0.1)'
|
|
791
|
+
: status === 'Running'
|
|
792
|
+
? 'rgba(251, 191, 36, 0.1)'
|
|
793
|
+
: status === 'Error'
|
|
794
|
+
? 'rgba(239, 68, 68, 0.1)'
|
|
795
|
+
: 'rgba(16, 185, 129, 0.1)';
|
|
796
|
+
})(),
|
|
797
|
+
color: (() => {
|
|
798
|
+
const status = data.status || 'Ready';
|
|
799
|
+
return status === 'Completed'
|
|
800
|
+
? '#93C5FD'
|
|
801
|
+
: status === 'Running'
|
|
802
|
+
? '#FCD34D'
|
|
803
|
+
: status === 'Error'
|
|
804
|
+
? '#FCA5A5'
|
|
805
|
+
: '#86EFAC';
|
|
806
|
+
})(),
|
|
807
|
+
fontWeight: 500,
|
|
808
|
+
fontSize: '12px',
|
|
809
|
+
height: '24px',
|
|
810
|
+
borderRadius: '12px',
|
|
811
|
+
}}
|
|
812
|
+
/>
|
|
813
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
|
814
|
+
<AccessTimeIcon sx={{ fontSize: '12px', color: '#94a3b8' }} />
|
|
815
|
+
<Typography variant="body2" sx={{ color: '#94a3b8', fontSize: '11px' }}>
|
|
816
|
+
{t('automation.common.lastRun')}: {data.lastRun || '2m ago'}
|
|
817
|
+
</Typography>
|
|
818
|
+
</Box>
|
|
819
|
+
</Box>
|
|
820
|
+
</Box>
|
|
821
|
+
|
|
822
|
+
{/* Output Methods */}
|
|
823
|
+
<Box>
|
|
824
|
+
{showSheets && <GoogleSheetsOutputMethod />}
|
|
825
|
+
{showGmail && <GmailOutputMethod />}
|
|
826
|
+
{showSlack && <SlackOutputMethod />}
|
|
827
|
+
{showWhatsApp && <WhatsAppOutputMethod />}
|
|
828
|
+
{!showGmail && !showSlack && !showWhatsApp && (
|
|
829
|
+
<Typography variant="body2" sx={{ color: '#94a3b8', p: 2 }}>
|
|
830
|
+
{t('automation.sheetsNode.noOutputMethodsConfigured')}
|
|
831
|
+
</Typography>
|
|
832
|
+
)}
|
|
833
|
+
</Box>
|
|
834
|
+
|
|
835
|
+
{/* Add Configuration Button */}
|
|
836
|
+
<Box sx={{
|
|
837
|
+
p: 2,
|
|
838
|
+
display: 'flex',
|
|
839
|
+
justifyContent: 'center',
|
|
840
|
+
borderTop: '1px solid #334155'
|
|
841
|
+
}}>
|
|
842
|
+
<Button
|
|
843
|
+
startIcon={<AddIcon sx={{ fontSize: '16px' }} />}
|
|
844
|
+
sx={{
|
|
845
|
+
color: '#94a3b8',
|
|
846
|
+
fontSize: '12px',
|
|
847
|
+
textTransform: 'none',
|
|
848
|
+
'&:hover': {
|
|
849
|
+
backgroundColor: 'rgba(255, 255, 255, 0.05)',
|
|
850
|
+
color: '#ffffff',
|
|
851
|
+
},
|
|
852
|
+
}}
|
|
853
|
+
>
|
|
854
|
+
{t('automation.sheetsNode.addConfiguration')}
|
|
855
|
+
</Button>
|
|
856
|
+
</Box>
|
|
857
|
+
|
|
858
|
+
{/* Connection Handles - Bidirectional (source + target at each position) */}
|
|
859
|
+
{/* Top - Source */}
|
|
860
|
+
<Handle
|
|
861
|
+
type="source"
|
|
862
|
+
position={Position.Top}
|
|
863
|
+
id="top-source"
|
|
864
|
+
className="connection-handle"
|
|
865
|
+
style={{
|
|
866
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
867
|
+
width: '14px',
|
|
868
|
+
height: '14px',
|
|
869
|
+
border: '3px solid #10B981',
|
|
870
|
+
top: '-8px',
|
|
871
|
+
opacity: selected ? 1 : 0,
|
|
872
|
+
transition: 'all 0.2s ease-in-out',
|
|
873
|
+
cursor: 'crosshair',
|
|
874
|
+
zIndex: 10,
|
|
875
|
+
}}
|
|
876
|
+
/>
|
|
877
|
+
{/* Top - Target (hidden but functional) */}
|
|
878
|
+
<Handle
|
|
879
|
+
type="target"
|
|
880
|
+
position={Position.Top}
|
|
881
|
+
id="top-target"
|
|
882
|
+
style={{
|
|
883
|
+
background: 'transparent',
|
|
884
|
+
width: '14px',
|
|
885
|
+
height: '14px',
|
|
886
|
+
border: 'none',
|
|
887
|
+
top: '-8px',
|
|
888
|
+
opacity: 0,
|
|
889
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
890
|
+
}}
|
|
891
|
+
/>
|
|
892
|
+
{/* Bottom - Source */}
|
|
893
|
+
<Handle
|
|
894
|
+
type="source"
|
|
895
|
+
position={Position.Bottom}
|
|
896
|
+
id="bottom-source"
|
|
897
|
+
className="connection-handle"
|
|
898
|
+
style={{
|
|
899
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
900
|
+
width: '14px',
|
|
901
|
+
height: '14px',
|
|
902
|
+
border: '3px solid #10B981',
|
|
903
|
+
bottom: '-8px',
|
|
904
|
+
opacity: selected ? 1 : 0,
|
|
905
|
+
transition: 'all 0.2s ease-in-out',
|
|
906
|
+
cursor: 'crosshair',
|
|
907
|
+
zIndex: 10,
|
|
908
|
+
}}
|
|
909
|
+
/>
|
|
910
|
+
{/* Bottom - Target (hidden but functional) */}
|
|
911
|
+
<Handle
|
|
912
|
+
type="target"
|
|
913
|
+
position={Position.Bottom}
|
|
914
|
+
id="bottom-target"
|
|
915
|
+
style={{
|
|
916
|
+
background: 'transparent',
|
|
917
|
+
width: '14px',
|
|
918
|
+
height: '14px',
|
|
919
|
+
border: 'none',
|
|
920
|
+
bottom: '-8px',
|
|
921
|
+
opacity: 0,
|
|
922
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
923
|
+
}}
|
|
924
|
+
/>
|
|
925
|
+
{/* Left - Source */}
|
|
926
|
+
<Handle
|
|
927
|
+
type="source"
|
|
928
|
+
position={Position.Left}
|
|
929
|
+
id="left-source"
|
|
930
|
+
className="connection-handle"
|
|
931
|
+
style={{
|
|
932
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
933
|
+
width: '14px',
|
|
934
|
+
height: '14px',
|
|
935
|
+
border: '3px solid #10B981',
|
|
936
|
+
left: '-8px',
|
|
937
|
+
opacity: selected ? 1 : 0,
|
|
938
|
+
transition: 'all 0.2s ease-in-out',
|
|
939
|
+
cursor: 'crosshair',
|
|
940
|
+
zIndex: 10,
|
|
941
|
+
}}
|
|
942
|
+
/>
|
|
943
|
+
{/* Left - Target (hidden but functional) */}
|
|
944
|
+
<Handle
|
|
945
|
+
type="target"
|
|
946
|
+
position={Position.Left}
|
|
947
|
+
id="left-target"
|
|
948
|
+
style={{
|
|
949
|
+
background: 'transparent',
|
|
950
|
+
width: '14px',
|
|
951
|
+
height: '14px',
|
|
952
|
+
border: 'none',
|
|
953
|
+
left: '-8px',
|
|
954
|
+
opacity: 0,
|
|
955
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
956
|
+
}}
|
|
957
|
+
/>
|
|
958
|
+
{/* Right - Source */}
|
|
959
|
+
<Handle
|
|
960
|
+
type="source"
|
|
961
|
+
position={Position.Right}
|
|
962
|
+
id="right-source"
|
|
963
|
+
className="connection-handle"
|
|
964
|
+
style={{
|
|
965
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
966
|
+
width: '14px',
|
|
967
|
+
height: '14px',
|
|
968
|
+
border: '3px solid #10B981',
|
|
969
|
+
right: '-8px',
|
|
970
|
+
opacity: selected ? 1 : 0,
|
|
971
|
+
transition: 'all 0.2s ease-in-out',
|
|
972
|
+
cursor: 'crosshair',
|
|
973
|
+
zIndex: 10,
|
|
974
|
+
}}
|
|
975
|
+
/>
|
|
976
|
+
{/* Right - Target (hidden but functional) */}
|
|
977
|
+
<Handle
|
|
978
|
+
type="target"
|
|
979
|
+
position={Position.Right}
|
|
980
|
+
id="right-target"
|
|
981
|
+
style={{
|
|
982
|
+
background: 'transparent',
|
|
983
|
+
width: '14px',
|
|
984
|
+
height: '14px',
|
|
985
|
+
border: 'none',
|
|
986
|
+
right: '-8px',
|
|
987
|
+
opacity: 0,
|
|
988
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
989
|
+
}}
|
|
990
|
+
/>
|
|
991
|
+
|
|
992
|
+
</Box>
|
|
993
|
+
|
|
994
|
+
{/* Node Action Buttons - Shows when selected */}
|
|
995
|
+
<NodeActionButtons
|
|
996
|
+
selected={selected}
|
|
997
|
+
onOpenAIAssistant={(buttonElement) => {
|
|
998
|
+
if (nodeId) {
|
|
999
|
+
showNodeAIAssistantPopup(nodeId, 'Sheets Node', buttonElement);
|
|
1000
|
+
}
|
|
1001
|
+
}}
|
|
1002
|
+
onDelete={() => {
|
|
1003
|
+
if (nodeId && onNodesChange) {
|
|
1004
|
+
onNodesChange([{ id: nodeId, type: 'remove' }]);
|
|
1005
|
+
}
|
|
1006
|
+
}}
|
|
1007
|
+
onDuplicate={() => {
|
|
1008
|
+
if (nodeId) {
|
|
1009
|
+
const currentNode = nodes.find(n => n.id === nodeId);
|
|
1010
|
+
if (currentNode) {
|
|
1011
|
+
const newNode = {
|
|
1012
|
+
...currentNode,
|
|
1013
|
+
id: `${currentNode.id}-copy-${Date.now()}`,
|
|
1014
|
+
position: {
|
|
1015
|
+
x: currentNode.position.x + 50,
|
|
1016
|
+
y: currentNode.position.y + 50,
|
|
1017
|
+
},
|
|
1018
|
+
selected: false,
|
|
1019
|
+
};
|
|
1020
|
+
setNodes([...nodes, newNode]);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}}
|
|
1024
|
+
/>
|
|
1025
|
+
|
|
1026
|
+
{/* AI Suggestions Button - Positioned below the node box */}
|
|
1027
|
+
{data.formData?.aiSuggestionsCount !== undefined && data.formData.aiSuggestionsCount > 0 && (
|
|
1028
|
+
<Box
|
|
1029
|
+
sx={{
|
|
1030
|
+
position: 'absolute',
|
|
1031
|
+
top: '100%',
|
|
1032
|
+
left: '50%',
|
|
1033
|
+
transform: 'translateX(-50%)',
|
|
1034
|
+
marginTop: '12px',
|
|
1035
|
+
zIndex: 10,
|
|
1036
|
+
whiteSpace: 'nowrap',
|
|
1037
|
+
}}
|
|
1038
|
+
onClick={(e) => {
|
|
1039
|
+
e.stopPropagation();
|
|
1040
|
+
// Toggle AI Suggestions panel
|
|
1041
|
+
setShowSuggestions(!showSuggestions);
|
|
1042
|
+
}}
|
|
1043
|
+
>
|
|
1044
|
+
<Button
|
|
1045
|
+
variant="contained"
|
|
1046
|
+
startIcon={<LightbulbIcon sx={{ fontSize: '12px' }} />}
|
|
1047
|
+
sx={{
|
|
1048
|
+
backgroundColor: '#2563EB',
|
|
1049
|
+
color: '#ffffff',
|
|
1050
|
+
borderRadius: '20px',
|
|
1051
|
+
textTransform: 'none',
|
|
1052
|
+
fontSize: '10px',
|
|
1053
|
+
fontWeight: 400,
|
|
1054
|
+
padding: '8px 16px',
|
|
1055
|
+
whiteSpace: 'nowrap',
|
|
1056
|
+
display: 'inline-flex',
|
|
1057
|
+
alignItems: 'center',
|
|
1058
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.3)',
|
|
1059
|
+
'&:hover': {
|
|
1060
|
+
backgroundColor: '#2563eb',
|
|
1061
|
+
},
|
|
1062
|
+
'& .MuiButton-startIcon': {
|
|
1063
|
+
marginRight: '8px',
|
|
1064
|
+
}
|
|
1065
|
+
}}
|
|
1066
|
+
>
|
|
1067
|
+
AI Suggestions
|
|
1068
|
+
<Box
|
|
1069
|
+
component="span"
|
|
1070
|
+
sx={{
|
|
1071
|
+
marginLeft: '8px',
|
|
1072
|
+
backgroundColor: '#FFFFFF26',
|
|
1073
|
+
color: '#ffffff',
|
|
1074
|
+
fontSize: '10px',
|
|
1075
|
+
fontWeight: 400,
|
|
1076
|
+
minWidth: '18px',
|
|
1077
|
+
height: '18px',
|
|
1078
|
+
borderRadius: '9px',
|
|
1079
|
+
display: 'inline-flex',
|
|
1080
|
+
alignItems: 'center',
|
|
1081
|
+
justifyContent: 'center',
|
|
1082
|
+
padding: '0 6px',
|
|
1083
|
+
border: '1px solid rgba(255, 255, 255, 0.2)',
|
|
1084
|
+
}}
|
|
1085
|
+
>
|
|
1086
|
+
{data.formData.aiSuggestionsCount}
|
|
1087
|
+
</Box>
|
|
1088
|
+
</Button>
|
|
1089
|
+
</Box>
|
|
1090
|
+
)}
|
|
1091
|
+
|
|
1092
|
+
{/* AI Suggestions Panel - Rendered on canvas below the button */}
|
|
1093
|
+
{showSuggestions && data.formData?.aiSuggestionsCount !== undefined && data.formData.aiSuggestionsCount > 0 && nodeId && (
|
|
1094
|
+
<AISuggestionsPanel
|
|
1095
|
+
suggestions={data.formData?.aiSuggestions || [
|
|
1096
|
+
{
|
|
1097
|
+
id: '1',
|
|
1098
|
+
title: 'Add Citation Extraction',
|
|
1099
|
+
description: 'Automatically extract and format citations from article content.',
|
|
1100
|
+
tags: ['classification', 'enhancement'],
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
id: '2',
|
|
1104
|
+
title: 'Generate Bullet Summary',
|
|
1105
|
+
description: 'Create a concise bullet-point summary of the article\'s main points.',
|
|
1106
|
+
tags: ['classification', 'enhancement'],
|
|
1107
|
+
},
|
|
1108
|
+
]}
|
|
1109
|
+
parentNodeId={nodeId}
|
|
1110
|
+
onSuggestionClick={(suggestion) => {
|
|
1111
|
+
console.log('Suggestion clicked:', suggestion);
|
|
1112
|
+
// Handle suggestion selection here
|
|
1113
|
+
}}
|
|
1114
|
+
onClose={() => setShowSuggestions(false)}
|
|
1115
|
+
/>
|
|
1116
|
+
)}
|
|
1117
|
+
</Box>
|
|
1118
|
+
);
|
|
1119
|
+
};
|
|
1120
|
+
|