@centreon/ui 24.4.32 → 24.4.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Listing/index.tsx +129 -117
package/package.json
CHANGED
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>;
|
|
@@ -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,
|
|
@@ -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,139 @@ 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?.rowProperty}
|
|
608
636
|
/>
|
|
609
637
|
))}
|
|
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>
|
|
638
|
+
</ListingRow>
|
|
639
|
+
);
|
|
640
|
+
})}
|
|
641
|
+
|
|
642
|
+
{rows.length < 1 &&
|
|
643
|
+
(loading ? (
|
|
644
|
+
<SkeletonLoader rows={limit} />
|
|
645
|
+
) : (
|
|
646
|
+
<EmptyResult label={t(labelNoResultFound)} />
|
|
647
|
+
))}
|
|
648
|
+
</TableBody>
|
|
649
|
+
</Table>
|
|
650
|
+
)}
|
|
639
651
|
</Box>
|
|
640
652
|
)}
|
|
641
653
|
</ParentSize>
|