@centreon/ui 24.4.31 → 24.4.32
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 +14 -19
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +5 -9
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/Dialog/index.tsx +1 -1
- package/src/FallbackPage/FallbackPage.tsx +3 -3
- package/src/FileDropZone/index.tsx +1 -3
- package/src/Form/Inputs/CheckboxGroup.tsx +4 -1
- package/src/Form/Inputs/index.tsx +1 -3
- package/src/Form/Inputs/models.ts +1 -9
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +4 -5
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +3 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
- package/src/Graph/LineChart/helpers/doc.ts +13 -16
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +2 -4
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.stories.tsx +4 -60
- package/src/Graph/common/timeSeries/index.ts +3 -3
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -10
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/index.tsx +115 -121
- package/src/InputField/Select/IconPopover/index.tsx +2 -2
- package/src/InputField/Select/index.tsx +1 -1
- package/src/InputField/Text/index.tsx +2 -2
- package/src/Listing/Cell/DataCell.tsx +1 -15
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.cypress.spec.tsx +2 -2
- package/src/Listing/Listing.styles.ts +3 -2
- package/src/Listing/index.stories.tsx +3 -14
- package/src/Listing/index.tsx +125 -138
- package/src/Module/index.tsx +4 -2
- package/src/RichTextEditor/RichTextEditor.tsx +1 -12
- package/src/SortableItems/index.tsx +7 -2
- package/src/ThemeProvider/index.tsx +0 -24
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -8
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +2 -0
- package/src/TimePeriods/DateTimePickerInput.tsx +19 -56
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +33 -9
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +4 -12
- package/src/TimePeriods/index.tsx +2 -2
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.ts +23 -27
- package/src/api/useMutationQuery/index.ts +21 -45
- package/src/components/Button/Icon/IconButton.tsx +2 -6
- package/src/components/DataTable/DataTable.stories.tsx +0 -40
- package/src/components/DataTable/DataTable.styles.ts +0 -3
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +2 -7
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -4
- package/src/components/DataTable/index.ts +1 -3
- package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +0 -2
- package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +1 -1
- package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +1 -5
- package/src/components/Layout/PageLayout/index.ts +1 -3
- package/src/components/Modal/Modal.styles.ts +3 -4
- package/src/components/Modal/ModalActions.tsx +2 -4
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
- package/src/index.ts +2 -2
- package/src/queryParameters/url/index.ts +1 -5
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/useDateTimePickerAdapter.ts +309 -0
- package/src/utils/{useLicenseExpirationWarning.test.tsx → useLicenseExpirationWarning.cypress.spec.tsx} +37 -48
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/Form/Form.cypress.spec.tsx +0 -133
- package/src/Form/Inputs/List/Content.tsx +0 -62
- package/src/Form/Inputs/List/List.styles.ts +0 -29
- package/src/Form/Inputs/List/List.tsx +0 -58
- package/src/Form/Inputs/List/useList.ts +0 -81
- package/src/Module/Module.cypress.spec.tsx +0 -129
- package/src/components/DataTable/DataListing.tsx +0 -6
- package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -193
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +0 -76
- package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -66
- package/src/utils/usePluralizedTranslation.ts +0 -21
package/src/Listing/index.tsx
CHANGED
|
@@ -69,7 +69,7 @@ const getVisibleColumns = ({
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return selectedColumnIds.map((id) =>
|
|
72
|
-
columns.find(propEq(id,
|
|
72
|
+
columns.find(propEq('id', id))
|
|
73
73
|
) as Array<Column>;
|
|
74
74
|
};
|
|
75
75
|
|
|
@@ -93,11 +93,9 @@ export interface Props<TRow> {
|
|
|
93
93
|
columnConfiguration?: ColumnConfiguration;
|
|
94
94
|
columns: Array<Column>;
|
|
95
95
|
currentPage?: number;
|
|
96
|
-
customListingComponent?: JSX.Element;
|
|
97
96
|
customPaginationClassName?: string;
|
|
98
97
|
disableRowCheckCondition?: (row) => boolean;
|
|
99
98
|
disableRowCondition?: (row) => boolean;
|
|
100
|
-
displayCustomListing?: boolean;
|
|
101
99
|
getHighlightRowCondition?: (row: TRow) => boolean;
|
|
102
100
|
getId?: (row: TRow) => RowId;
|
|
103
101
|
headerMemoProps?: Array<unknown>;
|
|
@@ -123,9 +121,9 @@ export interface Props<TRow> {
|
|
|
123
121
|
subItems?: {
|
|
124
122
|
canCheckSubItems: boolean;
|
|
125
123
|
enable: boolean;
|
|
126
|
-
getRowProperty: (row?) => string;
|
|
127
124
|
labelCollapse: string;
|
|
128
125
|
labelExpand: string;
|
|
126
|
+
rowProperty: string;
|
|
129
127
|
};
|
|
130
128
|
totalRows?: number;
|
|
131
129
|
viewerModeConfiguration?: ViewerModeConfiguration;
|
|
@@ -140,8 +138,6 @@ const defaultColumnConfiguration = {
|
|
|
140
138
|
export const performanceRowsLimit = 60;
|
|
141
139
|
|
|
142
140
|
const Listing = <TRow extends { id: RowId }>({
|
|
143
|
-
customListingComponent,
|
|
144
|
-
displayCustomListing,
|
|
145
141
|
limit = 10,
|
|
146
142
|
visualizationActions,
|
|
147
143
|
columns,
|
|
@@ -180,9 +176,9 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
180
176
|
subItems = {
|
|
181
177
|
canCheckSubItems: false,
|
|
182
178
|
enable: false,
|
|
183
|
-
getRowProperty: () => '',
|
|
184
179
|
labelCollapse: 'Collapse',
|
|
185
|
-
labelExpand: 'Expand'
|
|
180
|
+
labelExpand: 'Expand',
|
|
181
|
+
rowProperty: ''
|
|
186
182
|
}
|
|
187
183
|
}: Props<TRow>): JSX.Element => {
|
|
188
184
|
const currentVisibleColumns = getVisibleColumns({
|
|
@@ -215,10 +211,10 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
215
211
|
? reduce<TRow, Array<TRow>>(
|
|
216
212
|
(acc, row): Array<TRow> => {
|
|
217
213
|
if (
|
|
218
|
-
row[subItems.
|
|
214
|
+
row[subItems.rowProperty] &&
|
|
219
215
|
subItemsPivots.includes(row.id)
|
|
220
216
|
) {
|
|
221
|
-
return [...acc, row, ...row[subItems.
|
|
217
|
+
return [...acc, row, ...row[subItems.rowProperty]];
|
|
222
218
|
}
|
|
223
219
|
|
|
224
220
|
return [...acc, row];
|
|
@@ -233,6 +229,7 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
233
229
|
const { classes } = useListingStyles({
|
|
234
230
|
dataStyle,
|
|
235
231
|
getGridTemplateColumn,
|
|
232
|
+
limit,
|
|
236
233
|
listingVariant,
|
|
237
234
|
rows: rowsToDisplay
|
|
238
235
|
});
|
|
@@ -453,7 +450,7 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
453
450
|
reduce<TRow | number, Array<string | number>>(
|
|
454
451
|
(acc, row) => [
|
|
455
452
|
...acc,
|
|
456
|
-
...pluck('id', row[subItems?.
|
|
453
|
+
...pluck('id', row[subItems?.rowProperty || ''] || [])
|
|
457
454
|
],
|
|
458
455
|
[],
|
|
459
456
|
rows
|
|
@@ -498,7 +495,6 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
498
495
|
onSelectColumns={onSelectColumns}
|
|
499
496
|
/>
|
|
500
497
|
</div>
|
|
501
|
-
|
|
502
498
|
<ParentSize
|
|
503
499
|
parentSizeStyles={{
|
|
504
500
|
height: '100%',
|
|
@@ -514,141 +510,132 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
514
510
|
height: innerScrollDisabled ? '100%' : `calc(${height}px - 4px)`
|
|
515
511
|
}}
|
|
516
512
|
>
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
513
|
+
<Table
|
|
514
|
+
stickyHeader
|
|
515
|
+
className={classes.table}
|
|
516
|
+
component="div"
|
|
517
|
+
role={undefined}
|
|
518
|
+
size="small"
|
|
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}
|
|
523
540
|
component="div"
|
|
524
|
-
|
|
525
|
-
size="small"
|
|
541
|
+
onMouseLeave={clearHoveredRow}
|
|
526
542
|
>
|
|
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
|
-
onFocus={(): void => hoverRow(row)}
|
|
585
|
-
onMouseOver={(): void => hoverRow(row)}
|
|
586
|
-
>
|
|
587
|
-
{checkable &&
|
|
588
|
-
(!isSubItem || subItems.canCheckSubItems ? (
|
|
589
|
-
<Cell
|
|
590
|
-
align="left"
|
|
591
|
-
className={classes.checkbox}
|
|
592
|
-
disableRowCondition={disableRowCondition}
|
|
593
|
-
isRowHovered={isRowHovered}
|
|
594
|
-
row={row}
|
|
595
|
-
rowColorConditions={rowColorConditions}
|
|
596
|
-
onClick={(event): void => selectRow(event, row)}
|
|
597
|
-
>
|
|
598
|
-
<Checkbox
|
|
599
|
-
checked={isRowSelected}
|
|
600
|
-
disabled={
|
|
601
|
-
disableRowCheckCondition(row) ||
|
|
602
|
-
disableRowCondition(row)
|
|
603
|
-
}
|
|
604
|
-
inputProps={{
|
|
605
|
-
'aria-label': `Select row ${getId(row)}`
|
|
606
|
-
}}
|
|
607
|
-
/>
|
|
608
|
-
</Cell>
|
|
609
|
-
) : (
|
|
610
|
-
<Cell
|
|
611
|
-
align="left"
|
|
612
|
-
disableRowCondition={disableRowCondition}
|
|
613
|
-
isRowHovered={isRowHovered}
|
|
614
|
-
row={row}
|
|
615
|
-
rowColorConditions={rowColorConditions}
|
|
543
|
+
{rowsToDisplay.map((row, index) => {
|
|
544
|
+
const isRowSelected = isSelected(row);
|
|
545
|
+
const isRowHovered = equals(hoveredRowId, getId(row));
|
|
546
|
+
const isSubItem = allSubItemIds.includes(row.id);
|
|
547
|
+
|
|
548
|
+
return (
|
|
549
|
+
<ListingRow
|
|
550
|
+
checkable={
|
|
551
|
+
checkable && (!isSubItem || subItems.canCheckSubItems)
|
|
552
|
+
}
|
|
553
|
+
columnConfiguration={columnConfiguration}
|
|
554
|
+
columnIds={columns.map(prop('id'))}
|
|
555
|
+
disableRowCondition={disableRowCondition}
|
|
556
|
+
isHovered={isRowHovered}
|
|
557
|
+
isSelected={isRowSelected}
|
|
558
|
+
isShiftKeyDown={isShiftKeyDown}
|
|
559
|
+
key={
|
|
560
|
+
gte(limit, performanceRowsLimit)
|
|
561
|
+
? `row_${index}`
|
|
562
|
+
: getId(row)
|
|
563
|
+
}
|
|
564
|
+
lastSelectionIndex={lastSelectionIndex}
|
|
565
|
+
limit={limit}
|
|
566
|
+
listingVariant={listingVariant}
|
|
567
|
+
row={row}
|
|
568
|
+
rowColorConditions={rowColorConditions}
|
|
569
|
+
shiftKeyDownRowPivot={shiftKeyDownRowPivot}
|
|
570
|
+
subItemsPivots={subItemsPivots}
|
|
571
|
+
tabIndex={-1}
|
|
572
|
+
visibleColumns={visibleColumns}
|
|
573
|
+
onClick={(): void => {
|
|
574
|
+
onRowClick(row);
|
|
575
|
+
}}
|
|
576
|
+
onFocus={(): void => hoverRow(row)}
|
|
577
|
+
onMouseOver={(): void => hoverRow(row)}
|
|
578
|
+
>
|
|
579
|
+
{checkable &&
|
|
580
|
+
(!isSubItem || subItems.canCheckSubItems ? (
|
|
581
|
+
<Cell
|
|
582
|
+
align="left"
|
|
583
|
+
className={classes.checkbox}
|
|
584
|
+
disableRowCondition={disableRowCondition}
|
|
585
|
+
isRowHovered={isRowHovered}
|
|
586
|
+
row={row}
|
|
587
|
+
rowColorConditions={rowColorConditions}
|
|
588
|
+
onClick={(event): void => selectRow(event, row)}
|
|
589
|
+
>
|
|
590
|
+
<Checkbox
|
|
591
|
+
checked={isRowSelected}
|
|
592
|
+
disabled={
|
|
593
|
+
disableRowCheckCondition(row) ||
|
|
594
|
+
disableRowCondition(row)
|
|
595
|
+
}
|
|
596
|
+
inputProps={{
|
|
597
|
+
'aria-label': `Select row ${getId(row)}`
|
|
598
|
+
}}
|
|
616
599
|
/>
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
column={column}
|
|
600
|
+
</Cell>
|
|
601
|
+
) : (
|
|
602
|
+
<Cell
|
|
603
|
+
align="left"
|
|
622
604
|
disableRowCondition={disableRowCondition}
|
|
623
|
-
getHighlightRowCondition={
|
|
624
|
-
getHighlightRowCondition
|
|
625
|
-
}
|
|
626
605
|
isRowHovered={isRowHovered}
|
|
627
|
-
isRowSelected={isRowSelected}
|
|
628
|
-
key={`${getId(row)}-${column.id}`}
|
|
629
|
-
labelCollapse={subItems.labelCollapse}
|
|
630
|
-
labelExpand={subItems.labelExpand}
|
|
631
|
-
listingVariant={listingVariant}
|
|
632
606
|
row={row}
|
|
633
607
|
rowColorConditions={rowColorConditions}
|
|
634
|
-
subItemsRowProperty={subItems?.getRowProperty(
|
|
635
|
-
row
|
|
636
|
-
)}
|
|
637
608
|
/>
|
|
638
609
|
))}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
610
|
+
|
|
611
|
+
{visibleColumns.map((column) => (
|
|
612
|
+
<DataCell
|
|
613
|
+
column={column}
|
|
614
|
+
disableRowCondition={disableRowCondition}
|
|
615
|
+
getHighlightRowCondition={getHighlightRowCondition}
|
|
616
|
+
isRowHovered={isRowHovered}
|
|
617
|
+
isRowSelected={isRowSelected}
|
|
618
|
+
key={`${getId(row)}-${column.id}`}
|
|
619
|
+
labelCollapse={subItems.labelCollapse}
|
|
620
|
+
labelExpand={subItems.labelExpand}
|
|
621
|
+
listingVariant={listingVariant}
|
|
622
|
+
row={row}
|
|
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>
|
|
652
639
|
</Box>
|
|
653
640
|
)}
|
|
654
641
|
</ParentSize>
|
package/src/Module/index.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
1
3
|
import { Provider as JotaiProvider, createStore } from 'jotai';
|
|
2
4
|
|
|
3
5
|
import { createGenerateClassName, StylesProvider } from '@mui/styles';
|
|
@@ -7,7 +9,7 @@ import SnackbarProvider from '../Snackbar/SnackbarProvider';
|
|
|
7
9
|
|
|
8
10
|
export interface ModuleProps {
|
|
9
11
|
children: React.ReactElement;
|
|
10
|
-
maxSnackbars
|
|
12
|
+
maxSnackbars: number;
|
|
11
13
|
seedName: string;
|
|
12
14
|
store: ReturnType<typeof createStore>;
|
|
13
15
|
}
|
|
@@ -15,7 +17,7 @@ export interface ModuleProps {
|
|
|
15
17
|
const Module = ({
|
|
16
18
|
children,
|
|
17
19
|
seedName,
|
|
18
|
-
maxSnackbars
|
|
20
|
+
maxSnackbars,
|
|
19
21
|
store
|
|
20
22
|
}: ModuleProps): JSX.Element => {
|
|
21
23
|
const generateClassName = createGenerateClassName({
|
|
@@ -12,7 +12,6 @@ import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
|
12
12
|
import { equals } from 'ramda';
|
|
13
13
|
import { ListPlugin } from '@lexical/react/LexicalListPlugin';
|
|
14
14
|
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
15
|
-
import { $generateHtmlFromNodes } from '@lexical/html';
|
|
16
15
|
|
|
17
16
|
import { Typography } from '@mui/material';
|
|
18
17
|
|
|
@@ -39,7 +38,6 @@ export interface RichTextEditorProps {
|
|
|
39
38
|
openLinkInNewTab?: boolean;
|
|
40
39
|
placeholder?: string;
|
|
41
40
|
resetEditorToInitialStateCondition?: () => boolean;
|
|
42
|
-
setHtmlString?: (htmlString: string) => void;
|
|
43
41
|
toolbarClassName?: string;
|
|
44
42
|
toolbarPositions?: 'start' | 'end';
|
|
45
43
|
}
|
|
@@ -145,7 +143,6 @@ const RichTextEditor = ({
|
|
|
145
143
|
openLinkInNewTab = true,
|
|
146
144
|
initialize,
|
|
147
145
|
displayBlockButtons = true,
|
|
148
|
-
setHtmlString,
|
|
149
146
|
toolbarClassName
|
|
150
147
|
}: RichTextEditorProps): JSX.Element => {
|
|
151
148
|
const { classes } = useStyles({ toolbarPositions });
|
|
@@ -181,13 +178,6 @@ const RichTextEditor = ({
|
|
|
181
178
|
}
|
|
182
179
|
};
|
|
183
180
|
|
|
184
|
-
const change = (state: EditorState, editor: LexicalEditor): void => {
|
|
185
|
-
editor.update(() => {
|
|
186
|
-
setHtmlString?.($generateHtmlFromNodes(editor, null));
|
|
187
|
-
});
|
|
188
|
-
getEditorState?.(state, editor);
|
|
189
|
-
};
|
|
190
|
-
|
|
191
181
|
return (
|
|
192
182
|
<LexicalComposer initialConfig={initialConfig}>
|
|
193
183
|
<div className={classes.container}>
|
|
@@ -220,7 +210,6 @@ const RichTextEditor = ({
|
|
|
220
210
|
resetEditorToInitialStateCondition={
|
|
221
211
|
resetEditorToInitialStateCondition
|
|
222
212
|
}
|
|
223
|
-
setHtmlString={setHtmlString}
|
|
224
213
|
onBlur={onBlur}
|
|
225
214
|
/>
|
|
226
215
|
}
|
|
@@ -229,7 +218,7 @@ const RichTextEditor = ({
|
|
|
229
218
|
<HistoryPlugin />
|
|
230
219
|
<LinkPlugin />
|
|
231
220
|
<ListPlugin />
|
|
232
|
-
<OnChangePlugin onChange={
|
|
221
|
+
<OnChangePlugin onChange={getEditorState} />
|
|
233
222
|
<AutoCompleteLinkPlugin openLinkInNewTab={openLinkInNewTab} />
|
|
234
223
|
<FloatingLinkEditorPlugin
|
|
235
224
|
editable={editable}
|
|
@@ -15,7 +15,11 @@ import {
|
|
|
15
15
|
DragEndEvent,
|
|
16
16
|
Over
|
|
17
17
|
} from '@dnd-kit/core';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
SortableContext,
|
|
20
|
+
sortableKeyboardCoordinates,
|
|
21
|
+
SortingStrategy
|
|
22
|
+
} from '@dnd-kit/sortable';
|
|
19
23
|
import {
|
|
20
24
|
equals,
|
|
21
25
|
find,
|
|
@@ -113,6 +117,7 @@ const SortableItems = <T extends { [propertyToFilterItemsOn]: string }>({
|
|
|
113
117
|
useSensor(MouseSensor),
|
|
114
118
|
useSensor(PointerSensor),
|
|
115
119
|
useSensor(KeyboardSensor, {
|
|
120
|
+
coordinateGetter: sortableKeyboardCoordinates,
|
|
116
121
|
keyboardCodes: {
|
|
117
122
|
cancel: ['Escape'],
|
|
118
123
|
end: ['Space', 'Enter'],
|
|
@@ -164,7 +169,7 @@ const SortableItems = <T extends { [propertyToFilterItemsOn]: string }>({
|
|
|
164
169
|
};
|
|
165
170
|
|
|
166
171
|
const getItemById = (id): T | undefined =>
|
|
167
|
-
find(propEq(
|
|
172
|
+
find(propEq(propertyToFilterItemsOn, id), items);
|
|
168
173
|
|
|
169
174
|
const activeItem = getItemById(activeId) as Record<string, unknown>;
|
|
170
175
|
|
|
@@ -147,30 +147,6 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
|
|
|
147
147
|
},
|
|
148
148
|
MuiCssBaseline: {
|
|
149
149
|
styleOverrides: (theme) => `
|
|
150
|
-
::-webkit-scrollbar {
|
|
151
|
-
height: ${theme.spacing(1)};
|
|
152
|
-
width: ${theme.spacing(1)};
|
|
153
|
-
background-color: transparent;
|
|
154
|
-
}
|
|
155
|
-
::-webkit-scrollbar-thumb {
|
|
156
|
-
background-color: ${
|
|
157
|
-
equals(mode, 'dark')
|
|
158
|
-
? theme.palette.divider
|
|
159
|
-
: theme.palette.text.disabled
|
|
160
|
-
};
|
|
161
|
-
border-radius: ${theme.spacing(0.5)};
|
|
162
|
-
}
|
|
163
|
-
::-webkit-scrollbar-thumb:hover {
|
|
164
|
-
background-color: ${theme.palette.primary.main};
|
|
165
|
-
}
|
|
166
|
-
* {
|
|
167
|
-
scrollbar-color: ${
|
|
168
|
-
equals(mode, 'dark')
|
|
169
|
-
? theme.palette.divider
|
|
170
|
-
: theme.palette.text.disabled
|
|
171
|
-
} ${theme.palette.background.default};
|
|
172
|
-
scrollbar-width: thin;
|
|
173
|
-
}
|
|
174
150
|
html {
|
|
175
151
|
margin: 0;
|
|
176
152
|
padding: 0;
|
|
@@ -2,15 +2,12 @@ import { useAtomValue } from 'jotai';
|
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
import { equals } from 'ramda';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import dayjs from 'dayjs';
|
|
6
|
-
import utc from 'dayjs/plugin/utc';
|
|
7
|
-
import timezone from 'dayjs/plugin/timezone';
|
|
8
5
|
|
|
9
|
-
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
10
6
|
import { Typography } from '@mui/material';
|
|
11
7
|
import { LocalizationProvider } from '@mui/x-date-pickers';
|
|
12
8
|
|
|
13
9
|
import { userAtom } from '@centreon/ui-context';
|
|
10
|
+
import { useDateTimePickerAdapter } from '@centreon/ui';
|
|
14
11
|
|
|
15
12
|
import DateTimePickerInput from '../../DateTimePickerInput';
|
|
16
13
|
import {
|
|
@@ -23,9 +20,6 @@ import ErrorText from './ErrorText';
|
|
|
23
20
|
import { PickersData, PickersStartEndDateDirection } from './models';
|
|
24
21
|
import { PickersStartEndDateModel } from './usePickersStartEndDate';
|
|
25
22
|
|
|
26
|
-
dayjs.extend(utc);
|
|
27
|
-
dayjs.extend(timezone);
|
|
28
|
-
|
|
29
23
|
const useStyles = makeStyles()((theme) => ({
|
|
30
24
|
error: {
|
|
31
25
|
textAlign: 'center'
|
|
@@ -110,6 +104,7 @@ const PickersStartEndDate = ({
|
|
|
110
104
|
direction = PickersStartEndDateDirection.column
|
|
111
105
|
}: Props): JSX.Element => {
|
|
112
106
|
const { classes, cx } = useStyles();
|
|
107
|
+
const { Adapter } = useDateTimePickerAdapter();
|
|
113
108
|
|
|
114
109
|
const { locale } = useAtomValue(userAtom);
|
|
115
110
|
const error = useAtomValue(errorTimePeriodAtom);
|
|
@@ -131,7 +126,7 @@ const PickersStartEndDate = ({
|
|
|
131
126
|
return (
|
|
132
127
|
<LocalizationProvider
|
|
133
128
|
adapterLocale={locale.substring(0, 2)}
|
|
134
|
-
dateAdapter={
|
|
129
|
+
dateAdapter={Adapter}
|
|
135
130
|
>
|
|
136
131
|
<div className={styleContainer}>
|
|
137
132
|
<PickerDateWithLabel
|
|
@@ -18,6 +18,8 @@ export interface PickersData {
|
|
|
18
18
|
getError?: (value: boolean) => void;
|
|
19
19
|
isDisabledEndPicker?: boolean;
|
|
20
20
|
isDisabledStartPicker?: boolean;
|
|
21
|
+
onCloseEndPicker?: (isClosed: boolean) => void;
|
|
22
|
+
onCloseStartPicker?: (isClosed: boolean) => void;
|
|
21
23
|
rangeEndDate?: RangeDate;
|
|
22
24
|
rangeStartDate?: RangeDate;
|
|
23
25
|
}
|
|
@@ -1,85 +1,48 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { useAtomValue } from 'jotai';
|
|
5
|
-
import { equals } from 'ramda';
|
|
3
|
+
import { DateTimePicker } from '@mui/x-date-pickers';
|
|
6
4
|
|
|
7
|
-
import {
|
|
8
|
-
DateTimePicker,
|
|
9
|
-
DateTimePickerProps,
|
|
10
|
-
LocalizationProvider
|
|
11
|
-
} from '@mui/x-date-pickers';
|
|
12
|
-
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
13
|
-
|
|
14
|
-
import { userAtom } from '@centreon/ui-context';
|
|
5
|
+
import { useDateTimePickerAdapter } from '@centreon/ui';
|
|
15
6
|
|
|
16
7
|
import { CustomTimePeriodProperty } from './models';
|
|
17
8
|
|
|
18
|
-
interface ChangeDateProps {
|
|
19
|
-
date: Date;
|
|
20
|
-
property: CustomTimePeriodProperty | string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
9
|
interface Props {
|
|
24
|
-
changeDate: (props
|
|
10
|
+
changeDate: (props) => void;
|
|
25
11
|
date: Date | null;
|
|
26
12
|
desktopMediaQuery?: string;
|
|
27
13
|
disabled?: boolean;
|
|
28
14
|
maxDate?: Date;
|
|
29
15
|
minDate?: Date;
|
|
30
|
-
|
|
31
|
-
property: CustomTimePeriodProperty | string;
|
|
16
|
+
property: CustomTimePeriodProperty;
|
|
32
17
|
}
|
|
33
18
|
|
|
34
19
|
const DateTimePickerInput = ({
|
|
35
20
|
date,
|
|
36
21
|
maxDate,
|
|
37
22
|
minDate,
|
|
38
|
-
minDateTime,
|
|
39
23
|
property,
|
|
40
24
|
changeDate,
|
|
41
25
|
disabled = false,
|
|
42
|
-
desktopMediaQuery
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const desktopPickerMediaQuery =
|
|
46
|
-
'@media (min-width: 1024px) or (pointer: fine)';
|
|
47
|
-
|
|
48
|
-
const { timezone, locale } = useAtomValue(userAtom);
|
|
49
|
-
|
|
50
|
-
const isUTC = equals(timezone, 'UTC');
|
|
26
|
+
desktopMediaQuery
|
|
27
|
+
}: Props): JSX.Element => {
|
|
28
|
+
const { desktopPickerMediaQuery } = useDateTimePickerAdapter();
|
|
51
29
|
|
|
52
30
|
const changeTime = (newValue: dayjs.Dayjs | null): void => {
|
|
53
31
|
changeDate({ date: dayjs(newValue).toDate(), property });
|
|
54
32
|
};
|
|
55
33
|
|
|
56
|
-
const formatDate = useCallback(
|
|
57
|
-
(currentDate: Date | null): Dayjs => {
|
|
58
|
-
return isUTC ? dayjs.utc(currentDate) : dayjs.tz(currentDate, timezone);
|
|
59
|
-
},
|
|
60
|
-
[isUTC, timezone]
|
|
61
|
-
);
|
|
62
|
-
|
|
63
34
|
return (
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
maxDate={maxDate && formatDate(maxDate)}
|
|
76
|
-
minDate={minDate && formatDate(minDate)}
|
|
77
|
-
minDateTime={minDateTime && formatDate(minDateTime)}
|
|
78
|
-
value={formatDate(date)}
|
|
79
|
-
onChange={changeTime}
|
|
80
|
-
{...rest}
|
|
81
|
-
/>
|
|
82
|
-
</LocalizationProvider>
|
|
35
|
+
<DateTimePicker<dayjs.Dayjs>
|
|
36
|
+
dayOfWeekFormatter={(day: string): string =>
|
|
37
|
+
day.substring(0, 2).toUpperCase()
|
|
38
|
+
}
|
|
39
|
+
desktopModeMediaQuery={desktopMediaQuery ?? desktopPickerMediaQuery}
|
|
40
|
+
disabled={disabled}
|
|
41
|
+
maxDate={maxDate && dayjs(maxDate)}
|
|
42
|
+
minDate={minDate && dayjs(minDate)}
|
|
43
|
+
value={dayjs(date)}
|
|
44
|
+
onChange={changeTime}
|
|
45
|
+
/>
|
|
83
46
|
);
|
|
84
47
|
};
|
|
85
48
|
|