@centreon/ui 24.4.77 → 24.4.79
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 +2 -2
- package/src/Dashboard/Dashboard.styles.ts +3 -0
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +2 -0
- package/src/Form/Inputs/models.ts +5 -0
- package/src/Graph/BarStack/Graph.tsx +9 -10
- package/src/Graph/BarStack/GraphAndLegend.tsx +9 -10
- package/src/Graph/Tree/Tree.cypress.spec.tsx +4 -2
- package/src/InputField/Number/Number.tsx +4 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +4 -2
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +2 -1
- package/src/Listing/Cell/index.tsx +2 -1
- package/src/Snackbar/Transition.tsx +1 -2
- package/src/api/useFetchQuery/index.ts +28 -31
- package/src/api/useMutationQuery/index.ts +5 -7
- package/src/api/useRequest/index.ts +4 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.4.
|
|
3
|
+
"version": "24.4.79",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update:deps": "pnpx npm-check-updates -i --format group",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"ulog": "^2.0.0-beta.19"
|
|
145
145
|
},
|
|
146
146
|
"peerDependencies": {
|
|
147
|
-
"@centreon/ui-context": "
|
|
147
|
+
"@centreon/ui-context": "workspace:*",
|
|
148
148
|
"@dnd-kit/core": "6.x",
|
|
149
149
|
"@dnd-kit/sortable": "6.x",
|
|
150
150
|
"@dnd-kit/utilities": "3.x",
|
|
@@ -22,6 +22,9 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
22
22
|
'& .react-grid-item.resizing': {
|
|
23
23
|
boxShadow: theme.shadows[3]
|
|
24
24
|
},
|
|
25
|
+
'& .react-grid-layout': {
|
|
26
|
+
position: 'relative'
|
|
27
|
+
},
|
|
25
28
|
'& .react-resizable-handle': {
|
|
26
29
|
backgroundColor: theme.palette.action.focus,
|
|
27
30
|
backgroundImage: 'none',
|
|
@@ -112,11 +112,13 @@ const ConnectedAutocomplete = ({
|
|
|
112
112
|
error={error}
|
|
113
113
|
field={filterKey}
|
|
114
114
|
getEndpoint={getEndpoint}
|
|
115
|
+
getOptionLabel={connectedAutocomplete?.getOptionLabel}
|
|
115
116
|
getRenderedOptionText={connectedAutocomplete?.getRenderedOptionText}
|
|
116
117
|
initialPage={1}
|
|
117
118
|
isOptionEqualToValue={isOptionEqualToValue}
|
|
118
119
|
label={t(label)}
|
|
119
120
|
name={fieldName}
|
|
121
|
+
optionProperty={connectedAutocomplete?.optionProperty}
|
|
120
122
|
required={isRequired}
|
|
121
123
|
value={value ?? null}
|
|
122
124
|
onBlur={blur}
|
|
@@ -46,9 +46,14 @@ export interface InputProps {
|
|
|
46
46
|
};
|
|
47
47
|
connectedAutocomplete?: {
|
|
48
48
|
additionalConditionParameters: Array<ConditionsSearchParameter>;
|
|
49
|
+
decoder?;
|
|
50
|
+
disableSelectAll?: boolean;
|
|
49
51
|
endpoint?: string;
|
|
50
52
|
filterKey?: string;
|
|
53
|
+
getOptionLabel?: (option) => string;
|
|
51
54
|
getRenderedOptionText?: (option) => string | JSX.Element;
|
|
55
|
+
limitTags?: number;
|
|
56
|
+
optionProperty?: string;
|
|
52
57
|
};
|
|
53
58
|
custom?: {
|
|
54
59
|
Component: React.ComponentType<InputPropsWithoutGroup>;
|
|
@@ -15,16 +15,15 @@ import { useGraphStyles } from './BarStack.styles';
|
|
|
15
15
|
import { BarStackProps } from './models';
|
|
16
16
|
import { useGraphAndLegend } from './useGraphAndLegend';
|
|
17
17
|
|
|
18
|
-
interface Props
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
> {
|
|
18
|
+
interface Props extends Pick<
|
|
19
|
+
BarStackProps,
|
|
20
|
+
| 'data'
|
|
21
|
+
| 'displayValues'
|
|
22
|
+
| 'onSingleBarClick'
|
|
23
|
+
| 'unit'
|
|
24
|
+
| 'TooltipContent'
|
|
25
|
+
| 'tooltipProps'
|
|
26
|
+
> {
|
|
28
27
|
colorScale;
|
|
29
28
|
height: number;
|
|
30
29
|
isVerticalBar: boolean;
|
|
@@ -7,16 +7,15 @@ import Graph from './Graph';
|
|
|
7
7
|
import { gap, legendMaxHeight, legendMaxWidth } from './constants';
|
|
8
8
|
import { BarStackProps } from './models';
|
|
9
9
|
|
|
10
|
-
interface Props
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> {
|
|
10
|
+
interface Props extends Pick<
|
|
11
|
+
BarStackProps,
|
|
12
|
+
| 'data'
|
|
13
|
+
| 'displayValues'
|
|
14
|
+
| 'onSingleBarClick'
|
|
15
|
+
| 'unit'
|
|
16
|
+
| 'TooltipContent'
|
|
17
|
+
| 'tooltipProps'
|
|
18
|
+
> {
|
|
20
19
|
colorScale;
|
|
21
20
|
displayLegend: boolean;
|
|
22
21
|
height: number;
|
|
@@ -23,8 +23,10 @@ const validateTree = (tree): void => {
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
interface InitializeProps
|
|
27
|
-
|
|
26
|
+
interface InitializeProps extends Pick<
|
|
27
|
+
TreeProps<SimpleData | ComplexData>,
|
|
28
|
+
'treeLink' | 'children'
|
|
29
|
+
> {
|
|
28
30
|
data?: Node<SimpleData | ComplexData>;
|
|
29
31
|
isDefaultExpanded?: (data: SimpleData | ComplexData) => boolean;
|
|
30
32
|
}
|
|
@@ -4,8 +4,10 @@ import { T, always, cond, isEmpty, isNil } from 'ramda';
|
|
|
4
4
|
|
|
5
5
|
import TextField, { TextProps } from '../Text';
|
|
6
6
|
|
|
7
|
-
export interface NumberProps
|
|
8
|
-
|
|
7
|
+
export interface NumberProps extends Omit<
|
|
8
|
+
TextProps,
|
|
9
|
+
'defaultValue' | 'onChange'
|
|
10
|
+
> {
|
|
9
11
|
/**
|
|
10
12
|
* The initial value which will be used by the input for the first render
|
|
11
13
|
*/
|
|
@@ -57,7 +57,7 @@ const ConnectedAutocompleteField = (
|
|
|
57
57
|
open,
|
|
58
58
|
exclusionOptionProperty = 'id',
|
|
59
59
|
searchConditions = [],
|
|
60
|
-
getRenderedOptionText = (option): string => option
|
|
60
|
+
getRenderedOptionText = (option): string => option?.name?.toString(),
|
|
61
61
|
getRequestHeaders,
|
|
62
62
|
displayOptionThumbnail,
|
|
63
63
|
queryKey,
|
|
@@ -8,8 +8,10 @@ import { Chip, Typography, useTheme } from '@mui/material';
|
|
|
8
8
|
|
|
9
9
|
import { DraggableSelectEntry, SortableListProps } from './SortableList';
|
|
10
10
|
|
|
11
|
-
interface ContentProps
|
|
12
|
-
|
|
11
|
+
interface ContentProps extends Pick<
|
|
12
|
+
DraggableSelectEntry,
|
|
13
|
+
'name' | 'createOption' | 'id'
|
|
14
|
+
> {
|
|
13
15
|
attributes;
|
|
14
16
|
id: string;
|
|
15
17
|
index: number;
|
|
@@ -23,7 +23,8 @@ type DisableClearable = boolean;
|
|
|
23
23
|
type FreeSolo = boolean;
|
|
24
24
|
|
|
25
25
|
export interface Props
|
|
26
|
-
extends
|
|
26
|
+
extends
|
|
27
|
+
Omit<AutocompleteProps, 'renderTags' | 'renderOption' | 'multiple'>,
|
|
27
28
|
Omit<
|
|
28
29
|
UseAutocompleteProps<SelectEntry, Multiple, DisableClearable, FreeSolo>,
|
|
29
30
|
'multiple'
|
|
@@ -22,8 +22,7 @@ type TransitionKeys =
|
|
|
22
22
|
| 'addEndListener'
|
|
23
23
|
| TransitionHandlerKeys;
|
|
24
24
|
interface TransitionProps
|
|
25
|
-
extends TransitionActions,
|
|
26
|
-
Partial<Pick<_TransitionProps, TransitionKeys>> {
|
|
25
|
+
extends TransitionActions, Partial<Pick<_TransitionProps, TransitionKeys>> {
|
|
27
26
|
style?: React.CSSProperties;
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import 'ulog';
|
|
4
1
|
import {
|
|
5
2
|
QueryKey,
|
|
6
3
|
QueryObserverBaseResult,
|
|
4
|
+
UseQueryOptions,
|
|
7
5
|
useQuery,
|
|
8
6
|
useQueryClient,
|
|
9
|
-
|
|
10
|
-
} from
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import { has, includes, isNil, not, omit } from 'ramda';
|
|
7
|
+
} from "@tanstack/react-query";
|
|
8
|
+
import { has, includes, isNil, not, omit } from "ramda";
|
|
9
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
10
|
+
import { JsonDecoder } from "ts.data.json";
|
|
14
11
|
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
12
|
+
import useSnackbar from "../../Snackbar/useSnackbar";
|
|
13
|
+
import { useDeepCompare } from "../../utils";
|
|
14
|
+
import { CatchErrorProps, customFetch, ResponseError } from "../customFetch";
|
|
18
15
|
|
|
19
16
|
export interface UseFetchQueryProps<T> {
|
|
20
17
|
baseEndpoint?: string;
|
|
@@ -31,24 +28,24 @@ export interface UseFetchQueryProps<T> {
|
|
|
31
28
|
suspense?: boolean;
|
|
32
29
|
} & Omit<
|
|
33
30
|
UseQueryOptions<T | ResponseError, Error, T | ResponseError, QueryKey>,
|
|
34
|
-
|
|
31
|
+
"queryKey" | "queryFn"
|
|
35
32
|
>;
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
export type UseFetchQueryState<T> = {
|
|
39
36
|
data?: T;
|
|
40
|
-
error: Omit<ResponseError,
|
|
37
|
+
error: Omit<ResponseError, "isError"> | null;
|
|
41
38
|
fetchQuery: () => Promise<T | ResponseError>;
|
|
42
39
|
prefetchNextPage: ({ page, getPrefetchQueryKey }) => void;
|
|
43
40
|
prefetchPreviousPage: ({ page, getPrefetchQueryKey }) => void;
|
|
44
41
|
prefetchQuery: ({ endpointParams, queryKey }) => void;
|
|
45
|
-
} & Omit<QueryObserverBaseResult,
|
|
42
|
+
} & Omit<QueryObserverBaseResult, "data" | "error">;
|
|
46
43
|
|
|
47
44
|
export interface PrefetchEndpointParams {
|
|
48
45
|
page: number;
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
const log =
|
|
48
|
+
const log = console;
|
|
52
49
|
|
|
53
50
|
const useFetchQuery = <T extends object>({
|
|
54
51
|
getEndpoint,
|
|
@@ -61,7 +58,7 @@ const useFetchQuery = <T extends object>({
|
|
|
61
58
|
queryOptions,
|
|
62
59
|
httpCodesBypassErrorSnackbar = [],
|
|
63
60
|
baseEndpoint,
|
|
64
|
-
doNotCancelCallsOnUnmount = false
|
|
61
|
+
doNotCancelCallsOnUnmount = false,
|
|
65
62
|
}: UseFetchQueryProps<T>): UseFetchQueryState<T> => {
|
|
66
63
|
const dataRef = useRef<T | undefined>(undefined);
|
|
67
64
|
|
|
@@ -76,10 +73,10 @@ const useFetchQuery = <T extends object>({
|
|
|
76
73
|
defaultFailureMessage,
|
|
77
74
|
endpoint: getEndpoint(),
|
|
78
75
|
headers: new Headers(fetchHeaders),
|
|
79
|
-
signal
|
|
76
|
+
signal,
|
|
80
77
|
}),
|
|
81
78
|
queryKey: getQueryKey(),
|
|
82
|
-
...queryOptions
|
|
79
|
+
...queryOptions,
|
|
83
80
|
});
|
|
84
81
|
|
|
85
82
|
const queryClient = useQueryClient();
|
|
@@ -90,7 +87,7 @@ const useFetchQuery = <T extends object>({
|
|
|
90
87
|
log.error(data.message);
|
|
91
88
|
const hasACorrespondingHttpCode = includes(
|
|
92
89
|
data?.statusCode || 0,
|
|
93
|
-
httpCodesBypassErrorSnackbar
|
|
90
|
+
httpCodesBypassErrorSnackbar,
|
|
94
91
|
);
|
|
95
92
|
|
|
96
93
|
if (!hasACorrespondingHttpCode) {
|
|
@@ -109,9 +106,9 @@ const useFetchQuery = <T extends object>({
|
|
|
109
106
|
defaultFailureMessage,
|
|
110
107
|
endpoint: getEndpoint(endpointParams),
|
|
111
108
|
headers: new Headers(fetchHeaders),
|
|
112
|
-
signal
|
|
109
|
+
signal,
|
|
113
110
|
}),
|
|
114
|
-
queryKey
|
|
111
|
+
queryKey,
|
|
115
112
|
});
|
|
116
113
|
};
|
|
117
114
|
|
|
@@ -124,7 +121,7 @@ const useFetchQuery = <T extends object>({
|
|
|
124
121
|
|
|
125
122
|
return prefetchQuery({
|
|
126
123
|
endpointParams: { page: nextPage },
|
|
127
|
-
queryKey: getPrefetchQueryKey(nextPage)
|
|
124
|
+
queryKey: getPrefetchQueryKey(nextPage),
|
|
128
125
|
});
|
|
129
126
|
};
|
|
130
127
|
|
|
@@ -137,7 +134,7 @@ const useFetchQuery = <T extends object>({
|
|
|
137
134
|
|
|
138
135
|
return prefetchQuery({
|
|
139
136
|
endpointParams: { page: previousPage },
|
|
140
|
-
queryKey: getPrefetchQueryKey(previousPage)
|
|
137
|
+
queryKey: getPrefetchQueryKey(previousPage),
|
|
141
138
|
});
|
|
142
139
|
};
|
|
143
140
|
|
|
@@ -151,16 +148,16 @@ const useFetchQuery = <T extends object>({
|
|
|
151
148
|
defaultFailureMessage,
|
|
152
149
|
endpoint: getEndpoint(),
|
|
153
150
|
headers: new Headers(fetchHeaders),
|
|
154
|
-
signal
|
|
151
|
+
signal,
|
|
155
152
|
}),
|
|
156
|
-
queryKey: getQueryKey()
|
|
153
|
+
queryKey: getQueryKey(),
|
|
157
154
|
});
|
|
158
155
|
};
|
|
159
156
|
|
|
160
157
|
const data = useMemo(
|
|
161
158
|
() =>
|
|
162
|
-
not(has(
|
|
163
|
-
[queryData.data]
|
|
159
|
+
not(has("isError", queryData.data)) ? (queryData.data as T) : undefined,
|
|
160
|
+
[queryData.data],
|
|
164
161
|
);
|
|
165
162
|
|
|
166
163
|
if (!isNil(data)) {
|
|
@@ -183,17 +180,17 @@ const useFetchQuery = <T extends object>({
|
|
|
183
180
|
() => {
|
|
184
181
|
manageError();
|
|
185
182
|
},
|
|
186
|
-
useDeepCompare([queryData.data])
|
|
183
|
+
useDeepCompare([queryData.data]),
|
|
187
184
|
);
|
|
188
185
|
|
|
189
186
|
return {
|
|
190
|
-
...omit([
|
|
187
|
+
...omit(["data", "error"], queryData),
|
|
191
188
|
data: dataRef.current,
|
|
192
|
-
error: errorData?.isError ? omit([
|
|
189
|
+
error: errorData?.isError ? omit(["isError"], errorData) : null,
|
|
193
190
|
fetchQuery,
|
|
194
191
|
prefetchNextPage,
|
|
195
192
|
prefetchPreviousPage,
|
|
196
|
-
prefetchQuery
|
|
193
|
+
prefetchQuery,
|
|
197
194
|
};
|
|
198
195
|
};
|
|
199
196
|
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import 'ulog';
|
|
2
1
|
import { useEffect } from 'react';
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
|
-
useMutation,
|
|
6
4
|
UseMutationOptions,
|
|
7
|
-
UseMutationResult
|
|
5
|
+
UseMutationResult,
|
|
6
|
+
useMutation
|
|
8
7
|
} from '@tanstack/react-query';
|
|
9
|
-
import { JsonDecoder } from 'ts.data.json';
|
|
10
|
-
import anylogger from 'anylogger';
|
|
11
8
|
import { includes, omit } from 'ramda';
|
|
9
|
+
import { JsonDecoder } from 'ts.data.json';
|
|
12
10
|
|
|
13
|
-
import { CatchErrorProps, customFetch, ResponseError } from '../customFetch';
|
|
14
11
|
import useSnackbar from '../../Snackbar/useSnackbar';
|
|
15
12
|
import { useDeepCompare } from '../../utils';
|
|
13
|
+
import { CatchErrorProps, customFetch, ResponseError } from '../customFetch';
|
|
16
14
|
|
|
17
15
|
export enum Method {
|
|
18
16
|
DELETE = 'DELETE',
|
|
@@ -52,7 +50,7 @@ export type UseMutationQueryProps<T, TMeta> = {
|
|
|
52
50
|
'mutationFn' | 'onError' | 'onMutate' | 'onSuccess' | 'mutateAsync' | 'mutate'
|
|
53
51
|
>;
|
|
54
52
|
|
|
55
|
-
const log =
|
|
53
|
+
const log = console;
|
|
56
54
|
|
|
57
55
|
export type UseMutationQueryState<T, TMeta> = Omit<
|
|
58
56
|
UseMutationResult<T | ResponseError>,
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import 'ulog';
|
|
4
3
|
import axios from 'axios';
|
|
5
|
-
import {
|
|
6
|
-
import anylogger from 'anylogger';
|
|
4
|
+
import { defaultTo, includes, or, path, pathOr } from 'ramda';
|
|
7
5
|
import { JsonDecoder } from 'ts.data.json';
|
|
8
6
|
|
|
9
|
-
import useCancelTokenSource from '../useCancelTokenSource';
|
|
10
7
|
import useSnackbar from '../../Snackbar/useSnackbar';
|
|
8
|
+
import useCancelTokenSource from '../useCancelTokenSource';
|
|
11
9
|
|
|
12
|
-
const log =
|
|
10
|
+
const log = console;
|
|
13
11
|
|
|
14
12
|
export interface RequestParams<TResult> {
|
|
15
13
|
decoder?: JsonDecoder.Decoder<TResult>;
|