@fluxo-dev/shell-reporting 25.3.1 → 25.3.3

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.
@@ -1,11 +1,11 @@
1
- import { c as createReactComponent, p as promiseNativeConstructor, f as fails$1, _ as _export, s as speciesConstructor$1, g as getBuiltIn$1, a as promiseResolve$1, i as isCallable$1, d as defineBuiltIn$1 } from './index.esm2.js';
1
+ import { c as createReactComponent, p as promiseNativeConstructor, f as fails$1, _ as _export, s as speciesConstructor$1, g as getBuiltIn$1, a as promiseResolve$1, i as isCallable$1, d as defineBuiltIn$1, R as ReportDesigner } from './index.esm2.js';
2
2
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
- import { ShellPage, DataCard, ConfirmModal } from '@fluxo-dev/ui-components';
4
- import { Stack, Text, TextInput, Textarea, Group, Button, Loader, Divider, Center, Modal } from '@mantine/core';
5
- import { useState, useEffect } from 'react';
3
+ import { Stack, Text, TextInput, Textarea, Group, Button, Paper, Skeleton, Center, Select, Badge, Menu, ActionIcon, Modal } from '@mantine/core';
4
+ import { useState, useEffect, useRef, useCallback } from 'react';
6
5
  import { FluxoClientSys } from '@fluxo-dev/api-client-base';
7
6
  import { useNavigate } from 'react-router-dom';
8
7
  import { showNotification } from '@mantine/notifications';
8
+ import { ShellPage, ConfirmModal } from '@fluxo-dev/ui-components';
9
9
  import '@mantine/dates';
10
10
 
11
11
  /**
@@ -13,6 +13,72 @@ import '@mantine/dates';
13
13
  */
14
14
 
15
15
 
