@centreon/ui 24.4.8 → 24.4.10
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 +17 -12
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/FileDropZone/index.tsx +3 -1
- package/src/Form/Form.cypress.spec.tsx +133 -0
- package/src/Form/Inputs/CheckboxGroup.tsx +1 -4
- package/src/Form/Inputs/List/Content.tsx +62 -0
- package/src/Form/Inputs/List/List.styles.ts +29 -0
- package/src/Form/Inputs/List/List.tsx +58 -0
- package/src/Form/Inputs/List/useList.ts +81 -0
- package/src/Form/Inputs/index.tsx +3 -1
- package/src/Form/Inputs/models.ts +9 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +5 -4
- 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 +2 -3
- 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 +16 -13
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +4 -2
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.stories.tsx +60 -4
- package/src/Graph/common/timeSeries/index.ts +3 -3
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
- 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/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.styles.ts +2 -3
- package/src/Listing/index.stories.tsx +12 -1
- package/src/Listing/index.tsx +1 -2
- package/src/RichTextEditor/RichTextEditor.tsx +12 -1
- package/src/SortableItems/index.tsx +2 -7
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -3
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -2
- package/src/TimePeriods/DateTimePickerInput.tsx +45 -17
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +9 -33
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +12 -4
- package/src/TimePeriods/index.tsx +2 -2
- package/src/Typography/Subtitle.tsx +55 -0
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.ts +27 -23
- package/src/api/useMutationQuery/index.ts +41 -17
- package/src/components/DataTable/DataListing.tsx +6 -0
- package/src/components/DataTable/DataTable.cypress.spec.tsx +193 -0
- package/src/components/DataTable/DataTable.stories.tsx +40 -0
- package/src/components/DataTable/DataTable.styles.ts +3 -0
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +7 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +2 -2
- package/src/components/DataTable/index.ts +3 -1
- package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +2 -0
- package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +1 -1
- package/src/components/Form/Dashboard/DashboardForm.tsx +15 -12
- package/src/components/Modal/Modal.styles.ts +4 -3
- package/src/components/Modal/ModalActions.tsx +4 -2
- package/src/index.ts +2 -0
- package/src/queryParameters/url/index.ts +5 -1
- package/src/utils/index.ts +1 -1
- package/src/utils/{useLicenseExpirationWarning.cypress.spec.tsx → useLicenseExpirationWarning.test.tsx} +48 -37
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/utils/usePluralizedTranslation.ts +21 -0
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +0 -281
- package/src/utils/useDateTimePickerAdapter.ts +0 -309
|
@@ -27,9 +27,9 @@ interface Props {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
|
|
30
|
-
const displayedLines = reject(propEq('display'
|
|
30
|
+
const displayedLines = reject(propEq(false, 'display'), lines);
|
|
31
31
|
const getLineByMetric = (metric_id: number): Line =>
|
|
32
|
-
find(propEq(
|
|
32
|
+
find(propEq(metric_id, 'metric_id'), lines) as Line;
|
|
33
33
|
|
|
34
34
|
const toggleMetricLine = (metric_id): void => {
|
|
35
35
|
const data = lines.map((line) => ({
|
|
@@ -92,7 +92,7 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
|
|
|
92
92
|
|
|
93
93
|
const newLines = lines.map((line) => ({
|
|
94
94
|
...line,
|
|
95
|
-
display: find(propEq(
|
|
95
|
+
display: find(propEq(line.metric_id, 'metric_id'), lines)?.display ?? true
|
|
96
96
|
}));
|
|
97
97
|
|
|
98
98
|
setLinesGraph(newLines);
|
|
@@ -69,21 +69,24 @@ export const getDescription = ({ sections }: Description): string => {
|
|
|
69
69
|
})}<br></details>`;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const formattedProps = props.reduce(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
const formattedProps = props.reduce(
|
|
73
|
+
(accumulator, currentValue, index) => {
|
|
74
|
+
const key = Object.keys(currentValue)[0];
|
|
75
|
+
const { description, type } = currentValue[key];
|
|
76
|
+
const body = `${accumulator} ${getBodyDescription({
|
|
77
|
+
description,
|
|
78
|
+
key,
|
|
79
|
+
type
|
|
80
|
+
})}`;
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
if (!equals(index, props.length - 1)) {
|
|
83
|
+
return body;
|
|
84
|
+
}
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
return `${body}</details>`;
|
|
87
|
+
},
|
|
88
|
+
getInitialValue({ section: name, type: item?.type })
|
|
89
|
+
);
|
|
87
90
|
|
|
88
91
|
return formattedProps as string;
|
|
89
92
|
});
|
|
@@ -14,7 +14,7 @@ import { LineChartData } from '../../common/models';
|
|
|
14
14
|
export const adjustGraphData = (graphData: LineChartData): LinesData => {
|
|
15
15
|
const lines = getLineData(graphData);
|
|
16
16
|
const sortedLines = sortBy(prop('name'), lines);
|
|
17
|
-
const displayedLines = reject(propEq('display'
|
|
17
|
+
const displayedLines = reject(propEq(false, 'display'), sortedLines);
|
|
18
18
|
|
|
19
19
|
const timeSeries = getTimeSeries(graphData);
|
|
20
20
|
|
|
@@ -39,8 +39,7 @@ import { Interval, ThresholdType, TooltipData } from './models';
|
|
|
39
39
|
import WrapperLineChart from './index';
|
|
40
40
|
|
|
41
41
|
const meta: Meta<typeof WrapperLineChart> = {
|
|
42
|
-
component: WrapperLineChart
|
|
43
|
-
tags: ['autodocs']
|
|
42
|
+
component: WrapperLineChart
|
|
44
43
|
};
|
|
45
44
|
export default meta;
|
|
46
45
|
|
|
@@ -353,6 +352,9 @@ export const LineChartWithTimePeriod: Story = {
|
|
|
353
352
|
end: defaultEnd,
|
|
354
353
|
height: 500,
|
|
355
354
|
start: defaultStart
|
|
355
|
+
},
|
|
356
|
+
parameters: {
|
|
357
|
+
chromatic: { diffThreshold: 0.1 }
|
|
356
358
|
}
|
|
357
359
|
};
|
|
358
360
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Thresholds } from '../common/models';
|
|
1
|
+
import { Thresholds as ThresholdsModel } from '../common/models';
|
|
2
2
|
|
|
3
3
|
import { ThresholdLine } from './ThresholdLine';
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ interface Props {
|
|
|
8
8
|
hideTooltip: () => void;
|
|
9
9
|
showTooltip: (args) => void;
|
|
10
10
|
size: 'small' | 'medium';
|
|
11
|
-
thresholds:
|
|
11
|
+
thresholds: ThresholdsModel;
|
|
12
12
|
xScale: (value: number) => number;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -24,7 +24,21 @@ export const success: Story = {
|
|
|
24
24
|
critical: 'Critical',
|
|
25
25
|
warning: 'Warning'
|
|
26
26
|
},
|
|
27
|
-
thresholds:
|
|
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
|
+
}
|
|
28
42
|
},
|
|
29
43
|
render: Template
|
|
30
44
|
};
|
|
@@ -36,7 +50,21 @@ export const warning: Story = {
|
|
|
36
50
|
critical: 'Critical',
|
|
37
51
|
warning: 'Warning'
|
|
38
52
|
},
|
|
39
|
-
thresholds:
|
|
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
|
+
}
|
|
40
68
|
},
|
|
41
69
|
render: Template
|
|
42
70
|
};
|
|
@@ -48,7 +76,21 @@ export const critical: Story = {
|
|
|
48
76
|
critical: 'Critical',
|
|
49
77
|
warning: 'Warning'
|
|
50
78
|
},
|
|
51
|
-
thresholds:
|
|
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
|
+
}
|
|
52
94
|
},
|
|
53
95
|
render: Template
|
|
54
96
|
};
|
|
@@ -61,7 +103,21 @@ export const rawValue: Story = {
|
|
|
61
103
|
critical: 'Critical',
|
|
62
104
|
warning: 'Warning'
|
|
63
105
|
},
|
|
64
|
-
thresholds:
|
|
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
|
+
}
|
|
65
121
|
},
|
|
66
122
|
render: Template
|
|
67
123
|
};
|
|
@@ -179,7 +179,7 @@ const getMetricValuesForUnit = ({
|
|
|
179
179
|
) as Array<number>;
|
|
180
180
|
|
|
181
181
|
return pipe(
|
|
182
|
-
filter(propEq(
|
|
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(
|
|
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(
|
|
278
|
+
pipe(getSortedStackedLines, any(propEq(unit, 'unit')))(lines);
|
|
279
279
|
|
|
280
280
|
const getTimeSeriesForLines = ({
|
|
281
281
|
lines,
|
|
@@ -283,13 +283,16 @@ const ConnectedAutocompleteField = (
|
|
|
283
283
|
}
|
|
284
284
|
}, [optionsOpen]);
|
|
285
285
|
|
|
286
|
-
useEffect(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
286
|
+
useEffect(
|
|
287
|
+
() => {
|
|
288
|
+
setSearchParameter(
|
|
289
|
+
!isEmpty(searchConditions)
|
|
290
|
+
? { conditions: searchConditions }
|
|
291
|
+
: undefined
|
|
292
|
+
);
|
|
293
|
+
},
|
|
294
|
+
useDeepCompare([searchConditions])
|
|
295
|
+
);
|
|
293
296
|
|
|
294
297
|
useEffect(() => {
|
|
295
298
|
if (!autocompleteChangedValue && !props?.value) {
|
|
@@ -49,7 +49,7 @@ const SortableListContent = ({
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const itemIndex = findIndex(propEq(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
72
|
+
return options.find(propEq(id, 'id')) as SelectEntry;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
const changeOption = (event): void => {
|
|
@@ -9,13 +9,12 @@ const loadingIndicatorHeight = 3;
|
|
|
9
9
|
interface StylesProps {
|
|
10
10
|
dataStyle: TableStyle;
|
|
11
11
|
getGridTemplateColumn: string;
|
|
12
|
-
limit: number;
|
|
13
12
|
listingVariant: ListingVariant;
|
|
14
13
|
rows: Array<unknown>;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
const useListingStyles = makeStyles<StylesProps>()(
|
|
18
|
-
(theme, { dataStyle, getGridTemplateColumn, rows
|
|
17
|
+
(theme, { dataStyle, getGridTemplateColumn, rows }) => ({
|
|
19
18
|
actionBar: {
|
|
20
19
|
alignItems: 'center',
|
|
21
20
|
display: 'flex'
|
|
@@ -56,7 +55,7 @@ const useListingStyles = makeStyles<StylesProps>()(
|
|
|
56
55
|
display: 'grid',
|
|
57
56
|
gridTemplateColumns: getGridTemplateColumn,
|
|
58
57
|
gridTemplateRows: `${theme.spacing(dataStyle.header.height / 8)} repeat(${
|
|
59
|
-
rows?.length ||
|
|
58
|
+
rows?.length || 1
|
|
60
59
|
}, ${dataStyle.body.height}px)`,
|
|
61
60
|
position: 'relative'
|
|
62
61
|
},
|
|
@@ -366,6 +366,16 @@ 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
|
+
|
|
369
379
|
export const ListingWithSubItems = {
|
|
370
380
|
args: {
|
|
371
381
|
checkable: true,
|
|
@@ -382,5 +392,6 @@ export const ListingWithSubItems = {
|
|
|
382
392
|
rowProperty: 'subItems'
|
|
383
393
|
},
|
|
384
394
|
totalRows: 10
|
|
385
|
-
}
|
|
395
|
+
},
|
|
396
|
+
render: TemplateSubItems
|
|
386
397
|
};
|
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(
|
|
72
|
+
columns.find(propEq(id, 'id'))
|
|
73
73
|
) as Array<Column>;
|
|
74
74
|
};
|
|
75
75
|
|
|
@@ -229,7 +229,6 @@ const Listing = <TRow extends { id: RowId }>({
|
|
|
229
229
|
const { classes } = useListingStyles({
|
|
230
230
|
dataStyle,
|
|
231
231
|
getGridTemplateColumn,
|
|
232
|
-
limit,
|
|
233
232
|
listingVariant,
|
|
234
233
|
rows: rowsToDisplay
|
|
235
234
|
});
|
|
@@ -12,6 +12,7 @@ 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';
|
|
15
16
|
|
|
16
17
|
import { Typography } from '@mui/material';
|
|
17
18
|
|
|
@@ -38,6 +39,7 @@ export interface RichTextEditorProps {
|
|
|
38
39
|
openLinkInNewTab?: boolean;
|
|
39
40
|
placeholder?: string;
|
|
40
41
|
resetEditorToInitialStateCondition?: () => boolean;
|
|
42
|
+
setHtmlString?: (htmlString: string) => void;
|
|
41
43
|
toolbarClassName?: string;
|
|
42
44
|
toolbarPositions?: 'start' | 'end';
|
|
43
45
|
}
|
|
@@ -143,6 +145,7 @@ const RichTextEditor = ({
|
|
|
143
145
|
openLinkInNewTab = true,
|
|
144
146
|
initialize,
|
|
145
147
|
displayBlockButtons = true,
|
|
148
|
+
setHtmlString,
|
|
146
149
|
toolbarClassName
|
|
147
150
|
}: RichTextEditorProps): JSX.Element => {
|
|
148
151
|
const { classes } = useStyles({ toolbarPositions });
|
|
@@ -178,6 +181,13 @@ const RichTextEditor = ({
|
|
|
178
181
|
}
|
|
179
182
|
};
|
|
180
183
|
|
|
184
|
+
const change = (state: EditorState, editor: LexicalEditor): void => {
|
|
185
|
+
editor.update(() => {
|
|
186
|
+
setHtmlString?.($generateHtmlFromNodes(editor, null));
|
|
187
|
+
});
|
|
188
|
+
getEditorState?.(state, editor);
|
|
189
|
+
};
|
|
190
|
+
|
|
181
191
|
return (
|
|
182
192
|
<LexicalComposer initialConfig={initialConfig}>
|
|
183
193
|
<div className={classes.container}>
|
|
@@ -210,6 +220,7 @@ const RichTextEditor = ({
|
|
|
210
220
|
resetEditorToInitialStateCondition={
|
|
211
221
|
resetEditorToInitialStateCondition
|
|
212
222
|
}
|
|
223
|
+
setHtmlString={setHtmlString}
|
|
213
224
|
onBlur={onBlur}
|
|
214
225
|
/>
|
|
215
226
|
}
|
|
@@ -218,7 +229,7 @@ const RichTextEditor = ({
|
|
|
218
229
|
<HistoryPlugin />
|
|
219
230
|
<LinkPlugin />
|
|
220
231
|
<ListPlugin />
|
|
221
|
-
<OnChangePlugin onChange={
|
|
232
|
+
<OnChangePlugin onChange={change} />
|
|
222
233
|
<AutoCompleteLinkPlugin openLinkInNewTab={openLinkInNewTab} />
|
|
223
234
|
<FloatingLinkEditorPlugin
|
|
224
235
|
editable={editable}
|
|
@@ -15,11 +15,7 @@ import {
|
|
|
15
15
|
DragEndEvent,
|
|
16
16
|
Over
|
|
17
17
|
} from '@dnd-kit/core';
|
|
18
|
-
import {
|
|
19
|
-
SortableContext,
|
|
20
|
-
sortableKeyboardCoordinates,
|
|
21
|
-
SortingStrategy
|
|
22
|
-
} from '@dnd-kit/sortable';
|
|
18
|
+
import { SortableContext, SortingStrategy } from '@dnd-kit/sortable';
|
|
23
19
|
import {
|
|
24
20
|
equals,
|
|
25
21
|
find,
|
|
@@ -117,7 +113,6 @@ const SortableItems = <T extends { [propertyToFilterItemsOn]: string }>({
|
|
|
117
113
|
useSensor(MouseSensor),
|
|
118
114
|
useSensor(PointerSensor),
|
|
119
115
|
useSensor(KeyboardSensor, {
|
|
120
|
-
coordinateGetter: sortableKeyboardCoordinates,
|
|
121
116
|
keyboardCodes: {
|
|
122
117
|
cancel: ['Escape'],
|
|
123
118
|
end: ['Space', 'Enter'],
|
|
@@ -169,7 +164,7 @@ const SortableItems = <T extends { [propertyToFilterItemsOn]: string }>({
|
|
|
169
164
|
};
|
|
170
165
|
|
|
171
166
|
const getItemById = (id): T | undefined =>
|
|
172
|
-
find(propEq(
|
|
167
|
+
find(propEq(id, propertyToFilterItemsOn), items);
|
|
173
168
|
|
|
174
169
|
const activeItem = getItemById(activeId) as Record<string, unknown>;
|
|
175
170
|
|
|
@@ -2,12 +2,15 @@ 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';
|
|
5
8
|
|
|
9
|
+
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
6
10
|
import { Typography } from '@mui/material';
|
|
7
11
|
import { LocalizationProvider } from '@mui/x-date-pickers';
|
|
8
12
|
|
|
9
13
|
import { userAtom } from '@centreon/ui-context';
|
|
10
|
-
import { useDateTimePickerAdapter } from '@centreon/ui';
|
|
11
14
|
|
|
12
15
|
import DateTimePickerInput from '../../DateTimePickerInput';
|
|
13
16
|
import {
|
|
@@ -20,6 +23,9 @@ import ErrorText from './ErrorText';
|
|
|
20
23
|
import { PickersData, PickersStartEndDateDirection } from './models';
|
|
21
24
|
import { PickersStartEndDateModel } from './usePickersStartEndDate';
|
|
22
25
|
|
|
26
|
+
dayjs.extend(utc);
|
|
27
|
+
dayjs.extend(timezone);
|
|
28
|
+
|
|
23
29
|
const useStyles = makeStyles()((theme) => ({
|
|
24
30
|
error: {
|
|
25
31
|
textAlign: 'center'
|
|
@@ -104,7 +110,6 @@ const PickersStartEndDate = ({
|
|
|
104
110
|
direction = PickersStartEndDateDirection.column
|
|
105
111
|
}: Props): JSX.Element => {
|
|
106
112
|
const { classes, cx } = useStyles();
|
|
107
|
-
const { Adapter } = useDateTimePickerAdapter();
|
|
108
113
|
|
|
109
114
|
const { locale } = useAtomValue(userAtom);
|
|
110
115
|
const error = useAtomValue(errorTimePeriodAtom);
|
|
@@ -126,7 +131,7 @@ const PickersStartEndDate = ({
|
|
|
126
131
|
return (
|
|
127
132
|
<LocalizationProvider
|
|
128
133
|
adapterLocale={locale.substring(0, 2)}
|
|
129
|
-
dateAdapter={
|
|
134
|
+
dateAdapter={AdapterDayjs}
|
|
130
135
|
>
|
|
131
136
|
<div className={styleContainer}>
|
|
132
137
|
<PickerDateWithLabel
|
|
@@ -18,8 +18,6 @@ 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;
|
|
23
21
|
rangeEndDate?: RangeDate;
|
|
24
22
|
rangeStartDate?: RangeDate;
|
|
25
23
|
}
|
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
4
|
+
import { useAtomValue } from 'jotai';
|
|
5
|
+
import { equals } from 'ramda';
|
|
4
6
|
|
|
5
|
-
import {
|
|
7
|
+
import { DateTimePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
|
8
|
+
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
9
|
+
|
|
10
|
+
import { userAtom } from '@centreon/ui-context';
|
|
6
11
|
|
|
7
12
|
import { CustomTimePeriodProperty } from './models';
|
|
8
13
|
|
|
14
|
+
interface ChangeDateProps {
|
|
15
|
+
date: Date;
|
|
16
|
+
property: CustomTimePeriodProperty | string;
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
interface Props {
|
|
10
|
-
changeDate: (props) => void;
|
|
20
|
+
changeDate: (props: ChangeDateProps) => void;
|
|
11
21
|
date: Date | null;
|
|
12
22
|
desktopMediaQuery?: string;
|
|
13
23
|
disabled?: boolean;
|
|
14
24
|
maxDate?: Date;
|
|
15
25
|
minDate?: Date;
|
|
16
|
-
property: CustomTimePeriodProperty;
|
|
26
|
+
property: CustomTimePeriodProperty | string;
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
const DateTimePickerInput = ({
|
|
@@ -25,24 +35,42 @@ const DateTimePickerInput = ({
|
|
|
25
35
|
disabled = false,
|
|
26
36
|
desktopMediaQuery
|
|
27
37
|
}: Props): JSX.Element => {
|
|
28
|
-
const
|
|
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');
|
|
29
44
|
|
|
30
45
|
const changeTime = (newValue: dayjs.Dayjs | null): void => {
|
|
31
46
|
changeDate({ date: dayjs(newValue).toDate(), property });
|
|
32
47
|
};
|
|
33
48
|
|
|
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
|
+
|
|
34
56
|
return (
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
<LocalizationProvider
|
|
58
|
+
adapterLocale={locale.substring(0, 2)}
|
|
59
|
+
dateAdapter={AdapterDayjs}
|
|
60
|
+
dateLibInstance={dayjs}
|
|
61
|
+
>
|
|
62
|
+
<DateTimePicker<dayjs.Dayjs>
|
|
63
|
+
dayOfWeekFormatter={(dayOfWeek) =>
|
|
64
|
+
dayOfWeek.substring(0, 2).toLocaleUpperCase()
|
|
65
|
+
}
|
|
66
|
+
desktopModeMediaQuery={desktopMediaQuery ?? desktopPickerMediaQuery}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
maxDate={maxDate && formatDate(maxDate)}
|
|
69
|
+
minDate={minDate && formatDate(minDate)}
|
|
70
|
+
value={formatDate(date)}
|
|
71
|
+
onChange={changeTime}
|
|
72
|
+
/>
|
|
73
|
+
</LocalizationProvider>
|
|
46
74
|
);
|
|
47
75
|
};
|
|
48
76
|
|