@centreon/ui 24.4.1-MON-24235-Filter-App-token.3 → 24.4.1-SAAS-1230.1
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/Dialog/Confirm/index.tsx +2 -10
- package/src/Dialog/index.tsx +1 -8
- package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
- package/src/Graph/LineChart/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +2 -4
- package/src/api/useMutationQuery/index.test.ts +4 -4
- package/src/api/useMutationQuery/index.ts +24 -13
- package/src/components/List/Item/ListItem.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DialogContentText, Typography } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
import Dialog, { Props as DialogProps } from '..';
|
|
4
4
|
|
|
@@ -6,23 +6,15 @@ type Props = DialogProps & {
|
|
|
6
6
|
children?: JSX.Element;
|
|
7
7
|
labelMessage?: string | null;
|
|
8
8
|
labelSecondMessage?: string | null;
|
|
9
|
-
restCancelButtonProps?: ButtonProps;
|
|
10
|
-
restConfirmButtonProps?: ButtonProps;
|
|
11
9
|
};
|
|
12
10
|
|
|
13
11
|
const Confirm = ({
|
|
14
12
|
labelMessage,
|
|
15
13
|
labelSecondMessage,
|
|
16
14
|
children,
|
|
17
|
-
restCancelButtonProps,
|
|
18
|
-
restConfirmButtonProps,
|
|
19
15
|
...rest
|
|
20
16
|
}: Props): JSX.Element => (
|
|
21
|
-
<Dialog
|
|
22
|
-
restCancelButtonProps={restCancelButtonProps}
|
|
23
|
-
restConfirmButtonProps={restConfirmButtonProps}
|
|
24
|
-
{...rest}
|
|
25
|
-
>
|
|
17
|
+
<Dialog {...rest}>
|
|
26
18
|
<DialogContentText>
|
|
27
19
|
{labelMessage && <Typography>{labelMessage}</Typography>}
|
|
28
20
|
{labelSecondMessage && <Typography>{labelSecondMessage}</Typography>}
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -9,8 +9,7 @@ import {
|
|
|
9
9
|
DialogContent,
|
|
10
10
|
DialogActions,
|
|
11
11
|
DialogProps,
|
|
12
|
-
CircularProgress
|
|
13
|
-
ButtonProps
|
|
12
|
+
CircularProgress
|
|
14
13
|
} from '@mui/material';
|
|
15
14
|
|
|
16
15
|
import { DataTestAttributes } from '../@types/data-attributes';
|
|
@@ -49,8 +48,6 @@ export type Props = {
|
|
|
49
48
|
onClose?: () => void;
|
|
50
49
|
onConfirm: (event, value?) => void;
|
|
51
50
|
open: boolean;
|
|
52
|
-
restCancelButtonProps?: ButtonProps;
|
|
53
|
-
restConfirmButtonProps?: ButtonProps;
|
|
54
51
|
submitting?: boolean;
|
|
55
52
|
} & DialogProps &
|
|
56
53
|
DataTestAttributes;
|
|
@@ -73,8 +70,6 @@ const Dialog = ({
|
|
|
73
70
|
dialogContentClassName,
|
|
74
71
|
dialogActionsClassName,
|
|
75
72
|
dialogConfirmButtonClassName,
|
|
76
|
-
restCancelButtonProps,
|
|
77
|
-
restConfirmButtonProps,
|
|
78
73
|
...rest
|
|
79
74
|
}: Props): JSX.Element => {
|
|
80
75
|
const { classes, cx } = useStyles({ contentWidth });
|
|
@@ -106,7 +101,6 @@ const Dialog = ({
|
|
|
106
101
|
data-testid="Cancel"
|
|
107
102
|
disabled={cancelDisabled}
|
|
108
103
|
onClick={onCancel}
|
|
109
|
-
{...restCancelButtonProps}
|
|
110
104
|
>
|
|
111
105
|
{labelCancel}
|
|
112
106
|
</Button>
|
|
@@ -119,7 +113,6 @@ const Dialog = ({
|
|
|
119
113
|
disabled={confirmDisabled}
|
|
120
114
|
endIcon={submitting && <CircularProgress size={15} />}
|
|
121
115
|
onClick={onConfirm}
|
|
122
|
-
{...restConfirmButtonProps}
|
|
123
116
|
>
|
|
124
117
|
{labelConfirm}
|
|
125
118
|
</Button>
|
|
@@ -8,7 +8,7 @@ interface MakeStylesProps {
|
|
|
8
8
|
|
|
9
9
|
export const legendWidth = 21;
|
|
10
10
|
const legendItemHeight = 5.25;
|
|
11
|
-
const legendItemHeightCompact =
|
|
11
|
+
const legendItemHeightCompact = 2;
|
|
12
12
|
|
|
13
13
|
export const useStyles = makeStyles<MakeStylesProps>()(
|
|
14
14
|
(theme, { limitLegendRows }) => ({
|
|
@@ -5,7 +5,7 @@ import { equals, find, isNil } from 'ramda';
|
|
|
5
5
|
|
|
6
6
|
import { mousePositionAtom } from '../InteractiveComponents/interactionWithGraphAtoms';
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
formatMetricValueWithUnit,
|
|
9
9
|
getLineForMetric,
|
|
10
10
|
getMetrics,
|
|
11
11
|
getTimeValue
|
|
@@ -73,7 +73,7 @@ const useInteractiveValues = ({
|
|
|
73
73
|
metric_id
|
|
74
74
|
}) as Line;
|
|
75
75
|
|
|
76
|
-
const formattedValue =
|
|
76
|
+
const formattedValue = formatMetricValueWithUnit({
|
|
77
77
|
base,
|
|
78
78
|
unit,
|
|
79
79
|
value
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { includes, map, prop, reject
|
|
1
|
+
import { includes, map, prop, reject } from 'ramda';
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
|
|
4
4
|
import { Chip, ChipProps, Tooltip } from '@mui/material';
|
|
@@ -85,11 +85,9 @@ const MultiAutocompleteField = ({
|
|
|
85
85
|
return includes(id, valueIds);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
const sortByName = sortBy(compose(toLower, prop('name')));
|
|
89
|
-
|
|
90
88
|
const autocompleteOptions = disableSortedOptions
|
|
91
89
|
? options
|
|
92
|
-
:
|
|
90
|
+
: [...values, ...reject(isOptionSelected, options)];
|
|
93
91
|
|
|
94
92
|
return (
|
|
95
93
|
<Autocomplete
|
|
@@ -48,7 +48,7 @@ describe('useFetchQuery', () => {
|
|
|
48
48
|
method: Method.POST
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
result.current.mutate(user);
|
|
51
|
+
result.current.mutate({ payload: user });
|
|
52
52
|
|
|
53
53
|
await waitFor(() => {
|
|
54
54
|
expect(result.current?.isError).toEqual(false);
|
|
@@ -64,7 +64,7 @@ describe('useFetchQuery', () => {
|
|
|
64
64
|
method: Method.POST
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
result.current.mutate(user);
|
|
67
|
+
result.current.mutate({ payload: user });
|
|
68
68
|
|
|
69
69
|
await waitFor(() => {
|
|
70
70
|
expect(result.current?.isError).toEqual(true);
|
|
@@ -85,7 +85,7 @@ describe('useFetchQuery', () => {
|
|
|
85
85
|
method: Method.POST
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
result.current.mutate(user);
|
|
88
|
+
result.current.mutate({ payload: user });
|
|
89
89
|
|
|
90
90
|
await waitFor(() => {
|
|
91
91
|
expect(result.current?.isError).toEqual(true);
|
|
@@ -109,7 +109,7 @@ describe('useFetchQuery', () => {
|
|
|
109
109
|
method: Method.POST
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
result.current.mutate(user);
|
|
112
|
+
result.current.mutate({ payload: user });
|
|
113
113
|
|
|
114
114
|
await waitFor(() => {
|
|
115
115
|
expect(mockedShowErrorMessage).not.toHaveBeenCalled();
|
|
@@ -22,6 +22,11 @@ export enum Method {
|
|
|
22
22
|
PUT = 'PUT'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
interface Variables<TMeta, T> {
|
|
26
|
+
_meta?: TMeta;
|
|
27
|
+
payload?: T;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
export type UseMutationQueryProps<T, TMeta> = {
|
|
26
31
|
baseEndpoint?: string;
|
|
27
32
|
catchError?: (props: CatchErrorProps) => void;
|
|
@@ -33,30 +38,36 @@ export type UseMutationQueryProps<T, TMeta> = {
|
|
|
33
38
|
method: Method;
|
|
34
39
|
onError?: (
|
|
35
40
|
error: ResponseError,
|
|
36
|
-
variables:
|
|
41
|
+
variables: Variables<TMeta, T>,
|
|
37
42
|
context: unknown
|
|
38
43
|
) => unknown;
|
|
39
|
-
onMutate?: (variables:
|
|
44
|
+
onMutate?: (variables: Variables<TMeta, T>) => Promise<unknown> | unknown;
|
|
40
45
|
onSuccess?: (
|
|
41
46
|
data: ResponseError | T,
|
|
42
|
-
variables: T
|
|
43
|
-
_meta: TMeta;
|
|
44
|
-
},
|
|
47
|
+
variables: Variables<TMeta, T>,
|
|
45
48
|
context: unknown
|
|
46
49
|
) => unknown;
|
|
47
50
|
} & Omit<
|
|
48
|
-
UseMutationOptions<
|
|
49
|
-
'mutationFn' | 'onError' | 'onMutate' | 'onSuccess'
|
|
51
|
+
UseMutationOptions<{ _meta?: TMeta; payload: T }>,
|
|
52
|
+
'mutationFn' | 'onError' | 'onMutate' | 'onSuccess' | 'mutateAsync' | 'mutate'
|
|
50
53
|
>;
|
|
51
54
|
|
|
52
55
|
const log = anylogger('API Request');
|
|
53
56
|
|
|
54
|
-
export type UseMutationQueryState<T> = Omit<
|
|
57
|
+
export type UseMutationQueryState<T, TMeta> = Omit<
|
|
55
58
|
UseMutationResult<T | ResponseError>,
|
|
56
|
-
'isError'
|
|
59
|
+
'isError' | 'mutate' | 'mutateAsync'
|
|
57
60
|
> & {
|
|
58
61
|
isError: boolean;
|
|
59
62
|
isMutating: boolean;
|
|
63
|
+
mutate: (variables: Variables<TMeta, T>) => ResponseError | T;
|
|
64
|
+
mutateAsync: (
|
|
65
|
+
variables: Variables<TMeta, T>,
|
|
66
|
+
rest?: Pick<
|
|
67
|
+
UseMutationQueryProps<T, TMeta>,
|
|
68
|
+
'onError' | 'onMutate' | 'onSettled' | 'onSuccess'
|
|
69
|
+
>
|
|
70
|
+
) => Promise<ResponseError | T>;
|
|
60
71
|
};
|
|
61
72
|
|
|
62
73
|
const useMutationQuery = <T extends object, TMeta>({
|
|
@@ -72,18 +83,18 @@ const useMutationQuery = <T extends object, TMeta>({
|
|
|
72
83
|
onSuccess,
|
|
73
84
|
onSettled,
|
|
74
85
|
baseEndpoint
|
|
75
|
-
}: UseMutationQueryProps<T, TMeta>): UseMutationQueryState<T> => {
|
|
86
|
+
}: UseMutationQueryProps<T, TMeta>): UseMutationQueryState<T, TMeta> => {
|
|
76
87
|
const { showErrorMessage } = useSnackbar();
|
|
77
88
|
|
|
78
89
|
const queryData = useMutation<
|
|
79
90
|
T | ResponseError,
|
|
80
91
|
ResponseError,
|
|
81
|
-
|
|
92
|
+
Variables<TMeta, T>
|
|
82
93
|
>({
|
|
83
94
|
mutationFn: (
|
|
84
|
-
|
|
95
|
+
variables: Variables<TMeta, T>
|
|
85
96
|
): Promise<T | ResponseError> => {
|
|
86
|
-
const { _meta,
|
|
97
|
+
const { _meta, payload } = variables || {};
|
|
87
98
|
|
|
88
99
|
return customFetch<T>({
|
|
89
100
|
baseEndpoint,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ForwardedRef, forwardRef, ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ListItem as MuiListItem } from '@mui/material';
|
|
4
4
|
|
|
5
5
|
import { useStyles } from './ListItem.styles';
|
|
6
6
|
|
|
7
|
-
type
|
|
7
|
+
type ListItemProps = {
|
|
8
8
|
action?: ReactElement;
|
|
9
9
|
children: ReactNode | Array<ReactNode>;
|
|
10
10
|
className?: string;
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
|
|
13
13
|
export const ListItem = forwardRef(
|
|
14
14
|
(
|
|
15
|
-
{ action, children, className, ...attr }:
|
|
15
|
+
{ action, children, className, ...attr }: ListItemProps,
|
|
16
16
|
ref?: ForwardedRef<HTMLLIElement>
|
|
17
17
|
) => {
|
|
18
18
|
const { classes, cx } = useStyles();
|