16
+ var IconDotsVertical = createReactComponent("dots-vertical", "IconDotsVertical", [
17
+ ["path", { d: "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", key: "svg-0" }],
18
+ ["path", { d: "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", key: "svg-1" }],
19
+ ["path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", key: "svg-2" }]
20
+ ]);
21
+
22
+ /**
23
+ * @tabler/icons-react v2.47.0 - MIT
24
+ */
25
+
26
+
27
+ var IconEdit = createReactComponent("edit", "IconEdit", [
28
+ [
29
+ "path",
30
+ {
31
+ d: "M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",
32
+ key: "svg-0"
33
+ }
34
+ ],
35
+ [
36
+ "path",
37
+ {
38
+ d: "M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",
39
+ key: "svg-1"
40
+ }
41
+ ],
42
+ ["path", { d: "M16 5l3 3", key: "svg-2" }]
43
+ ]);
44
+
45
+ /**
46
+ * @tabler/icons-react v2.47.0 - MIT
47
+ */
48
+
49
+
50
+ var IconExternalLink = createReactComponent("external-link", "IconExternalLink", [
51
+ [
52
+ "path",
53
+ {
54
+ d: "M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",
55
+ key: "svg-0"
56
+ }
57
+ ],
58
+ ["path", { d: "M11 13l9 -9", key: "svg-1" }],
59
+ ["path", { d: "M15 4h5v5", key: "svg-2" }]
60
+ ]);
61
+
62
+ /**
63
+ * @tabler/icons-react v2.47.0 - MIT
64
+ */
65
+
66
+
67
+ var IconFolder = createReactComponent("folder", "IconFolder", [
68
+ [
69
+ "path",
70
+ {
71
+ d: "M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",
72
+ key: "svg-0"
73
+ }
74
+ ]
75
+ ]);
76
+
77
+ /**
78
+ * @tabler/icons-react v2.47.0 - MIT
79
+ */
80
+
81
+
16
82
  var IconPlus = createReactComponent("plus", "IconPlus", [
17
83
  ["path", { d: "M12 5l0 14", key: "svg-0" }],
18
84
  ["path", { d: "M5 12l14 0", key: "svg-1" }]
@@ -42,6 +108,22 @@ var IconReport = createReactComponent("report", "IconReport", [
42
108
  ["path", { d: "M8 15h3", key: "svg-6" }]
43
109
  ]);
44
110
 
111
+ /**
112
+ * @tabler/icons-react v2.47.0 - MIT
113
+ */
114
+
115
+
116
+ var IconTrash = createReactComponent("trash", "IconTrash", [
117
+ ["path", { d: "M4 7l16 0", key: "svg-0" }],
118
+ ["path", { d: "M10 11l0 6", key: "svg-1" }],
119
+ ["path", { d: "M14 11l0 6", key: "svg-2" }],
120
+ [
121
+ "path",
122
+ { d: "M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12", key: "svg-3" }
123
+ ],
124
+ ["path", { d: "M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3", key: "svg-4" }]
125
+ ]);
126
+
45
127
  var $ = _export;
46
128
  var NativePromiseConstructor = promiseNativeConstructor;
47
129
  var fails = fails$1;
@@ -85,9 +167,14 @@ if (isCallable(NativePromiseConstructor)) {
85
167
  }
86
168
 
87
169
  function CreateReport(props) {
88
- const [name, setName] = useState('');
89
- const [note, setNote] = useState('');
170
+ const [name, setName] = useState(props.initialName || '');
171
+ const [note, setNote] = useState(props.initialNote || '');
90
172
  const [loading, setLoading] = useState(false);
173
+ const isEditMode = props.mode === 'edit';
174
+ useEffect(() => {
175
+ if (props.initialName) setName(props.initialName);
176
+ if (props.initialNote) setNote(props.initialNote);
177
+ }, [props.initialName, props.initialNote]);
91
178
  const createReport = () => {
92
179
  if (!name) return;
93
180
  const command = {
@@ -116,22 +203,57 @@ function CreateReport(props) {
116
203
  setLoading(false);
117
204
  });
118
205
  };
206
+ const updateReport = () => {
207
+ if (!name || !props.reportId) return;
208
+ setLoading(true);
209
+ FluxoClientSys.Instance.reporting.updateReport(props.reportId, {
210
+ name: name,
211
+ annotations: note
212
+ }).then(() => {
213
+ var _a;
214
+ showNotification({
215
+ title: 'Report aggiornato',
216
+ message: 'Il report è stato aggiornato con successo',
217
+ color: 'teal'
218
+ });
219
+ (_a = props.onUpdated) === null || _a === void 0 ? void 0 : _a.call(props);
220
+ }).catch(err => {
221
+ showNotification({
222
+ title: 'Errore',
223
+ message: 'Si è verificato un errore durante l\'aggiornamento del report',
224
+ color: 'red'
225
+ });
226
+ }).finally(() => {
227
+ setLoading(false);
228
+ });
229
+ };
230
+ const handleSubmit = () => {
231
+ if (isEditMode) {
232
+ updateReport();
233
+ } else {
234
+ createReport();
235
+ }
236
+ };
119
237
  return jsxs(Stack, {
120
- children: [jsxs(Text, {
121
- children: [jsx("b", {
122
- children: "Nome:"
123
- }), " ", props.name]
124
- }), jsxs(Text, {
125
- children: [jsx("b", {
126
- children: "Categoria:"
127
- }), " ", props.scope, ".", props.packageName, ".", props.namespace, ".", props.id]
238
+ children: [!isEditMode && jsxs(Fragment, {
239
+ children: [jsxs(Text, {
240
+ children: [jsx("b", {
241
+ children: "Nome:"
242
+ }), " ", props.name]
243
+ }), jsxs(Text, {
244
+ children: [jsx("b", {
245
+ children: "Categoria:"
246
+ }), " ", props.scope, ".", props.packageName, ".", props.namespace, ".", props.id]
247
+ })]
128
248
  }), jsx(TextInput, {
129
249
  disabled: loading,
130
250
  label: 'Nome report',
251
+ value: name,
131
252
  onChange: v => setName(v.target.value)
132
253
  }), jsx(Textarea, {
133
254
  disabled: loading,
134
255
  label: 'Note',
256
+ value: note,
135
257
  onChange: v => setNote(v.target.value)
136
258
  }), jsxs(Group, {
137
259
  justify: 'right',
@@ -141,9 +263,9 @@ function CreateReport(props) {
141
263
  variant: 'subtle',
142
264
  children: "Annulla"
143
265
  }), jsx(Button, {
144
- onClick: createReport,
266
+ onClick: handleSubmit,
145
267
  disabled: !name || loading,
146
- children: "Crea"
268
+ children: isEditMode ? 'Salva' : 'Crea'
147
269
  })]
148
270
  })]
149
271
  });
@@ -152,32 +274,143 @@ function CreateReport(props) {
152
274
  function ReportsManager() {
153
275
  const [reportsList, setReportsList] = useState([]);
154
276
  const [loading, setLoading] = useState(true);
155
- const navigate = useNavigate();
156
- const [createReportModalOpened, setCreateReportModalOpened] = useState(false);
157
- const [deleteReportModalOpened, setDeleteReportModalOpened] = useState(false);
158
- const [currentId, setCurrentId] = useState();
159
- const [currentScope, setCurrentScope] = useState('');
160
- const [currentPackageName, setCurrentPackageName] = useState('');
161
- const [currentNamespace, setCurrentNamespace] = useState('');
162
- const [currentReportId, setCurrentReportId] = useState('');
163
- const [currentReportTypeName, setCurrentReportTypeName] = useState('');
164
- const [currentReportName, setCurrentReportName] = useState('');
277
+ useNavigate();
278
+ // Refactored state management
279
+ const [selectedCategory, setSelectedCategory] = useState(null);
280
+ const [selectedReport, setSelectedReport] = useState(null);
281
+ const [selectedCategoryKey, setSelectedCategoryKey] = useState(null);
282
+ const [modals, setModals] = useState({
283
+ create: false,
284
+ delete: false,
285
+ edit: false,
286
+ reportEditor: false
287
+ });
288
+ const [editingReportId, setEditingReportId] = useState(null);
289
+ const [editingReport, setEditingReport] = useState(null);
290
+ const isClosingRef = useRef(false);
165
291
  useEffect(() => {
166
292
  refresh();
167
293
  }, []);
294
+ useEffect(() => {
295
+ // Auto-select first category when data loads
296
+ if (reportsList.length > 0 && !selectedCategoryKey) {
297
+ const firstCategory = reportsList[0];
298
+ setSelectedCategoryKey(`${firstCategory.scope}-${firstCategory.reportTypeId}`);
299
+ }
300
+ }, [reportsList, selectedCategoryKey]);
301
+ // Intercetta il refresh e il cambio tab del browser
302
+ useEffect(() => {
303
+ if (!modals.reportEditor) return;
304
+ const handleBeforeUnload = e => {
305
+ e.preventDefault();
306
+ e.returnValue = 'Sei sicuro di voler uscire? Le modifiche non salvate andranno perse.';
307
+ return e.returnValue;
308
+ };
309
+ window.addEventListener('beforeunload', handleBeforeUnload);
310
+ return () => window.removeEventListener('beforeunload', handleBeforeUnload);
311
+ }, [modals.reportEditor]);
312
+ // Intercetta la navigazione nel router (back button del browser)
313
+ useEffect(() => {
314
+ if (!modals.reportEditor) return;
315
+ const handlePopState = () => {
316
+ if (!isClosingRef.current) {
317
+ const confirmExit = window.confirm('Sei sicuro di voler uscire dall\'editor? Le modifiche non salvate andranno perse.');
318
+ if (!confirmExit) {
319
+ window.history.pushState(null, '', window.location.href);
320
+ } else {
321
+ setModals(prev => Object.assign(Object.assign({}, prev), {
322
+ reportEditor: false
323
+ }));
324
+ setEditingReportId(null);
325
+ }
326
+ }
327
+ };
328
+ // Aggiungi uno stato alla history per intercettare il back button
329
+ window.history.pushState(null, '', window.location.href);
330
+ window.addEventListener('popstate', handlePopState);
331
+ return () => {
332
+ window.removeEventListener('popstate', handlePopState);
333
+ };
334
+ }, [modals.reportEditor]);
168
335
  const refresh = () => {
169
336
  FluxoClientSys.Instance.reporting.getReportsList().then(res => {
170
337
  setReportsList(res);
171
338
  setLoading(false);
172
339
  });
173
340
  };
341
+ // Helper functions for modal management
342
+ const openCreateModal = category => {
343
+ setSelectedCategory(category);
344
+ setModals(prev => Object.assign(Object.assign({}, prev), {
345
+ create: true
346
+ }));
347
+ };
348
+ const closeCreateModal = () => {
349
+ setSelectedCategory(null);
350
+ setModals(prev => Object.assign(Object.assign({}, prev), {
351
+ create: false
352
+ }));
353
+ };
354
+ const openEditModal = (report, category) => {
355
+ setEditingReport({
356
+ id: report.id,
357
+ name: report.name,
358
+ annotations: report.annotations || '',
359
+ scope: category.scope,
360
+ packageName: category.packageName,
361
+ namespace: category.namespace,
362
+ reportTypeId: category.reportTypeId,
363
+ categoryName: category.name
364
+ });
365
+ setModals(prev => Object.assign(Object.assign({}, prev), {
366
+ edit: true
367
+ }));
368
+ };
369
+ const closeEditModal = () => {
370
+ setEditingReport(null);
371
+ setModals(prev => Object.assign(Object.assign({}, prev), {
372
+ edit: false
373
+ }));
374
+ };
375
+ const openDeleteModal = report => {
376
+ setSelectedReport(report);
377
+ setModals(prev => Object.assign(Object.assign({}, prev), {
378
+ delete: true
379
+ }));
380
+ };
381
+ const closeDeleteModal = () => {
382
+ setSelectedReport(null);
383
+ setModals(prev => Object.assign(Object.assign({}, prev), {
384
+ delete: false
385
+ }));
386
+ };
387
+ const openReportEditor = reportId => {
388
+ setEditingReportId(reportId);
389
+ setModals(prev => Object.assign(Object.assign({}, prev), {
390
+ reportEditor: true
391
+ }));
392
+ };
393
+ const handleCloseReportEditor = useCallback(() => {
394
+ const confirmClose = window.confirm('Sei sicuro di voler chiudere l\'editor? Le modifiche non salvate andranno perse.');
395
+ if (confirmClose) {
396
+ isClosingRef.current = true;
397
+ setModals(prev => Object.assign(Object.assign({}, prev), {
398
+ reportEditor: false
399
+ }));
400
+ setEditingReportId(null);
401
+ // Reset del flag dopo un breve delay
402
+ setTimeout(() => {
403
+ isClosingRef.current = false;
404
+ }, 100);
405
+ }
406
+ }, []);
174
407
  const deleteReport = () => {
175
- if (!currentId) return;
176
- FluxoClientSys.Instance.reporting.deleteReport(currentId).then(() => {
408
+ if (!(selectedReport === null || selectedReport === void 0 ? void 0 : selectedReport.id)) return;
409
+ FluxoClientSys.Instance.reporting.deleteReport(selectedReport.id).then(() => {
177
410
  showNotification({
178
411
  title: 'Report eliminato',
179
412
  message: 'Il report è stato eliminato con successo',
180
- color: 'success'
413
+ color: 'green'
181
414
  });
182
415
  refresh();
183
416
  }).catch(() => {
@@ -187,105 +420,312 @@ function ReportsManager() {
187
420
  color: 'red'
188
421
  });
189
422
  }).finally(() => {
190
- setDeleteReportModalOpened(false);
191
- setCurrentId(undefined);
423
+ closeDeleteModal();
192
424
  });
193
425
  };
426
+ // Get currently selected category data
427
+ const getCurrentCategory = () => {
428
+ if (!selectedCategoryKey) return null;
429
+ return reportsList.find(cat => `${cat.scope}-${cat.reportTypeId}` === selectedCategoryKey);
430
+ };
431
+ const currentCategory = getCurrentCategory();
194
432
  return jsxs(ShellPage, {
195
433
  headerProps: {
196
434
  title: 'Reports'
197
435
  },
198
- children: [loading ? jsx(Loader, {
199
- size: 48,
200
- style: {
201
- margin: 'auto'
202
- }
203
- }) : jsx(Stack, {
204
- children: reportsList.map(report => {
205
- return jsx(DataCard, {
206
- title: report.name,
207
- actions: [{
208
- label: 'Nuovo report',
209
- icon: jsx(IconPlus, {
210
- size: 18
436
+ children: [loading ? jsx(Stack, {
437
+ gap: "sm",
438
+ maw: 1280,
439
+ m: '0 auto',
440
+ children: [1, 2, 3].map(i => jsxs(Paper, {
441
+ p: "sm",
442
+ withBorder: true,
443
+ children: [jsxs(Group, {
444
+ justify: "space-between",
445
+ mb: "xs",
446
+ children: [jsx(Skeleton, {
447
+ height: 20,
448
+ width: 200
449
+ }), jsx(Skeleton, {
450
+ height: 16,
451
+ circle: true
452
+ })]
453
+ }), jsx(Skeleton, {
454
+ height: 32,
455
+ mt: "sm"
456
+ })]
457
+ }, i))
458
+ }) : reportsList.length === 0 ? jsx(Center, {
459
+ py: 60,
460
+ maw: 1280,
461
+ m: '0 auto',
462
+ children: jsxs(Stack, {
463
+ align: "center",
464
+ gap: "sm",
465
+ children: [jsx(IconFolder, {
466
+ size: 48,
467
+ stroke: 1.2,
468
+ style: {
469
+ opacity: 0.4
470
+ }
471
+ }), jsx(Text, {
472
+ size: "sm",
473
+ c: "dimmed",
474
+ children: "Nessuna categoria di report disponibile"
475
+ })]
476
+ })
477
+ }) : jsxs(Stack, {
478
+ gap: "sm",
479
+ maw: 1280,
480
+ m: '0 auto',
481
+ children: [jsx(Paper, {
482
+ p: "sm",
483
+ withBorder: true,
484
+ children: jsxs(Group, {
485
+ justify: "space-between",
486
+ align: "flex-end",
487
+ children: [jsx(Select, {
488
+ label: "Categoria",
489
+ placeholder: "Seleziona categoria",
490
+ value: selectedCategoryKey,
491
+ onChange: value => setSelectedCategoryKey(value),
492
+ data: reportsList.map(category => ({
493
+ value: `${category.scope}-${category.reportTypeId}`,
494
+ label: `${category.name} (${category.reports.length})`
495
+ })),
496
+ searchable: true,
497
+ clearable: true,
498
+ leftSection: jsx(IconFolder, {
499
+ size: 16
500
+ }),
501
+ style: {
502
+ flex: 1,
503
+ maxWidth: 400
504
+ },
505
+ size: "sm"
506
+ }), currentCategory && jsx(Button, {
507
+ size: "sm",
508
+ variant: "light",
509
+ leftSection: jsx(IconPlus, {
510
+ size: 16
511
+ }),
512
+ onClick: () => openCreateModal({
513
+ scope: currentCategory.scope,
514
+ packageName: currentCategory.packageName,
515
+ namespace: currentCategory.namespace,
516
+ reportTypeId: currentCategory.reportTypeId,
517
+ name: currentCategory.name
211
518
  }),
212
- onClick: () => {
213
- setCurrentScope(report.scope);
214
- setCurrentPackageName(report.packageName);
215
- setCurrentNamespace(report.namespace);
216
- setCurrentReportId(report.reportTypeId);
217
- setCurrentReportTypeName(report.name);
218
- setCreateReportModalOpened(true);
219
- }
220
- }],
221
- children: jsxs(Stack, {
222
- children: [report.reports.map((r, index) => {
223
- return jsxs(Fragment, {
519
+ children: "Nuovo report"
520
+ })]
521
+ })
522
+ }), currentCategory ? jsx(Paper, {
523
+ p: "sm",
524
+ withBorder: true,
525
+ children: jsxs(Stack, {
526
+ gap: "sm",
527
+ children: [jsx(Group, {
528
+ justify: "space-between",
529
+ mb: "xs",
530
+ children: jsxs(Group, {
531
+ gap: "xs",
532
+ children: [jsx(Text, {
533
+ size: "sm",
534
+ children: currentCategory.name
535
+ }), jsx(Badge, {
536
+ size: "sm",
537
+ variant: "dot",
538
+ color: currentCategory.reports.length > 0 ? 'blue' : 'gray',
539
+ children: currentCategory.reports.length
540
+ })]
541
+ })
542
+ }), currentCategory.reports.length === 0 ? jsx(Center, {
543
+ py: 40,
544
+ children: jsxs(Stack, {
545
+ align: "center",
546
+ gap: "sm",
547
+ children: [jsx(IconReport, {
548
+ size: 40,
549
+ stroke: 1.2,
550
+ style: {
551
+ opacity: 0.4
552
+ }
553
+ }), jsx(Text, {
554
+ size: "sm",
555
+ c: "dimmed",
556
+ children: "Nessun report"
557
+ }), jsx(Button, {
558
+ size: "xs",
559
+ variant: "light",
560
+ leftSection: jsx(IconPlus, {
561
+ size: 14
562
+ }),
563
+ onClick: () => openCreateModal({
564
+ scope: currentCategory.scope,
565
+ packageName: currentCategory.packageName,
566
+ namespace: currentCategory.namespace,
567
+ reportTypeId: currentCategory.reportTypeId,
568
+ name: currentCategory.name
569
+ }),
570
+ children: "Crea report"
571
+ })]
572
+ })
573
+ }) : jsx(Stack, {
574
+ gap: 8,
575
+ children: currentCategory.reports.map(report => jsx(Paper, {
576
+ p: "xs",
577
+ withBorder: true,
578
+ style: {
579
+ cursor: 'pointer'
580
+ },
581
+ onClick: () => openReportEditor(report.id),
582
+ children: jsxs(Group, {
583
+ justify: "space-between",
224
584
  children: [jsxs(Group, {
225
- justify: 'space-between',
226
- children: [jsxs(Group, {
227
- children: [jsx(IconReport, {
228
- color: 'gray',
229
- size: 18
230
- }), jsx(Text, {
231
- fw: 600,
232
- size: 'md',
233
- children: r.name
234
- })]
235
- }), jsxs(Group, {
236
- children: [jsx(Button, {
237
- onClick: () => navigate(r.id.toString(), {
238
- state: {
239
- title: `Report/${r.name}`
240
- }
585
+ gap: "sm",
586
+ children: [jsx(IconReport, {
587
+ size: 16,
588
+ style: {
589
+ opacity: 0.6
590
+ }
591
+ }), jsx(Text, {
592
+ size: "sm",
593
+ children: report.name
594
+ })]
595
+ }), jsxs(Menu, {
596
+ shadow: "sm",
597
+ width: 160,
598
+ position: "bottom-end",
599
+ children: [jsx(Menu.Target, {
600
+ children: jsx(ActionIcon, {
601
+ variant: "subtle",
602
+ color: "gray",
603
+ size: "sm",
604
+ onClick: e => e.stopPropagation(),
605
+ children: jsx(IconDotsVertical, {
606
+ size: 16
607
+ })
608
+ })
609
+ }), jsxs(Menu.Dropdown, {
610
+ children: [jsx(Menu.Item, {
611
+ leftSection: jsx(IconEdit, {
612
+ size: 14
241
613
  }),
242
- size: 'xs',
614
+ onClick: e => {
615
+ e.stopPropagation();
616
+ openEditModal(report, currentCategory);
617
+ },
243
618
  children: "Modifica"
244
- }), jsx(Button, {
245
- onClick: () => {
246
- setCurrentId(r.id);
247
- setCurrentReportName(r.name);
248
- setDeleteReportModalOpened(true);
619
+ }), jsx(Menu.Item, {
620
+ leftSection: jsx(IconExternalLink, {
621
+ size: 14
622
+ }),
623
+ onClick: e => {
624
+ e.stopPropagation();
625
+ openReportEditor(report.id);
626
+ },
627
+ children: "Apri designer"
628
+ }), jsx(Menu.Item, {
629
+ leftSection: jsx(IconTrash, {
630
+ size: 14
631
+ }),
632
+ color: "red",
633
+ onClick: e => {
634
+ e.stopPropagation();
635
+ openDeleteModal({
636
+ id: report.id,
637
+ name: report.name
638
+ });
249
639
  },
250
- size: 'xs',
251
- color: 'red',
252
640
  children: "Elimina"
253
641
  })]
254
642
  })]
255
- }), index !== report.reports.length - 1 && jsx(Divider, {})]
256
- });
257
- }), report.reports.length === 0 && jsx(Center, {
258
- children: jsx(Text, {
259
- size: 'md',
260
- children: "Nessun report per la categoria"
643
+ })]
261
644
  })
262
- })]
645
+ }, report.id))
646
+ })]
647
+ })
648
+ }) : jsx(Paper, {
649
+ p: "sm",
650
+ withBorder: true,
651
+ children: jsx(Center, {
652
+ py: 30,
653
+ children: jsx(Text, {
654
+ size: "sm",
655
+ c: "dimmed",
656
+ children: "Seleziona una categoria"
263
657
  })
264
- });
265
- })
658
+ })
659
+ })]
266
660
  }), jsx(Modal, {
267
- title: 'Nuovo report',
661
+ title: "Nuovo report",
268
662
  centered: true,
269
- opened: createReportModalOpened,
270
- onClose: () => setCreateReportModalOpened(false),
271
- children: jsx(CreateReport, {
272
- name: currentReportTypeName,
273
- scope: currentScope,
274
- packageName: currentPackageName,
275
- namespace: currentNamespace,
276
- id: currentReportId,
663
+ opened: modals.create,
664
+ onClose: closeCreateModal,
665
+ size: "sm",
666
+ children: selectedCategory && jsx(CreateReport, {
667
+ name: selectedCategory.name,
668
+ scope: selectedCategory.scope,
669
+ packageName: selectedCategory.packageName,
670
+ namespace: selectedCategory.namespace,
671
+ id: selectedCategory.reportTypeId,
277
672
  onCreated: newReportId => {
278
- setCreateReportModalOpened(false);
279
- navigate(newReportId.toString());
673
+ closeCreateModal();
674
+ refresh();
675
+ openReportEditor(newReportId);
280
676
  },
281
- onCancel: () => setCreateReportModalOpened(false)
677
+ onCancel: closeCreateModal
678
+ })
679
+ }), jsx(Modal, {
680
+ title: "Modifica report",
681
+ centered: true,
682
+ opened: modals.edit,
683
+ onClose: closeEditModal,
684
+ size: "sm",
685
+ children: editingReport && jsx(CreateReport, {
686
+ mode: "edit",
687
+ reportId: editingReport.id,
688
+ initialName: editingReport.name,
689
+ initialNote: editingReport.annotations,
690
+ name: editingReport.categoryName,
691
+ scope: editingReport.scope,
692
+ packageName: editingReport.packageName,
693
+ namespace: editingReport.namespace,
694
+ id: editingReport.reportTypeId,
695
+ onCreated: () => {},
696
+ onUpdated: () => {
697
+ closeEditModal();
698
+ refresh();
699
+ },
700
+ onCancel: closeEditModal
282
701
  })
283
702
  }), jsx(ConfirmModal, {
284
- open: deleteReportModalOpened,
285
- onButtonConfirmClick: () => deleteReport(),
286
- onButtonCancelClick: () => setDeleteReportModalOpened(true),
287
- title: 'Elimina report',
288
- messageText: `Sei sicuro di voler eliminare il report ${currentReportName}?`
703
+ open: modals.delete,
704
+ onButtonConfirmClick: deleteReport,
705
+ onButtonCancelClick: closeDeleteModal,
706
+ title: "Elimina report",
707
+ messageText: `Sei sicuro di voler eliminare il report "${selectedReport === null || selectedReport === void 0 ? void 0 : selectedReport.name}"?`
708
+ }), jsx(Modal, {
709
+ title: "Editor Report",
710
+ styles: {
711
+ header: {
712
+ marginBottom: 0,
713
+ boxShadow: 'rgba(33, 33, 33, 0.1) 2px 1px 1px',
714
+ minHeight: 48,
715
+ padding: 8
716
+ }
717
+ },
718
+ padding: 0,
719
+ closeOnEscape: false,
720
+ closeOnClickOutside: false,
721
+ withCloseButton: true,
722
+ opened: modals.reportEditor,
723
+ fullScreen: true,
724
+ onClose: handleCloseReportEditor,
725
+ children: editingReportId && jsx(ReportDesigner, {
726
+ mode: "designer",
727
+ reportId: editingReportId
728
+ })
289
729
  })]
290
730
  });
291
731
  }