@centreon/ui 24.4.32 → 24.4.34
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
CHANGED
|
@@ -77,9 +77,9 @@ const mountListing = (): void => {
|
|
|
77
77
|
subItems={{
|
|
78
78
|
canCheckSubItems: false,
|
|
79
79
|
enable: true,
|
|
80
|
+
getRowProperty: () => 'subItems',
|
|
80
81
|
labelCollapse: 'Collapse',
|
|
81
|
-
labelExpand: 'Expand'
|
|
82
|
-
rowProperty: 'subItems'
|
|
82
|
+
labelExpand: 'Expand'
|
|
83
83
|
}}
|
|
84
84
|
totalRows={10}
|
|
85
85
|
/>
|
|
@@ -377,9 +377,9 @@ export const ListingWithSubItems = {
|
|
|
377
377
|
subItems: {
|
|
378
378
|
canCheckSubItems: false,
|
|
379
379
|
enable: true,
|
|
380
|
+
getRowProperty: () => 'subItems',
|
|
380
381
|
labelCollapse: 'Collapse',
|
|
381
|
-
labelExpand: 'Expand'
|
|
382
|
-
rowProperty: 'subItems'
|
|
382
|
+
labelExpand: 'Expand'
|
|
383
383
|
},
|
|
384
384
|
totalRows: 10
|
|
385
385
|
}
|
package/src/Listing/index.tsx
CHANGED
|
@@ -93,9 +93,11 @@ export interface Props<TRow> {
|
|
|
93
93
|
columnConfiguration?: ColumnConfiguration;
|
|
94
94
|
columns: Array<Column>;
|
|
95
95
|
currentPage?: number;
|
|
96
|
+
customListingComponent?: JSX.Element;
|
|
96
97
|
customPaginationClassName?: string;
|
|
97
98
|
disableRowCheckCondition?: (row) => boolean;
|
|
98
99
|
disableRowCondition?: (row) => boolean;
|
|
100
|
+
displayCustomListing?: boolean;
|
|
99
101
|
getHighlightRowCondition?: (row: TRow) => boolean;
|
|
100
102
|
getId?: (row: TRow) => RowId;
|
|
101
103
|
headerMemoProps?: Array<unknown>;
|
|
@@ -121,9 +123,9 @@ export interface Props<TRow> {
|
|
|
121
123
|
subItems?: {
|
|
122
124
|
canCheckSubItems: boolean;
|
|
123
125
|
enable: boolean;
|
|
126
|
+
getRowProperty: (row?) => string;
|
|
124
127
|
labelCollapse: string;
|
|
125
128
|
labelExpand: string;
|
|
126
|
-
rowProperty: string;
|
|
127
129
|
};
|
|
128
130
|
totalRows?: number;
|
|
129
131
|
viewerModeConfiguration?: ViewerModeConfiguration;
|
|
@@ -138,6 +140,8 @@ const defaultColumnConfiguration = {
|
|
|
138
140
|
export const performanceRowsLimit = 60;
|
|
139
141
|
|
|
140
142
|
const Listing = <TRow extends { id: RowId }>({
|
|
143
|
+
customListingComponent,
|
|
144
|
+
displayCustomListing,
|
|
141
145
|
limit = 10,
|
|
142
146
|
visualizationActions,
|
|
143
147
|
columns,
|
|
@@ -176,9 +180,9 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
176
180
|
subItems = {
|
|
177
181
|
canCheckSubItems: false,
|
|
178
182
|
enable: false,
|
|
183
|
+
getRowProperty: () => '',
|
|
179
184
|
labelCollapse: 'Collapse',
|
|
180
|
-
labelExpand: 'Expand'
|
|
181
|
-
rowProperty: ''
|
|
185
|
+
labelExpand: 'Expand'
|
|
182
186
|
}
|
|
183
187
|
}: Props<TRow>): JSX.Element => {
|
|
184
188
|
const currentVisibleColumns = getVisibleColumns({
|
|
@@ -211,10 +215,10 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
211
215
|
? reduce<TRow, Array<TRow>>(
|
|
212
216
|
(acc, row): Array<TRow> => {
|
|
213
217
|
if (
|
|
214
|
-
row[subItems.
|
|
218
|
+
row[subItems.getRowProperty()] &&
|
|
215
219
|
subItemsPivots.includes(row.id)
|
|
216
220
|
) {
|
|
217
|
-
return [...acc, row, ...row[subItems.
|
|
221
|
+
return [...acc, row, ...row[subItems.getRowProperty()]];
|
|
218
222
|
}
|
|
219
223
|
|
|
220
224
|
return [...acc, row];
|
|
@@ -450,7 +454,7 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
450
454
|
reduce<TRow | number, Array<string | number>>(
|
|
451
455
|
(acc, row) => [
|
|
452
456
|
...acc,
|
|
453
|
-
...pluck('id', row[subItems?.
|
|
457
|
+
...pluck('id', row[subItems?.getRowProperty() || ''] || [])
|
|
454
458
|
],
|
|
455
459
|
[],
|
|
456
460
|
rows
|
|
@@ -495,6 +499,7 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
495
499
|
onSelectColumns={onSelectColumns}
|
|
496
500
|
/>
|
|
497
501
|
</div>
|
|
502
|
+
|
|
498
503
|
<ParentSize
|
|
499
504
|
parentSizeStyles={{
|
|
500
505
|
height: '100%',
|
|
@@ -510,132 +515,141 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
510
515
|
height: innerScrollDisabled ? '100%' : `calc(${height}px - 4px)`
|
|
511
516
|
}}
|
|
512
517
|
>
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
>
|
|
520
|
-
<ListingHeader
|
|
521
|
-
areColumnsEditable={areColumnsEditable}
|
|
522
|
-
checkable={checkable}
|
|
523
|
-
columnConfiguration={columnConfiguration}
|
|
524
|
-
columns={columns}
|
|
525
|
-
listingVariant={listingVariant}
|
|
526
|
-
memoProps={headerMemoProps}
|
|
527
|
-
predefinedRowsSelection={predefinedRowsSelection}
|
|
528
|
-
rowCount={limit - emptyRows}
|
|
529
|
-
selectedRowCount={selectedRows.length}
|
|
530
|
-
sortField={sortField}
|
|
531
|
-
sortOrder={sortOrder}
|
|
532
|
-
onSelectAllClick={selectAllRows}
|
|
533
|
-
onSelectColumns={onSelectColumns}
|
|
534
|
-
onSelectRowsWithCondition={onSelectRowsWithCondition}
|
|
535
|
-
onSort={onSort}
|
|
536
|
-
/>
|
|
537
|
-
|
|
538
|
-
<TableBody
|
|
539
|
-
className={classes.tableBody}
|
|
518
|
+
{displayCustomListing ? (
|
|
519
|
+
customListingComponent
|
|
520
|
+
) : (
|
|
521
|
+
<Table
|
|
522
|
+
stickyHeader
|
|
523
|
+
className={classes.table}
|
|
540
524
|
component="div"
|
|
541
|
-
|
|
525
|
+
role={undefined}
|
|
526
|
+
size="small"
|
|
542
527
|
>
|
|
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
|
-
row
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
528
|
+
<ListingHeader
|
|
529
|
+
areColumnsEditable={areColumnsEditable}
|
|
530
|
+
checkable={checkable}
|
|
531
|
+
columnConfiguration={columnConfiguration}
|
|
532
|
+
columns={columns}
|
|
533
|
+
listingVariant={listingVariant}
|
|
534
|
+
memoProps={headerMemoProps}
|
|
535
|
+
predefinedRowsSelection={predefinedRowsSelection}
|
|
536
|
+
rowCount={limit - emptyRows}
|
|
537
|
+
selectedRowCount={selectedRows.length}
|
|
538
|
+
sortField={sortField}
|
|
539
|
+
sortOrder={sortOrder}
|
|
540
|
+
onSelectAllClick={selectAllRows}
|
|
541
|
+
onSelectColumns={onSelectColumns}
|
|
542
|
+
onSelectRowsWithCondition={onSelectRowsWithCondition}
|
|
543
|
+
onSort={onSort}
|
|
544
|
+
/>
|
|
545
|
+
|
|
546
|
+
<TableBody
|
|
547
|
+
className={classes.tableBody}
|
|
548
|
+
component="div"
|
|
549
|
+
onMouseLeave={clearHoveredRow}
|
|
550
|
+
>
|
|
551
|
+
{rowsToDisplay.map((row, index) => {
|
|
552
|
+
const isRowSelected = isSelected(row);
|
|
553
|
+
const isRowHovered = equals(hoveredRowId, getId(row));
|
|
554
|
+
const isSubItem = allSubItemIds.includes(row.id);
|
|
555
|
+
|
|
556
|
+
return (
|
|
557
|
+
<ListingRow
|
|
558
|
+
checkable={
|
|
559
|
+
checkable &&
|
|
560
|
+
(!isSubItem || subItems.canCheckSubItems)
|
|
561
|
+
}
|
|
562
|
+
columnConfiguration={columnConfiguration}
|
|
563
|
+
columnIds={columns.map(prop('id'))}
|
|
564
|
+
disableRowCondition={disableRowCondition}
|
|
565
|
+
isHovered={isRowHovered}
|
|
566
|
+
isSelected={isRowSelected}
|
|
567
|
+
isShiftKeyDown={isShiftKeyDown}
|
|
568
|
+
key={
|
|
569
|
+
gte(limit, performanceRowsLimit)
|
|
570
|
+
? `row_${index}`
|
|
571
|
+
: getId(row)
|
|
572
|
+
}
|
|
573
|
+
lastSelectionIndex={lastSelectionIndex}
|
|
574
|
+
limit={limit}
|
|
575
|
+
listingVariant={listingVariant}
|
|
576
|
+
row={row}
|
|
577
|
+
rowColorConditions={rowColorConditions}
|
|
578
|
+
shiftKeyDownRowPivot={shiftKeyDownRowPivot}
|
|
579
|
+
subItemsPivots={subItemsPivots}
|
|
580
|
+
tabIndex={-1}
|
|
581
|
+
visibleColumns={visibleColumns}
|
|
582
|
+
onClick={(): void => {
|
|
583
|
+
onRowClick(row);
|
|
584
|
+
}}
|
|
585
|
+
onFocus={(): void => hoverRow(row)}
|
|
586
|
+
onMouseOver={(): void => hoverRow(row)}
|
|
587
|
+
>
|
|
588
|
+
{checkable &&
|
|
589
|
+
(!isSubItem || subItems.canCheckSubItems ? (
|
|
590
|
+
<Cell
|
|
591
|
+
align="left"
|
|
592
|
+
className={classes.checkbox}
|
|
593
|
+
disableRowCondition={disableRowCondition}
|
|
594
|
+
isRowHovered={isRowHovered}
|
|
595
|
+
row={row}
|
|
596
|
+
rowColorConditions={rowColorConditions}
|
|
597
|
+
onClick={(event): void => selectRow(event, row)}
|
|
598
|
+
>
|
|
599
|
+
<Checkbox
|
|
600
|
+
checked={isRowSelected}
|
|
601
|
+
disabled={
|
|
602
|
+
disableRowCheckCondition(row) ||
|
|
603
|
+
disableRowCondition(row)
|
|
604
|
+
}
|
|
605
|
+
inputProps={{
|
|
606
|
+
'aria-label': `Select row ${getId(row)}`
|
|
607
|
+
}}
|
|
608
|
+
/>
|
|
609
|
+
</Cell>
|
|
610
|
+
) : (
|
|
611
|
+
<Cell
|
|
612
|
+
align="left"
|
|
613
|
+
disableRowCondition={disableRowCondition}
|
|
614
|
+
isRowHovered={isRowHovered}
|
|
615
|
+
row={row}
|
|
616
|
+
rowColorConditions={rowColorConditions}
|
|
599
617
|
/>
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
618
|
+
))}
|
|
619
|
+
|
|
620
|
+
{visibleColumns.map((column) => (
|
|
621
|
+
<DataCell
|
|
622
|
+
column={column}
|
|
604
623
|
disableRowCondition={disableRowCondition}
|
|
624
|
+
getHighlightRowCondition={
|
|
625
|
+
getHighlightRowCondition
|
|
626
|
+
}
|
|
605
627
|
isRowHovered={isRowHovered}
|
|
628
|
+
isRowSelected={isRowSelected}
|
|
629
|
+
key={`${getId(row)}-${column.id}`}
|
|
630
|
+
labelCollapse={subItems.labelCollapse}
|
|
631
|
+
labelExpand={subItems.labelExpand}
|
|
632
|
+
listingVariant={listingVariant}
|
|
606
633
|
row={row}
|
|
607
634
|
rowColorConditions={rowColorConditions}
|
|
635
|
+
subItemsRowProperty={subItems?.getRowProperty(
|
|
636
|
+
row
|
|
637
|
+
)}
|
|
608
638
|
/>
|
|
609
639
|
))}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
rowColorConditions={rowColorConditions}
|
|
624
|
-
subItemsRowProperty={subItems?.rowProperty}
|
|
625
|
-
/>
|
|
626
|
-
))}
|
|
627
|
-
</ListingRow>
|
|
628
|
-
);
|
|
629
|
-
})}
|
|
630
|
-
|
|
631
|
-
{rows.length < 1 &&
|
|
632
|
-
(loading ? (
|
|
633
|
-
<SkeletonLoader rows={limit} />
|
|
634
|
-
) : (
|
|
635
|
-
<EmptyResult label={t(labelNoResultFound)} />
|
|
636
|
-
))}
|
|
637
|
-
</TableBody>
|
|
638
|
-
</Table>
|
|
640
|
+
</ListingRow>
|
|
641
|
+
);
|
|
642
|
+
})}
|
|
643
|
+
|
|
644
|
+
{rows.length < 1 &&
|
|
645
|
+
(loading ? (
|
|
646
|
+
<SkeletonLoader rows={limit} />
|
|
647
|
+
) : (
|
|
648
|
+
<EmptyResult label={t(labelNoResultFound)} />
|
|
649
|
+
))}
|
|
650
|
+
</TableBody>
|
|
651
|
+
</Table>
|
|
652
|
+
)}
|
|
639
653
|
</Box>
|
|
640
654
|
)}
|
|
641
655
|
</ParentSize>
|
|
@@ -49,13 +49,14 @@ const useStyles = makeStyles<{
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
modalActions: {
|
|
52
|
-
|
|
52
|
+
'&[data-fixed="true"]': {
|
|
53
|
+
position: 'fixed'
|
|
54
|
+
},
|
|
53
55
|
bottom: theme.spacing(2),
|
|
54
56
|
display: 'flex',
|
|
55
57
|
flexDirection: 'row',
|
|
56
58
|
gap: theme.spacing(2),
|
|
57
59
|
justifyContent: 'flex-end',
|
|
58
|
-
position: 'fixed',
|
|
59
60
|
right: theme.spacing(2)
|
|
60
61
|
},
|
|
61
62
|
modalBody: {
|
|
@@ -8,6 +8,7 @@ export type ModalActionsProps = {
|
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
isDanger?: boolean;
|
|
11
|
+
isFixed?: boolean;
|
|
11
12
|
labels?: ModalActionsLabels;
|
|
12
13
|
onCancel?: () => void;
|
|
13
14
|
onConfirm?: () => void;
|
|
@@ -24,12 +25,13 @@ const ModalActions = ({
|
|
|
24
25
|
onCancel,
|
|
25
26
|
onConfirm,
|
|
26
27
|
isDanger = false,
|
|
27
|
-
disabled
|
|
28
|
+
disabled,
|
|
29
|
+
isFixed
|
|
28
30
|
}: ModalActionsProps): ReactElement => {
|
|
29
31
|
const { classes } = useStyles();
|
|
30
32
|
|
|
31
33
|
return (
|
|
32
|
-
<div className={classes.modalActions}>
|
|
34
|
+
<div className={classes.modalActions} data-fixed={isFixed}>
|
|
33
35
|
{children || (
|
|
34
36
|
<>
|
|
35
37
|
<Button
|