@centreon/ui 24.4.22 → 24.4.23
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/Content.tsx +9 -26
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +3 -10
- 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/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/IconPopover/index.tsx +2 -2
- package/src/InputField/Select/index.tsx +1 -1
- 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 +9 -8
- 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 +17 -45
- 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 +2 -2
- 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/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
|
@@ -24,21 +24,7 @@ export const success: Story = {
|
|
|
24
24
|
critical: 'Critical',
|
|
25
25
|
warning: 'Warning'
|
|
26
26
|
},
|
|
27
|
-
thresholds:
|
|
28
|
-
critical: [
|
|
29
|
-
{
|
|
30
|
-
label: 'Critical',
|
|
31
|
-
value: 1.5
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
enabled: true,
|
|
35
|
-
warning: [
|
|
36
|
-
{
|
|
37
|
-
label: 'Warning',
|
|
38
|
-
value: 0.5
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
|
27
|
+
thresholds: [0.5, 1.5]
|
|
42
28
|
},
|
|
43
29
|
render: Template
|
|
44
30
|
};
|
|
@@ -50,21 +36,7 @@ export const warning: Story = {
|
|
|
50
36
|
critical: 'Critical',
|
|
51
37
|
warning: 'Warning'
|
|
52
38
|
},
|
|
53
|
-
thresholds:
|
|
54
|
-
critical: [
|
|
55
|
-
{
|
|
56
|
-
label: 'Critical',
|
|
57
|
-
value: 1.5
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
enabled: true,
|
|
61
|
-
warning: [
|
|
62
|
-
{
|
|
63
|
-
label: 'Warning',
|
|
64
|
-
value: 0.4
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
39
|
+
thresholds: [0.2, 0.5]
|
|
68
40
|
},
|
|
69
41
|
render: Template
|
|
70
42
|
};
|
|
@@ -76,21 +48,7 @@ export const critical: Story = {
|
|
|
76
48
|
critical: 'Critical',
|
|
77
49
|
warning: 'Warning'
|
|
78
50
|
},
|
|
79
|
-
thresholds:
|
|
80
|
-
critical: [
|
|
81
|
-
{
|
|
82
|
-
label: 'Critical',
|
|
83
|
-
value: 0.3
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
enabled: true,
|
|
87
|
-
warning: [
|
|
88
|
-
{
|
|
89
|
-
label: 'Warning',
|
|
90
|
-
value: 0.2
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
}
|
|
51
|
+
thresholds: [0.13, 0.35]
|
|
94
52
|
},
|
|
95
53
|
render: Template
|
|
96
54
|
};
|
|
@@ -103,21 +61,7 @@ export const rawValue: Story = {
|
|
|
103
61
|
critical: 'Critical',
|
|
104
62
|
warning: 'Warning'
|
|
105
63
|
},
|
|
106
|
-
thresholds:
|
|
107
|
-
critical: [
|
|
108
|
-
{
|
|
109
|
-
label: 'Critical',
|
|
110
|
-
value: 1.5
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
enabled: true,
|
|
114
|
-
warning: [
|
|
115
|
-
{
|
|
116
|
-
label: 'Warning',
|
|
117
|
-
value: 0.5
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
}
|
|
64
|
+
thresholds: [0.5, 1.5]
|
|
121
65
|
},
|
|
122
66
|
render: Template
|
|
123
67
|
};
|
|
@@ -179,7 +179,7 @@ const getMetricValuesForUnit = ({
|
|
|
179
179
|
) as Array<number>;
|
|
180
180
|
|
|
181
181
|
return pipe(
|
|
182
|
-
filter(propEq(unit,
|
|
182
|
+
filter(propEq('unit', unit)) as (line) => Array<Line>,
|
|
183
183
|
map(prop('metric_id')),
|
|
184
184
|
map(getTimeSeriesValuesForMetric),
|
|
185
185
|
flatten,
|
|
@@ -203,7 +203,7 @@ const getLineForMetric = ({
|
|
|
203
203
|
lines,
|
|
204
204
|
metric_id
|
|
205
205
|
}: LineForMetricProps): Line | undefined =>
|
|
206
|
-
find(propEq(metric_id,
|
|
206
|
+
find(propEq('metric_id', metric_id), lines);
|
|
207
207
|
|
|
208
208
|
interface LinesTimeSeries {
|
|
209
209
|
lines: Array<Line>;
|
|
@@ -275,7 +275,7 @@ interface HasStackedLines {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
const hasUnitStackedLines = ({ lines, unit }: HasStackedLines): boolean =>
|
|
278
|
-
pipe(getSortedStackedLines, any(propEq(unit,
|
|
278
|
+
pipe(getSortedStackedLines, any(propEq('unit', unit)))(lines);
|
|
279
279
|
|
|
280
280
|
const getTimeSeriesForLines = ({
|
|
281
281
|
lines,
|
|
@@ -292,16 +292,13 @@ const ConnectedAutocompleteField = (
|
|
|
292
292
|
}
|
|
293
293
|
}, [optionsOpen]);
|
|
294
294
|
|
|
295
|
-
useEffect(
|
|
296
|
-
(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
},
|
|
303
|
-
useDeepCompare([searchConditions])
|
|
304
|
-
);
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
setSearchParameter(
|
|
297
|
+
!isEmpty(searchConditions)
|
|
298
|
+
? { conditions: searchConditions }
|
|
299
|
+
: undefined
|
|
300
|
+
);
|
|
301
|
+
}, useDeepCompare([searchConditions]));
|
|
305
302
|
|
|
306
303
|
useEffect(() => {
|
|
307
304
|
if (!autocompleteChangedValue && !props?.value) {
|
|
@@ -49,7 +49,7 @@ const SortableListContent = ({
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const itemIndex = findIndex(propEq(id,
|
|
52
|
+
const itemIndex = findIndex(propEq('id', id), items);
|
|
53
53
|
|
|
54
54
|
itemHover?.(null);
|
|
55
55
|
itemClick?.({ index: itemIndex, item: { createOption, id, name } });
|
|
@@ -77,7 +77,7 @@ const DraggableAutocomplete = (
|
|
|
77
77
|
const deleteValue = (id): void => {
|
|
78
78
|
itemHover?.(null);
|
|
79
79
|
setSelectedValues((values: Array<DraggableSelectEntry>) => {
|
|
80
|
-
const index = findIndex(propEq(id,
|
|
80
|
+
const index = findIndex(propEq('id', id), values);
|
|
81
81
|
|
|
82
82
|
const newSelectedValues = remove(index, 1, values);
|
|
83
83
|
|
|
@@ -73,14 +73,14 @@ const IconPopoverMultiAutocomplete = ({
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
const isSelected = (id: number | string): boolean => {
|
|
76
|
-
return pipe(find(propEq(id,
|
|
76
|
+
return pipe(find(propEq('id', id)), Boolean)(value);
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
const unSelect = (option: SelectEntry): void => {
|
|
80
80
|
const { id } = option;
|
|
81
81
|
|
|
82
82
|
const updatedValue = isSelected(id)
|
|
83
|
-
? reject(propEq(id,
|
|
83
|
+
? reject(propEq('id', id), value)
|
|
84
84
|
: [...value, option];
|
|
85
85
|
|
|
86
86
|
onChange(updatedValue);
|
|
@@ -69,7 +69,7 @@ const SelectField = ({
|
|
|
69
69
|
const { classes, cx } = useStyles();
|
|
70
70
|
|
|
71
71
|
const getOption = (id): SelectEntry => {
|
|
72
|
-
return options.find(propEq(id,
|
|
72
|
+
return options.find(propEq('id', id)) as SelectEntry;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
const changeOption = (event): void => {
|
|
@@ -107,21 +107,7 @@ const DataCell = ({
|
|
|
107
107
|
const isCellHidden = getHiddenCondition?.(isRowSelected);
|
|
108
108
|
|
|
109
109
|
if (isCellHidden) {
|
|
110
|
-
return
|
|
111
|
-
<Cell
|
|
112
|
-
className={classes.cell}
|
|
113
|
-
isRowHighlighted={isRowHighlighted}
|
|
114
|
-
listingVariant={listingVariant}
|
|
115
|
-
onClick={(e): void => {
|
|
116
|
-
if (!clickable) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
e.preventDefault();
|
|
120
|
-
e.stopPropagation();
|
|
121
|
-
}}
|
|
122
|
-
{...commonCellProps}
|
|
123
|
-
/>
|
|
124
|
-
);
|
|
110
|
+
return null;
|
|
125
111
|
}
|
|
126
112
|
|
|
127
113
|
return (
|
|
@@ -77,9 +77,9 @@ const mountListing = (): void => {
|
|
|
77
77
|
subItems={{
|
|
78
78
|
canCheckSubItems: false,
|
|
79
79
|
enable: true,
|
|
80
|
-
getRowProperty: () => 'subItems',
|
|
81
80
|
labelCollapse: 'Collapse',
|
|
82
|
-
labelExpand: 'Expand'
|
|
81
|
+
labelExpand: 'Expand',
|
|
82
|
+
rowProperty: 'subItems'
|
|
83
83
|
}}
|
|
84
84
|
totalRows={10}
|
|
85
85
|
/>
|
|
@@ -9,12 +9,13 @@ const loadingIndicatorHeight = 3;
|
|
|
9
9
|
interface StylesProps {
|
|
10
10
|
dataStyle: TableStyle;
|
|
11
11
|
getGridTemplateColumn: string;
|
|
12
|
+
limit: number;
|
|
12
13
|
listingVariant: ListingVariant;
|
|
13
14
|
rows: Array<unknown>;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
const useListingStyles = makeStyles<StylesProps>()(
|
|
17
|
-
(theme, { dataStyle, getGridTemplateColumn, rows }) => ({
|
|
18
|
+
(theme, { dataStyle, getGridTemplateColumn, rows, limit }) => ({
|
|
18
19
|
actionBar: {
|
|
19
20
|
alignItems: 'center',
|
|
20
21
|
display: 'flex'
|
|
@@ -55,7 +56,7 @@ const useListingStyles = makeStyles<StylesProps>()(
|
|
|
55
56
|
display: 'grid',
|
|
56
57
|
gridTemplateColumns: getGridTemplateColumn,
|
|
57
58
|
gridTemplateRows: `${theme.spacing(dataStyle.header.height / 8)} repeat(${
|
|
58
|
-
rows?.length ||
|
|
59
|
+
rows?.length || limit
|
|
59
60
|
}, ${dataStyle.body.height}px)`,
|
|
60
61
|
position: 'relative'
|
|
61
62
|
},
|
|
@@ -366,16 +366,6 @@ const columnsWithSubItems = [
|
|
|
366
366
|
}
|
|
367
367
|
];
|
|
368
368
|
|
|
369
|
-
const TemplateSubItems = (args): JSX.Element => {
|
|
370
|
-
const { classes } = useStyles();
|
|
371
|
-
|
|
372
|
-
return (
|
|
373
|
-
<div className={classes.listing}>
|
|
374
|
-
<Listing {...args} />
|
|
375
|
-
</div>
|
|
376
|
-
);
|
|
377
|
-
};
|
|
378
|
-
|
|
379
369
|
export const ListingWithSubItems = {
|
|
380
370
|
args: {
|
|
381
371
|
checkable: true,
|
|
@@ -387,11 +377,10 @@ export const ListingWithSubItems = {
|
|
|
387
377
|
subItems: {
|
|
388
378
|
canCheckSubItems: false,
|
|
389
379
|
enable: true,
|
|
390
|
-
getRowProperty: () => 'subItems',
|
|
391
380
|
labelCollapse: 'Collapse',
|
|
392
|
-
labelExpand: 'Expand'
|
|
381
|
+
labelExpand: 'Expand',
|
|
382
|
+
rowProperty: 'subItems'
|
|
393
383
|
},
|
|
394
384
|
totalRows: 10
|
|
395
|
-
}
|
|
396
|
-
render: TemplateSubItems
|
|
385
|
+
}
|
|
397
386
|
};
|
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
|
|
|
@@ -121,9 +121,9 @@ export interface Props<TRow> {
|
|
|
121
121
|
subItems?: {
|
|
122
122
|
canCheckSubItems: boolean;
|
|
123
123
|
enable: boolean;
|
|
124
|
-
getRowProperty: (row?) => string;
|
|
125
124
|
labelCollapse: string;
|
|
126
125
|
labelExpand: string;
|
|
126
|
+
rowProperty: string;
|
|
127
127
|
};
|
|
128
128
|
totalRows?: number;
|
|
129
129
|
viewerModeConfiguration?: ViewerModeConfiguration;
|
|
@@ -176,9 +176,9 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
176
176
|
subItems = {
|
|
177
177
|
canCheckSubItems: false,
|
|
178
178
|
enable: false,
|
|
179
|
-
getRowProperty: () => '',
|
|
180
179
|
labelCollapse: 'Collapse',
|
|
181
|
-
labelExpand: 'Expand'
|
|
180
|
+
labelExpand: 'Expand',
|
|
181
|
+
rowProperty: ''
|
|
182
182
|
}
|
|
183
183
|
}: Props<TRow>): JSX.Element => {
|
|
184
184
|
const currentVisibleColumns = getVisibleColumns({
|
|
@@ -211,10 +211,10 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
211
211
|
? reduce<TRow, Array<TRow>>(
|
|
212
212
|
(acc, row): Array<TRow> => {
|
|
213
213
|
if (
|
|
214
|
-
row[subItems.
|
|
214
|
+
row[subItems.rowProperty] &&
|
|
215
215
|
subItemsPivots.includes(row.id)
|
|
216
216
|
) {
|
|
217
|
-
return [...acc, row, ...row[subItems.
|
|
217
|
+
return [...acc, row, ...row[subItems.rowProperty]];
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
return [...acc, row];
|
|
@@ -229,6 +229,7 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
229
229
|
const { classes } = useListingStyles({
|
|
230
230
|
dataStyle,
|
|
231
231
|
getGridTemplateColumn,
|
|
232
|
+
limit,
|
|
232
233
|
listingVariant,
|
|
233
234
|
rows: rowsToDisplay
|
|
234
235
|
});
|
|
@@ -449,7 +450,7 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
449
450
|
reduce<TRow | number, Array<string | number>>(
|
|
450
451
|
(acc, row) => [
|
|
451
452
|
...acc,
|
|
452
|
-
...pluck('id', row[subItems?.
|
|
453
|
+
...pluck('id', row[subItems?.rowProperty || ''] || [])
|
|
453
454
|
],
|
|
454
455
|
[],
|
|
455
456
|
rows
|
|
@@ -620,7 +621,7 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
620
621
|
listingVariant={listingVariant}
|
|
621
622
|
row={row}
|
|
622
623
|
rowColorConditions={rowColorConditions}
|
|
623
|
-
subItemsRowProperty={subItems?.
|
|
624
|
+
subItemsRowProperty={subItems?.rowProperty}
|
|
624
625
|
/>
|
|
625
626
|
))}
|
|
626
627
|
</ListingRow>
|
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,29 +1,19 @@
|
|
|
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
|
-
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
9
|
-
|
|
10
|
-
import { userAtom } from '@centreon/ui-context';
|
|
5
|
+
import { useDateTimePickerAdapter } from '@centreon/ui';
|
|
11
6
|
|
|
12
7
|
import { CustomTimePeriodProperty } from './models';
|
|
13
8
|
|
|
14
|
-
interface ChangeDateProps {
|
|
15
|
-
date: Date;
|
|
16
|
-
property: CustomTimePeriodProperty | string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
9
|
interface Props {
|
|
20
|
-
changeDate: (props
|
|
10
|
+
changeDate: (props) => void;
|
|
21
11
|
date: Date | null;
|
|
22
12
|
desktopMediaQuery?: string;
|
|
23
13
|
disabled?: boolean;
|
|
24
14
|
maxDate?: Date;
|
|
25
15
|
minDate?: Date;
|
|
26
|
-
property: CustomTimePeriodProperty
|
|
16
|
+
property: CustomTimePeriodProperty;
|
|
27
17
|
}
|
|
28
18
|
|
|
29
19
|
const DateTimePickerInput = ({
|
|
@@ -35,42 +25,24 @@ const DateTimePickerInput = ({
|
|
|
35
25
|
disabled = false,
|
|
36
26
|
desktopMediaQuery
|
|
37
27
|
}: Props): JSX.Element => {
|
|
38
|
-
const desktopPickerMediaQuery =
|
|
39
|
-
'@media (min-width: 1024px) or (pointer: fine)';
|
|
40
|
-
|
|
41
|
-
const { timezone, locale } = useAtomValue(userAtom);
|
|
42
|
-
|
|
43
|
-
const isUTC = equals(timezone, 'UTC');
|
|
28
|
+
const { desktopPickerMediaQuery } = useDateTimePickerAdapter();
|
|
44
29
|
|
|
45
30
|
const changeTime = (newValue: dayjs.Dayjs | null): void => {
|
|
46
31
|
changeDate({ date: dayjs(newValue).toDate(), property });
|
|
47
32
|
};
|
|
48
33
|
|
|
49
|
-
const formatDate = useCallback(
|
|
50
|
-
(currentDate: Date | null): Dayjs => {
|
|
51
|
-
return isUTC ? dayjs.utc(currentDate) : dayjs.tz(currentDate, timezone);
|
|
52
|
-
},
|
|
53
|
-
[isUTC, timezone]
|
|
54
|
-
);
|
|
55
|
-
|
|
56
34
|
return (
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
maxDate={maxDate && formatDate(maxDate)}
|
|
69
|
-
minDate={minDate && formatDate(minDate)}
|
|
70
|
-
value={formatDate(date)}
|
|
71
|
-
onChange={changeTime}
|
|
72
|
-
/>
|
|
73
|
-
</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
|
+
/>
|
|
74
46
|
);
|
|
75
47
|
};
|
|
76
48
|
|