@centreon/ui 24.4.1-MON-24518-status-grid.15 → 24.4.1-MON-fix-same-version.0
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/Graph/HeatMap/HeatMap.styles.tsx +0 -1
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +8 -12
- package/src/Graph/HeatMap/model.ts +0 -1
- package/src/Graph/LineChart/index.stories.tsx +3 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +0 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +0 -1
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +0 -3
- package/src/InputField/Text/index.tsx +1 -6
- package/src/ThemeProvider/palettes.ts +4 -4
- package/src/TimePeriods/index.stories.tsx +12 -4
- package/src/api/buildListingEndpoint/models.ts +1 -2
- package/src/api/customFetch.ts +3 -12
- package/src/api/useFetchQuery/index.ts +4 -15
- package/src/api/useMutationQuery/index.ts +1 -4
- package/src/utils/useInfiniteScrollListing.ts +7 -22
- package/src/utils/useLocaleDateTimeFormat/index.ts +0 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { scaleLinear } from '@visx/scale';
|
|
4
|
-
import {
|
|
4
|
+
import { equals, gt, lt } from 'ramda';
|
|
5
5
|
|
|
6
6
|
import { Box } from '@mui/material';
|
|
7
7
|
|
|
@@ -20,8 +20,7 @@ const ResponsiveHeatMap = <TData,>({
|
|
|
20
20
|
tiles,
|
|
21
21
|
arrowClassName,
|
|
22
22
|
tooltipContent,
|
|
23
|
-
tileSizeFixed
|
|
24
|
-
displayTooltipCondition = T
|
|
23
|
+
tileSizeFixed
|
|
25
24
|
}: HeatMapProps<TData> & { width: number }): JSX.Element | null => {
|
|
26
25
|
const { classes, cx } = useHeatMapStyles();
|
|
27
26
|
|
|
@@ -74,15 +73,12 @@ const ResponsiveHeatMap = <TData,>({
|
|
|
74
73
|
tooltip: classes.heatMapTooltip
|
|
75
74
|
}}
|
|
76
75
|
followCursor={false}
|
|
77
|
-
label={
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
isSmallestSize
|
|
84
|
-
})
|
|
85
|
-
}
|
|
76
|
+
label={tooltipContent?.({
|
|
77
|
+
backgroundColor,
|
|
78
|
+
data,
|
|
79
|
+
id,
|
|
80
|
+
isSmallestSize
|
|
81
|
+
})}
|
|
86
82
|
position="right-start"
|
|
87
83
|
>
|
|
88
84
|
<div className={classes.heatMapTileContent}>
|
|
@@ -21,7 +21,6 @@ export interface HeatMapProps<TData> {
|
|
|
21
21
|
data,
|
|
22
22
|
isSmallestSize
|
|
23
23
|
}: ChildrenProps<TData>) => ReactElement | boolean | null;
|
|
24
|
-
displayTooltipCondition?: (data: TData) => boolean;
|
|
25
24
|
tileSizeFixed?: boolean;
|
|
26
25
|
tiles: Array<Tile<TData>>;
|
|
27
26
|
tooltipContent?: ({
|
|
@@ -32,7 +32,6 @@ import useFetchQuery from '../../../../api/useFetchQuery';
|
|
|
32
32
|
|
|
33
33
|
export interface ConnectedAutoCompleteFieldProps<TData> {
|
|
34
34
|
allowUniqOption?: boolean;
|
|
35
|
-
baseEndpoint?: string;
|
|
36
35
|
conditionField?: keyof SelectEntry;
|
|
37
36
|
field: string;
|
|
38
37
|
getEndpoint: ({ search, page }) => string;
|
|
@@ -61,7 +60,6 @@ const ConnectedAutocompleteField = (
|
|
|
61
60
|
displayOptionThumbnail,
|
|
62
61
|
queryKey,
|
|
63
62
|
allowUniqOption,
|
|
64
|
-
baseEndpoint,
|
|
65
63
|
...props
|
|
66
64
|
}: ConnectedAutoCompleteFieldProps<TData> &
|
|
67
65
|
Omit<AutocompleteFieldProps, 'options'>): JSX.Element => {
|
|
@@ -89,7 +87,6 @@ const ConnectedAutocompleteField = (
|
|
|
89
87
|
const { fetchQuery, isFetching, prefetchNextPage } = useFetchQuery<
|
|
90
88
|
ListingModel<TData>
|
|
91
89
|
>({
|
|
92
|
-
baseEndpoint,
|
|
93
90
|
fetchHeaders: getRequestHeaders,
|
|
94
91
|
getEndpoint: (params) => {
|
|
95
92
|
return getEndpoint({
|
|
@@ -80,7 +80,6 @@ export type Props = {
|
|
|
80
80
|
autoSizeCustomPadding?: number;
|
|
81
81
|
autoSizeDefaultWidth?: number;
|
|
82
82
|
className?: string;
|
|
83
|
-
containerClassName?: string;
|
|
84
83
|
dataTestId: string;
|
|
85
84
|
debounced?: boolean;
|
|
86
85
|
displayErrorInTooltip?: boolean;
|
|
@@ -113,7 +112,6 @@ const TextField = forwardRef(
|
|
|
113
112
|
autoSizeCustomPadding,
|
|
114
113
|
defaultValue,
|
|
115
114
|
required = false,
|
|
116
|
-
containerClassName,
|
|
117
115
|
...rest
|
|
118
116
|
}: Props,
|
|
119
117
|
ref: React.ForwardedRef<HTMLDivElement>
|
|
@@ -144,10 +142,7 @@ const TextField = forwardRef(
|
|
|
144
142
|
}, [innerValue, debounced, defaultValue]);
|
|
145
143
|
|
|
146
144
|
return (
|
|
147
|
-
<Box
|
|
148
|
-
className={containerClassName}
|
|
149
|
-
sx={{ width: autoSize ? 'auto' : '100%' }}
|
|
150
|
-
>
|
|
145
|
+
<Box sx={{ width: autoSize ? 'auto' : '100%' }}>
|
|
151
146
|
<Tooltip placement="top" title={tooltipTitle}>
|
|
152
147
|
<MuiTextField
|
|
153
148
|
data-testid={dataTestId}
|
|
@@ -143,7 +143,7 @@ declare module '@mui/material/Badge' {
|
|
|
143
143
|
export const lightPalette: PaletteOptions = {
|
|
144
144
|
action: {
|
|
145
145
|
acknowledged: '#67532C',
|
|
146
|
-
acknowledgedBackground: '#
|
|
146
|
+
acknowledgedBackground: '#F5F1E9',
|
|
147
147
|
activatedOpacity: 0.12,
|
|
148
148
|
active: '#666666',
|
|
149
149
|
disabled: '#999999',
|
|
@@ -153,7 +153,7 @@ export const lightPalette: PaletteOptions = {
|
|
|
153
153
|
hover: 'rgba(0, 0, 0, 0.06)',
|
|
154
154
|
hoverOpacity: 0.06,
|
|
155
155
|
inDowntime: '#4B2352',
|
|
156
|
-
inDowntimeBackground: '#
|
|
156
|
+
inDowntimeBackground: '#F0E9F8',
|
|
157
157
|
selected: 'rgba(102, 102, 102, 0.3)',
|
|
158
158
|
selectedOpacity: 0.3
|
|
159
159
|
},
|
|
@@ -283,7 +283,7 @@ export const lightPalette: PaletteOptions = {
|
|
|
283
283
|
export const darkPalette: PaletteOptions = {
|
|
284
284
|
action: {
|
|
285
285
|
acknowledged: '#67532C',
|
|
286
|
-
acknowledgedBackground: '#
|
|
286
|
+
acknowledgedBackground: '#67532C',
|
|
287
287
|
activatedOpacity: 0.3,
|
|
288
288
|
active: '#B5B5B5',
|
|
289
289
|
disabled: '#999999',
|
|
@@ -293,7 +293,7 @@ export const darkPalette: PaletteOptions = {
|
|
|
293
293
|
hover: 'rgba(255, 255, 255, 0.16)',
|
|
294
294
|
hoverOpacity: 0.16,
|
|
295
295
|
inDowntime: '#4B2352',
|
|
296
|
-
inDowntimeBackground: '#
|
|
296
|
+
inDowntimeBackground: '#4B2352',
|
|
297
297
|
selected: 'rgba(255, 255, 255, 0.5)',
|
|
298
298
|
selectedOpacity: 0.5
|
|
299
299
|
},
|
|
@@ -88,20 +88,27 @@ const args = {
|
|
|
88
88
|
]
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
+
const parameters = {
|
|
92
|
+
chromatic: { diffThreshold: 0.1 }
|
|
93
|
+
};
|
|
94
|
+
|
|
91
95
|
export const BasicTimePeriod: Story = {
|
|
92
96
|
...Template,
|
|
93
|
-
argTypes
|
|
97
|
+
argTypes,
|
|
98
|
+
parameters
|
|
94
99
|
};
|
|
95
100
|
|
|
96
101
|
export const WithExtraTimePeriods: Story = {
|
|
97
102
|
...Template,
|
|
98
103
|
argTypes,
|
|
99
|
-
args
|
|
104
|
+
args,
|
|
105
|
+
parameters
|
|
100
106
|
};
|
|
101
107
|
|
|
102
108
|
export const WithExternalComponent: Story = {
|
|
103
109
|
...TemplateWithExternalComponent,
|
|
104
|
-
argTypes
|
|
110
|
+
argTypes,
|
|
111
|
+
parameters
|
|
105
112
|
};
|
|
106
113
|
|
|
107
114
|
export const SimpleTimePeriod: StorySimpleTimePeriod = {
|
|
@@ -109,5 +116,6 @@ export const SimpleTimePeriod: StorySimpleTimePeriod = {
|
|
|
109
116
|
args: {
|
|
110
117
|
endDate: dayjs(Date.now()).toDate(),
|
|
111
118
|
startDate: dayjs(Date.now()).subtract(29, 'day').toDate()
|
|
112
|
-
}
|
|
119
|
+
},
|
|
120
|
+
parameters
|
|
113
121
|
};
|
package/src/api/customFetch.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { equals
|
|
1
|
+
import { equals } from 'ramda';
|
|
2
2
|
import { JsonDecoder } from 'ts.data.json';
|
|
3
3
|
|
|
4
4
|
import { Method } from './useMutationQuery';
|
|
@@ -22,7 +22,6 @@ export interface CatchErrorProps {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
interface CustomFetchProps<T> {
|
|
25
|
-
baseEndpoint?: string;
|
|
26
25
|
catchError?: (props: CatchErrorProps) => void;
|
|
27
26
|
decoder?: JsonDecoder.Decoder<T>;
|
|
28
27
|
defaultFailureMessage?: string;
|
|
@@ -43,18 +42,10 @@ export const customFetch = <T>({
|
|
|
43
42
|
defaultFailureMessage = 'Something went wrong',
|
|
44
43
|
isMutation = false,
|
|
45
44
|
payload,
|
|
46
|
-
method = 'GET'
|
|
47
|
-
baseEndpoint = './api/latest'
|
|
45
|
+
method = 'GET'
|
|
48
46
|
}: CustomFetchProps<T>): Promise<T | ResponseError> => {
|
|
49
47
|
const defaultOptions = { headers, method, signal };
|
|
50
48
|
|
|
51
|
-
const formattedEndpoint =
|
|
52
|
-
!isNil(baseEndpoint) &&
|
|
53
|
-
!startsWith(baseEndpoint, endpoint) &&
|
|
54
|
-
!startsWith('./api/internal.php', endpoint)
|
|
55
|
-
? `${baseEndpoint}${endpoint}`
|
|
56
|
-
: endpoint;
|
|
57
|
-
|
|
58
49
|
const options = isMutation
|
|
59
50
|
? {
|
|
60
51
|
...defaultOptions,
|
|
@@ -62,7 +53,7 @@ export const customFetch = <T>({
|
|
|
62
53
|
}
|
|
63
54
|
: defaultOptions;
|
|
64
55
|
|
|
65
|
-
return fetch(
|
|
56
|
+
return fetch(endpoint, options)
|
|
66
57
|
.then((response) => {
|
|
67
58
|
if (equals(response.status, 204)) {
|
|
68
59
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useMemo
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import 'ulog';
|
|
4
4
|
import {
|
|
@@ -10,14 +10,13 @@ import {
|
|
|
10
10
|
} from '@tanstack/react-query';
|
|
11
11
|
import { JsonDecoder } from 'ts.data.json';
|
|
12
12
|
import anylogger from 'anylogger';
|
|
13
|
-
import { has, includes,
|
|
13
|
+
import { has, includes, not, omit } from 'ramda';
|
|
14
14
|
|
|
15
15
|
import { CatchErrorProps, customFetch, ResponseError } from '../customFetch';
|
|
16
16
|
import useSnackbar from '../../Snackbar/useSnackbar';
|
|
17
17
|
import { useDeepCompare } from '../../utils';
|
|
18
18
|
|
|
19
19
|
export interface UseFetchQueryProps<T> {
|
|
20
|
-
baseEndpoint?: string;
|
|
21
20
|
catchError?: (props: CatchErrorProps) => void;
|
|
22
21
|
decoder?: JsonDecoder.Decoder<T>;
|
|
23
22
|
defaultFailureMessage?: string;
|
|
@@ -58,17 +57,13 @@ const useFetchQuery = <T extends object>({
|
|
|
58
57
|
fetchHeaders,
|
|
59
58
|
isPaginated,
|
|
60
59
|
queryOptions,
|
|
61
|
-
httpCodesBypassErrorSnackbar = []
|
|
62
|
-
baseEndpoint
|
|
60
|
+
httpCodesBypassErrorSnackbar = []
|
|
63
61
|
}: UseFetchQueryProps<T>): UseFetchQueryState<T> => {
|
|
64
|
-
const dataRef = useRef<T | undefined>(undefined);
|
|
65
|
-
|
|
66
62
|
const { showErrorMessage } = useSnackbar();
|
|
67
63
|
|
|
68
64
|
const queryData = useQuery<T | ResponseError, Error>({
|
|
69
65
|
queryFn: ({ signal }): Promise<T | ResponseError> =>
|
|
70
66
|
customFetch<T>({
|
|
71
|
-
baseEndpoint,
|
|
72
67
|
catchError,
|
|
73
68
|
decoder,
|
|
74
69
|
defaultFailureMessage,
|
|
@@ -101,7 +96,6 @@ const useFetchQuery = <T extends object>({
|
|
|
101
96
|
queryClient.prefetchQuery({
|
|
102
97
|
queryFn: ({ signal }): Promise<T | ResponseError> =>
|
|
103
98
|
customFetch<T>({
|
|
104
|
-
baseEndpoint,
|
|
105
99
|
catchError,
|
|
106
100
|
decoder,
|
|
107
101
|
defaultFailureMessage,
|
|
@@ -143,7 +137,6 @@ const useFetchQuery = <T extends object>({
|
|
|
143
137
|
return queryClient.fetchQuery({
|
|
144
138
|
queryFn: ({ signal }): Promise<T | ResponseError> =>
|
|
145
139
|
customFetch<T>({
|
|
146
|
-
baseEndpoint,
|
|
147
140
|
catchError,
|
|
148
141
|
decoder,
|
|
149
142
|
defaultFailureMessage,
|
|
@@ -161,10 +154,6 @@ const useFetchQuery = <T extends object>({
|
|
|
161
154
|
[queryData.data]
|
|
162
155
|
);
|
|
163
156
|
|
|
164
|
-
if (!isNil(data)) {
|
|
165
|
-
dataRef.current = data;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
157
|
const errorData = queryData.data as ResponseError | undefined;
|
|
169
158
|
|
|
170
159
|
useEffect(() => {
|
|
@@ -182,7 +171,7 @@ const useFetchQuery = <T extends object>({
|
|
|
182
171
|
|
|
183
172
|
return {
|
|
184
173
|
...omit(['data', 'error'], queryData),
|
|
185
|
-
data
|
|
174
|
+
data,
|
|
186
175
|
error: errorData?.isError ? omit(['isError'], errorData) : null,
|
|
187
176
|
fetchQuery,
|
|
188
177
|
prefetchNextPage,
|
|
@@ -23,7 +23,6 @@ export enum Method {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export type UseMutationQueryProps<T, TMeta> = {
|
|
26
|
-
baseEndpoint?: string;
|
|
27
26
|
catchError?: (props: CatchErrorProps) => void;
|
|
28
27
|
decoder?: JsonDecoder.Decoder<T>;
|
|
29
28
|
defaultFailureMessage?: string;
|
|
@@ -69,8 +68,7 @@ const useMutationQuery = <T extends object, TMeta>({
|
|
|
69
68
|
method,
|
|
70
69
|
onMutate,
|
|
71
70
|
onError,
|
|
72
|
-
onSuccess
|
|
73
|
-
baseEndpoint
|
|
71
|
+
onSuccess
|
|
74
72
|
}: UseMutationQueryProps<T, TMeta>): UseMutationQueryState<T> => {
|
|
75
73
|
const { showErrorMessage } = useSnackbar();
|
|
76
74
|
|
|
@@ -85,7 +83,6 @@ const useMutationQuery = <T extends object, TMeta>({
|
|
|
85
83
|
const { _meta, ...payload } = _payload || {};
|
|
86
84
|
|
|
87
85
|
return customFetch<T>({
|
|
88
|
-
baseEndpoint,
|
|
89
86
|
catchError,
|
|
90
87
|
decoder,
|
|
91
88
|
defaultFailureMessage,
|
|
@@ -5,42 +5,33 @@ import { PrimitiveAtom, useAtom } from 'jotai';
|
|
|
5
5
|
import { JsonDecoder } from 'ts.data.json';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
QueryParameter,
|
|
9
8
|
buildListingEndpoint,
|
|
10
9
|
useFetchQuery,
|
|
11
10
|
useIntersectionObserver
|
|
12
11
|
} from '@centreon/ui';
|
|
13
12
|
|
|
14
13
|
import type { Listing } from '../api/models';
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
const limit = 100;
|
|
16
16
|
|
|
17
17
|
interface UseInfiniteScrollListing<T> {
|
|
18
18
|
elementRef: (node) => void;
|
|
19
19
|
elements: Array<T>;
|
|
20
20
|
isLoading: boolean;
|
|
21
|
-
total?: number;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
interface UseInfiniteScrollListingProps<T> {
|
|
25
|
-
|
|
26
|
-
decoder?: JsonDecoder.Decoder<Listing<T>>;
|
|
24
|
+
decoder: JsonDecoder.Decoder<Listing<T>>;
|
|
27
25
|
endpoint: string;
|
|
28
|
-
limit?: number;
|
|
29
26
|
pageAtom: PrimitiveAtom<number>;
|
|
30
|
-
parameters?: Parameters;
|
|
31
27
|
queryKeyName: string;
|
|
32
|
-
suspense?: boolean;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
export const useInfiniteScrollListing = <T>({
|
|
36
31
|
queryKeyName,
|
|
37
32
|
endpoint,
|
|
38
33
|
decoder,
|
|
39
|
-
pageAtom
|
|
40
|
-
suspense = true,
|
|
41
|
-
parameters,
|
|
42
|
-
customQueryParameters,
|
|
43
|
-
limit = 100
|
|
34
|
+
pageAtom
|
|
44
35
|
}: UseInfiniteScrollListingProps<T>): UseInfiniteScrollListing<T> => {
|
|
45
36
|
const [maxPage, setMaxPage] = useState(1);
|
|
46
37
|
|
|
@@ -55,15 +46,14 @@ export const useInfiniteScrollListing = <T>({
|
|
|
55
46
|
getEndpoint: (params) =>
|
|
56
47
|
buildListingEndpoint({
|
|
57
48
|
baseEndpoint: endpoint,
|
|
58
|
-
|
|
59
|
-
parameters: { limit, page: params?.page || page, ...parameters }
|
|
49
|
+
parameters: { limit, page: params?.page || page }
|
|
60
50
|
}),
|
|
61
51
|
getQueryKey: () => [queryKeyName, page],
|
|
62
52
|
isPaginated: true,
|
|
63
53
|
queryOptions: {
|
|
64
54
|
refetchOnMount: false,
|
|
65
55
|
refetchOnWindowFocus: false,
|
|
66
|
-
suspense:
|
|
56
|
+
suspense: equals(page, 1)
|
|
67
57
|
}
|
|
68
58
|
});
|
|
69
59
|
|
|
@@ -108,14 +98,9 @@ export const useInfiniteScrollListing = <T>({
|
|
|
108
98
|
});
|
|
109
99
|
}, [data]);
|
|
110
100
|
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
return () => setPage(1);
|
|
113
|
-
}, []);
|
|
114
|
-
|
|
115
101
|
return {
|
|
116
102
|
elementRef,
|
|
117
103
|
elements: elements.current || [],
|
|
118
|
-
isLoading
|
|
119
|
-
total: data?.meta.total
|
|
104
|
+
isLoading
|
|
120
105
|
};
|
|
121
106
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import humanizeDuration from 'humanize-duration';
|
|
3
3
|
import { useAtomValue } from 'jotai';
|
|
4
|
-
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
5
4
|
|
|
6
5
|
import { userAtom } from '@centreon/ui-context';
|
|
7
6
|
|
|
@@ -21,8 +20,6 @@ export interface LocaleDateTimeFormat {
|
|
|
21
20
|
toTime: (date: Date | string) => string;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
dayjs.extend(localizedFormat);
|
|
25
|
-
|
|
26
23
|
const dateFormat = 'L';
|
|
27
24
|
const timeFormat = 'LT';
|
|
28
25
|
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|