@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
|
@@ -3,10 +3,15 @@ import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
|
|
|
3
3
|
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
4
4
|
import utcPlugin from 'dayjs/plugin/utc';
|
|
5
5
|
import { Provider, createStore } from 'jotai';
|
|
6
|
-
import { equals } from 'ramda';
|
|
6
|
+
import { equals, inc } from 'ramda';
|
|
7
7
|
import { renderHook } from '@testing-library/react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { LocalizationProvider } from '@mui/x-date-pickers';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
useLocaleDateTimeFormat,
|
|
13
|
+
useDateTimePickerAdapter
|
|
14
|
+
} from '@centreon/ui';
|
|
10
15
|
import { ListingVariant, userAtom } from '@centreon/ui-context';
|
|
11
16
|
|
|
12
17
|
import { CustomTimePeriodProperty } from './models';
|
|
@@ -292,6 +297,10 @@ testData.forEach((item) =>
|
|
|
292
297
|
beforeEach(() => {
|
|
293
298
|
cy.viewport('macbook-13');
|
|
294
299
|
|
|
300
|
+
const { result } = renderHook(() => useDateTimePickerAdapter());
|
|
301
|
+
|
|
302
|
+
const { Adapter } = result.current;
|
|
303
|
+
|
|
295
304
|
const store = createStore();
|
|
296
305
|
store.set(userAtom, {
|
|
297
306
|
...retrievedUser,
|
|
@@ -302,16 +311,31 @@ testData.forEach((item) =>
|
|
|
302
311
|
cy.mount({
|
|
303
312
|
Component: (
|
|
304
313
|
<Provider store={store}>
|
|
305
|
-
<
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
314
|
+
<LocalizationProvider adapterLocale="en" dateAdapter={Adapter}>
|
|
315
|
+
<DateTimePickerInput
|
|
316
|
+
changeDate={cy.stub()}
|
|
317
|
+
date={new Date(item.initialDate)}
|
|
318
|
+
desktopMediaQuery="@media (min-width: 1024px)"
|
|
319
|
+
property={CustomTimePeriodProperty.start}
|
|
320
|
+
/>
|
|
321
|
+
</LocalizationProvider>
|
|
310
322
|
</Provider>
|
|
311
323
|
)
|
|
312
324
|
});
|
|
313
325
|
});
|
|
314
326
|
|
|
327
|
+
it('checks input calendar value contains correct date', () => {
|
|
328
|
+
const { result } = renderHook(() => useLocaleDateTimeFormat());
|
|
329
|
+
const { format } = result.current;
|
|
330
|
+
|
|
331
|
+
const dateInput = format({
|
|
332
|
+
date: dayjs(item.initialDate).tz(item.timezone),
|
|
333
|
+
formatString: 'L hh:mm A'
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
cy.get('input').should('have.value', dateInput);
|
|
337
|
+
});
|
|
338
|
+
|
|
315
339
|
it(`displays the correct number of days for the current month when the ${item.button} button is clicked`, () => {
|
|
316
340
|
cy.get('button').click();
|
|
317
341
|
item.data.forEach((element) => {
|
|
@@ -365,7 +389,7 @@ testData.forEach((item) =>
|
|
|
365
389
|
|
|
366
390
|
cy.get('[role="rowgroup"]').children().as('listWeeks');
|
|
367
391
|
|
|
368
|
-
cy.get('@listWeeks').should('have.length', numberWeeks);
|
|
392
|
+
cy.get('@listWeeks').should('have.length', inc(numberWeeks));
|
|
369
393
|
cy.get('@listWeeks').eq(0).as('firstWeek');
|
|
370
394
|
cy.get('@firstWeek').children().as('listDaysInFirstWeek');
|
|
371
395
|
|
|
@@ -392,7 +416,7 @@ testData.forEach((item) =>
|
|
|
392
416
|
|
|
393
417
|
cy.get('[role="rowgroup"]').children().as('listWeeks');
|
|
394
418
|
|
|
395
|
-
cy.get('@listWeeks').should('have.length', numberWeeks);
|
|
419
|
+
cy.get('@listWeeks').should('have.length', inc(numberWeeks));
|
|
396
420
|
|
|
397
421
|
cy.get('@listWeeks')
|
|
398
422
|
.eq(numberWeeks - 1)
|
|
@@ -88,27 +88,20 @@ const args = {
|
|
|
88
88
|
]
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
const parameters = {
|
|
92
|
-
chromatic: { diffThreshold: 0.1 }
|
|
93
|
-
};
|
|
94
|
-
|
|
95
91
|
export const BasicTimePeriod: Story = {
|
|
96
92
|
...Template,
|
|
97
|
-
argTypes
|
|
98
|
-
parameters
|
|
93
|
+
argTypes
|
|
99
94
|
};
|
|
100
95
|
|
|
101
96
|
export const WithExtraTimePeriods: Story = {
|
|
102
97
|
...Template,
|
|
103
98
|
argTypes,
|
|
104
|
-
args
|
|
105
|
-
parameters
|
|
99
|
+
args
|
|
106
100
|
};
|
|
107
101
|
|
|
108
102
|
export const WithExternalComponent: Story = {
|
|
109
103
|
...TemplateWithExternalComponent,
|
|
110
|
-
argTypes
|
|
111
|
-
parameters
|
|
104
|
+
argTypes
|
|
112
105
|
};
|
|
113
106
|
|
|
114
107
|
export const SimpleTimePeriod: StorySimpleTimePeriod = {
|
|
@@ -116,6 +109,5 @@ export const SimpleTimePeriod: StorySimpleTimePeriod = {
|
|
|
116
109
|
args: {
|
|
117
110
|
endDate: dayjs(Date.now()).toDate(),
|
|
118
111
|
startDate: dayjs(Date.now()).subtract(29, 'day').toDate()
|
|
119
|
-
}
|
|
120
|
-
parameters
|
|
112
|
+
}
|
|
121
113
|
};
|
|
@@ -20,7 +20,7 @@ import { useStyles } from './TimePeriods.styles';
|
|
|
20
20
|
import {
|
|
21
21
|
CustomTimePeriod as CustomTimePeriodModel,
|
|
22
22
|
EndStartInterval,
|
|
23
|
-
TimePeriod
|
|
23
|
+
TimePeriod
|
|
24
24
|
} from './models';
|
|
25
25
|
import useTimePeriod from './useTimePeriod';
|
|
26
26
|
|
|
@@ -34,7 +34,7 @@ interface Parameters extends EndStartInterval {
|
|
|
34
34
|
export interface Props {
|
|
35
35
|
adjustTimePeriodData?: Omit<CustomTimePeriodModel, 'timelineEventsLimit'>;
|
|
36
36
|
disabled?: boolean;
|
|
37
|
-
extraTimePeriods?: Array<Omit<
|
|
37
|
+
extraTimePeriods?: Array<Omit<TimePeriod, 'timelineEventsLimit'>>;
|
|
38
38
|
getIsError?: (value: boolean) => void;
|
|
39
39
|
getParameters?: ({ start, end, timelineEventsLimit }: Parameters) => void;
|
|
40
40
|
renderExternalComponent?: ReactNode;
|
|
@@ -26,9 +26,7 @@ export interface UseFetchQueryProps<T> {
|
|
|
26
26
|
getQueryKey: () => QueryKey;
|
|
27
27
|
httpCodesBypassErrorSnackbar?: Array<number>;
|
|
28
28
|
isPaginated?: boolean;
|
|
29
|
-
queryOptions?:
|
|
30
|
-
suspense?: boolean;
|
|
31
|
-
} & Omit<
|
|
29
|
+
queryOptions?: Omit<
|
|
32
30
|
UseQueryOptions<T | ResponseError, Error, T | ResponseError, QueryKey>,
|
|
33
31
|
'queryKey' | 'queryFn'
|
|
34
32
|
>;
|
|
@@ -36,12 +34,11 @@ export interface UseFetchQueryProps<T> {
|
|
|
36
34
|
|
|
37
35
|
export type UseFetchQueryState<T> = {
|
|
38
36
|
data?: T;
|
|
39
|
-
error: Omit<ResponseError, 'isError'> | null;
|
|
40
37
|
fetchQuery: () => Promise<T | ResponseError>;
|
|
41
38
|
prefetchNextPage: ({ page, getPrefetchQueryKey }) => void;
|
|
42
39
|
prefetchPreviousPage: ({ page, getPrefetchQueryKey }) => void;
|
|
43
40
|
prefetchQuery: ({ endpointParams, queryKey }) => void;
|
|
44
|
-
} & Omit<QueryObserverBaseResult, 'data'
|
|
41
|
+
} & Omit<QueryObserverBaseResult, 'data'>;
|
|
45
42
|
|
|
46
43
|
export interface PrefetchEndpointParams {
|
|
47
44
|
page: number;
|
|
@@ -65,8 +62,9 @@ const useFetchQuery = <T extends object>({
|
|
|
65
62
|
|
|
66
63
|
const { showErrorMessage } = useSnackbar();
|
|
67
64
|
|
|
68
|
-
const queryData = useQuery<T | ResponseError, Error>(
|
|
69
|
-
|
|
65
|
+
const queryData = useQuery<T | ResponseError, Error>(
|
|
66
|
+
getQueryKey(),
|
|
67
|
+
({ signal }): Promise<T | ResponseError> =>
|
|
70
68
|
customFetch<T>({
|
|
71
69
|
baseEndpoint,
|
|
72
70
|
catchError,
|
|
@@ -76,9 +74,10 @@ const useFetchQuery = <T extends object>({
|
|
|
76
74
|
headers: new Headers(fetchHeaders),
|
|
77
75
|
signal
|
|
78
76
|
}),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
{
|
|
78
|
+
...queryOptions
|
|
79
|
+
}
|
|
80
|
+
);
|
|
82
81
|
|
|
83
82
|
const queryClient = useQueryClient();
|
|
84
83
|
|
|
@@ -98,8 +97,9 @@ const useFetchQuery = <T extends object>({
|
|
|
98
97
|
};
|
|
99
98
|
|
|
100
99
|
const prefetchQuery = ({ endpointParams, queryKey }): void => {
|
|
101
|
-
queryClient.prefetchQuery(
|
|
102
|
-
|
|
100
|
+
queryClient.prefetchQuery(
|
|
101
|
+
queryKey,
|
|
102
|
+
({ signal }): Promise<T | ResponseError> =>
|
|
103
103
|
customFetch<T>({
|
|
104
104
|
baseEndpoint,
|
|
105
105
|
catchError,
|
|
@@ -108,9 +108,8 @@ const useFetchQuery = <T extends object>({
|
|
|
108
108
|
endpoint: getEndpoint(endpointParams),
|
|
109
109
|
headers: new Headers(fetchHeaders),
|
|
110
110
|
signal
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
});
|
|
111
|
+
})
|
|
112
|
+
);
|
|
114
113
|
};
|
|
115
114
|
|
|
116
115
|
const prefetchNextPage = ({ page, getPrefetchQueryKey }): void => {
|
|
@@ -140,8 +139,9 @@ const useFetchQuery = <T extends object>({
|
|
|
140
139
|
};
|
|
141
140
|
|
|
142
141
|
const fetchQuery = (): Promise<T | ResponseError> => {
|
|
143
|
-
return queryClient.fetchQuery(
|
|
144
|
-
|
|
142
|
+
return queryClient.fetchQuery(
|
|
143
|
+
getQueryKey(),
|
|
144
|
+
({ signal }): Promise<T | ResponseError> =>
|
|
145
145
|
customFetch<T>({
|
|
146
146
|
baseEndpoint,
|
|
147
147
|
catchError,
|
|
@@ -150,9 +150,8 @@ const useFetchQuery = <T extends object>({
|
|
|
150
150
|
endpoint: getEndpoint(),
|
|
151
151
|
headers: new Headers(fetchHeaders),
|
|
152
152
|
signal
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
});
|
|
153
|
+
})
|
|
154
|
+
);
|
|
156
155
|
};
|
|
157
156
|
|
|
158
157
|
const data = useMemo(
|
|
@@ -169,16 +168,13 @@ const useFetchQuery = <T extends object>({
|
|
|
169
168
|
|
|
170
169
|
useEffect(() => {
|
|
171
170
|
return (): void => {
|
|
172
|
-
queryClient.cancelQueries(
|
|
171
|
+
queryClient.cancelQueries(getQueryKey());
|
|
173
172
|
};
|
|
174
173
|
}, []);
|
|
175
174
|
|
|
176
|
-
useEffect(
|
|
177
|
-
()
|
|
178
|
-
|
|
179
|
-
},
|
|
180
|
-
useDeepCompare([queryData.data])
|
|
181
|
-
);
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
manageError();
|
|
177
|
+
}, useDeepCompare([queryData.data]));
|
|
182
178
|
|
|
183
179
|
return {
|
|
184
180
|
...omit(['data', 'error'], queryData),
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@tanstack/react-query';
|
|
9
9
|
import { JsonDecoder } from 'ts.data.json';
|
|
10
10
|
import anylogger from 'anylogger';
|
|
11
|
-
import { includes
|
|
11
|
+
import { includes } from 'ramda';
|
|
12
12
|
|
|
13
13
|
import { CatchErrorProps, customFetch, ResponseError } from '../customFetch';
|
|
14
14
|
import useSnackbar from '../../Snackbar/useSnackbar';
|
|
@@ -31,33 +31,14 @@ export type UseMutationQueryProps<T, TMeta> = {
|
|
|
31
31
|
getEndpoint: (_meta: TMeta) => string;
|
|
32
32
|
httpCodesBypassErrorSnackbar?: Array<number>;
|
|
33
33
|
method: Method;
|
|
34
|
-
|
|
35
|
-
error: ResponseError,
|
|
36
|
-
variables: T & { _meta: TMeta },
|
|
37
|
-
context: unknown
|
|
38
|
-
) => unknown;
|
|
39
|
-
onMutate?: (variables: T & { _meta: TMeta }) => Promise<unknown> | unknown;
|
|
40
|
-
onSuccess?: (
|
|
41
|
-
data: ResponseError | T,
|
|
42
|
-
variables: T & {
|
|
43
|
-
_meta: TMeta;
|
|
44
|
-
},
|
|
45
|
-
context: unknown
|
|
46
|
-
) => unknown;
|
|
47
|
-
} & Omit<
|
|
48
|
-
UseMutationOptions<T & { _meta?: TMeta }>,
|
|
49
|
-
'mutationFn' | 'onError' | 'onMutate' | 'onSuccess'
|
|
50
|
-
>;
|
|
34
|
+
} & Omit<UseMutationOptions<T & { _meta?: TMeta }>, 'mutationFn'>;
|
|
51
35
|
|
|
52
36
|
const log = anylogger('API Request');
|
|
53
37
|
|
|
54
|
-
export type UseMutationQueryState<T> =
|
|
55
|
-
UseMutationResult<T | ResponseError>,
|
|
56
|
-
'isError'
|
|
57
|
-
> & {
|
|
38
|
+
export type UseMutationQueryState<T> = {
|
|
58
39
|
isError: boolean;
|
|
59
40
|
isMutating: boolean;
|
|
60
|
-
}
|
|
41
|
+
} & UseMutationResult<T | ResponseError>;
|
|
61
42
|
|
|
62
43
|
const useMutationQuery = <T extends object, TMeta>({
|
|
63
44
|
getEndpoint,
|
|
@@ -70,7 +51,6 @@ const useMutationQuery = <T extends object, TMeta>({
|
|
|
70
51
|
onMutate,
|
|
71
52
|
onError,
|
|
72
53
|
onSuccess,
|
|
73
|
-
onSettled,
|
|
74
54
|
baseEndpoint
|
|
75
55
|
}: UseMutationQueryProps<T, TMeta>): UseMutationQueryState<T> => {
|
|
76
56
|
const { showErrorMessage } = useSnackbar();
|
|
@@ -79,10 +59,8 @@ const useMutationQuery = <T extends object, TMeta>({
|
|
|
79
59
|
T | ResponseError,
|
|
80
60
|
ResponseError,
|
|
81
61
|
T & { _meta: TMeta }
|
|
82
|
-
>(
|
|
83
|
-
|
|
84
|
-
_payload: T & { _meta: TMeta }
|
|
85
|
-
): Promise<T | ResponseError> => {
|
|
62
|
+
>(
|
|
63
|
+
(_payload: T & { _meta: TMeta }): Promise<T | ResponseError> => {
|
|
86
64
|
const { _meta, ...payload } = _payload || {};
|
|
87
65
|
|
|
88
66
|
return customFetch<T>({
|
|
@@ -100,18 +78,19 @@ const useMutationQuery = <T extends object, TMeta>({
|
|
|
100
78
|
payload
|
|
101
79
|
});
|
|
102
80
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
{
|
|
82
|
+
onError,
|
|
83
|
+
onMutate,
|
|
84
|
+
onSuccess: (data, variables, context) => {
|
|
85
|
+
if (data?.isError) {
|
|
86
|
+
onError?.(data, variables, context);
|
|
109
87
|
|
|
110
|
-
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
onSuccess?.(data, variables, context);
|
|
111
91
|
}
|
|
112
|
-
onSuccess?.(data, variables, context);
|
|
113
92
|
}
|
|
114
|
-
|
|
93
|
+
);
|
|
115
94
|
|
|
116
95
|
const manageError = (): void => {
|
|
117
96
|
const data = queryData.data as ResponseError | undefined;
|
|
@@ -128,17 +107,14 @@ const useMutationQuery = <T extends object, TMeta>({
|
|
|
128
107
|
}
|
|
129
108
|
};
|
|
130
109
|
|
|
131
|
-
useEffect(
|
|
132
|
-
()
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
useDeepCompare([queryData.data])
|
|
136
|
-
);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
manageError();
|
|
112
|
+
}, useDeepCompare([queryData.data]));
|
|
137
113
|
|
|
138
114
|
return {
|
|
139
|
-
...
|
|
115
|
+
...queryData,
|
|
140
116
|
isError: (queryData.data as ResponseError | undefined)?.isError || false,
|
|
141
|
-
isMutating: queryData.
|
|
117
|
+
isMutating: queryData.isLoading
|
|
142
118
|
};
|
|
143
119
|
};
|
|
144
120
|
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
IconButton as MuiIconButton,
|
|
5
|
-
IconButtonProps as MuiIconButtonProps
|
|
6
|
-
} from '@mui/material';
|
|
3
|
+
import { IconButton as MuiIconButton } from '@mui/material';
|
|
7
4
|
|
|
8
5
|
import { AriaLabelingAttributes } from '../../../@types/aria-attributes';
|
|
9
6
|
import { DataTestAttributes } from '../../../@types/data-attributes';
|
|
@@ -26,8 +23,7 @@ type IconButtonProps = {
|
|
|
26
23
|
size?: 'small' | 'medium' | 'large';
|
|
27
24
|
variant?: 'primary' | 'secondary' | 'ghost';
|
|
28
25
|
} & AriaLabelingAttributes &
|
|
29
|
-
DataTestAttributes
|
|
30
|
-
MuiIconButtonProps;
|
|
26
|
+
DataTestAttributes;
|
|
31
27
|
|
|
32
28
|
/**
|
|
33
29
|
* @todo re-factor as `iconVariant: 'icon-only'` Button variant, and remove IconButton component (reason: code duplication)
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
|
|
3
|
-
import { Box } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
import { ColumnType } from '../../Listing/models';
|
|
6
|
-
|
|
7
3
|
import { DataTable } from './index';
|
|
8
4
|
|
|
9
5
|
const meta: Meta<typeof DataTable> = {
|
|
@@ -53,39 +49,3 @@ export const withFixedHeightContainer: Story = {
|
|
|
53
49
|
</div>
|
|
54
50
|
)
|
|
55
51
|
};
|
|
56
|
-
|
|
57
|
-
const ListingTemplate = (args): JSX.Element => (
|
|
58
|
-
<Box sx={{ height: '80vh' }}>
|
|
59
|
-
<DataTable {...args} />
|
|
60
|
-
</Box>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
export const listing: Story = {
|
|
64
|
-
args: {
|
|
65
|
-
children: (
|
|
66
|
-
<DataTable.Listing
|
|
67
|
-
columns={[
|
|
68
|
-
{
|
|
69
|
-
getFormattedString: (row) => row.title,
|
|
70
|
-
id: 'title',
|
|
71
|
-
label: 'Title',
|
|
72
|
-
type: ColumnType.string
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
getFormattedString: (row) => row.description,
|
|
76
|
-
id: 'description',
|
|
77
|
-
label: 'Description',
|
|
78
|
-
type: ColumnType.string
|
|
79
|
-
}
|
|
80
|
-
]}
|
|
81
|
-
rows={[...Array(5)].map((_, i) => ({
|
|
82
|
-
description: `Item description ${i}`,
|
|
83
|
-
id: i,
|
|
84
|
-
title: `Item ${i}`
|
|
85
|
-
}))}
|
|
86
|
-
/>
|
|
87
|
-
),
|
|
88
|
-
variant: 'listing'
|
|
89
|
-
},
|
|
90
|
-
render: ListingTemplate
|
|
91
|
-
};
|
|
@@ -10,9 +10,6 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
10
10
|
gridGap: theme.spacing(2.5),
|
|
11
11
|
gridTemplateColumns: `repeat(auto-fill, ${theme.spacing(45)})`
|
|
12
12
|
},
|
|
13
|
-
'&[data-variant="listing"]': {
|
|
14
|
-
height: '100%'
|
|
15
|
-
},
|
|
16
13
|
'&[data-variant][data-is-empty="true"]': {
|
|
17
14
|
display: 'flex',
|
|
18
15
|
justifyContent: 'center',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
1
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useStyles } from './DataTable.styles';
|
|
4
4
|
|
|
5
5
|
type DataTableProps = {
|
|
6
|
-
children
|
|
6
|
+
children: ReactNode | Array<ReactNode>;
|
|
7
7
|
isEmpty?: boolean;
|
|
8
|
-
variant
|
|
8
|
+
variant?: 'grid';
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
/** *
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { makeStyles } from 'tss-react/mui';
|
|
2
2
|
|
|
3
3
|
const useStyles = makeStyles()((theme) => ({
|
|
4
|
-
actions: {
|
|
5
|
-
display: 'flex',
|
|
6
|
-
flexDirection: 'row',
|
|
7
|
-
justifyContent: 'space-between'
|
|
8
|
-
},
|
|
9
4
|
dataTableItem: {
|
|
10
5
|
'& .MuiCardActionArea-root': {
|
|
11
6
|
alignItems: 'flex-start',
|
|
12
7
|
display: 'flex',
|
|
13
8
|
flexDirection: 'column',
|
|
14
9
|
height: '100%',
|
|
15
|
-
justifyContent: '
|
|
10
|
+
justifyContent: 'space-between'
|
|
16
11
|
},
|
|
17
12
|
'& .MuiCardActions-root': {
|
|
18
13
|
'& > span': {
|
|
@@ -20,13 +15,13 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
20
15
|
gap: theme.spacing(1)
|
|
21
16
|
},
|
|
22
17
|
display: 'flex',
|
|
18
|
+
|
|
23
19
|
justifyContent: 'space-between'
|
|
24
20
|
},
|
|
25
21
|
borderRadius: theme.shape.borderRadius,
|
|
26
22
|
display: 'flex',
|
|
27
23
|
flexDirection: 'column',
|
|
28
24
|
height: '186px',
|
|
29
|
-
justifyContent: 'space-between',
|
|
30
25
|
p: {
|
|
31
26
|
color: theme.palette.text.secondary,
|
|
32
27
|
letterSpacing: '0',
|
|
@@ -22,7 +22,7 @@ export interface DataTableItemProps {
|
|
|
22
22
|
description?: string;
|
|
23
23
|
hasActions?: boolean;
|
|
24
24
|
hasCardAction?: boolean;
|
|
25
|
-
labelsDelete
|
|
25
|
+
labelsDelete: {
|
|
26
26
|
cancel: string;
|
|
27
27
|
confirm: {
|
|
28
28
|
label: string;
|
|
@@ -76,7 +76,7 @@ const DataTableItem = forwardRef(
|
|
|
76
76
|
{hasActions && (
|
|
77
77
|
<MuiCardActions>
|
|
78
78
|
<span>
|
|
79
|
-
{onDelete &&
|
|
79
|
+
{onDelete && (
|
|
80
80
|
<ConfirmationTooltip
|
|
81
81
|
confirmVariant="error"
|
|
82
82
|
labels={labelsDelete}
|
|
@@ -2,11 +2,9 @@ import { DataTable as DataTableRoot } from './DataTable';
|
|
|
2
2
|
import { DataTableItem } from './Item/DataTableItem';
|
|
3
3
|
import { DataTableItemSkeleton } from './Item/DataTableItemSkeleton';
|
|
4
4
|
import { DataTableEmptyState } from './EmptyState/DataTableEmptyState';
|
|
5
|
-
import { DataListing } from './DataListing';
|
|
6
5
|
|
|
7
6
|
export const DataTable = Object.assign(DataTableRoot, {
|
|
8
7
|
EmptyState: DataTableEmptyState,
|
|
9
8
|
Item: DataTableItem,
|
|
10
|
-
ItemSkeleton: DataTableItemSkeleton
|
|
11
|
-
Listing: DataListing
|
|
9
|
+
ItemSkeleton: DataTableItemSkeleton
|
|
12
10
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ReactElement, useCallback, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as Yup from 'yup';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { equals } from 'ramda';
|
|
6
5
|
|
|
7
6
|
import { InputType } from '../../../Form/Inputs/models';
|
|
8
7
|
import { Form, FormProps } from '../../../Form';
|
|
@@ -85,8 +84,8 @@ const DashboardForm = ({
|
|
|
85
84
|
}
|
|
86
85
|
],
|
|
87
86
|
submit: (values, bag) => onSubmit?.(values, bag),
|
|
88
|
-
validationSchema: object({
|
|
89
|
-
description: string()
|
|
87
|
+
validationSchema: Yup.object().shape({
|
|
88
|
+
description: Yup.string()
|
|
90
89
|
.label(labels?.entity?.description || '')
|
|
91
90
|
.max(
|
|
92
91
|
180,
|
|
@@ -94,19 +93,17 @@ const DashboardForm = ({
|
|
|
94
93
|
`${p.label} ${t(labelMustBeMost)} ${p.max} ${t(labelCharacters)}`
|
|
95
94
|
)
|
|
96
95
|
.nullable(),
|
|
97
|
-
globalRefreshInterval: object({
|
|
98
|
-
interval: number().when('type',
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return schema.nullable();
|
|
96
|
+
globalRefreshInterval: Yup.object().shape({
|
|
97
|
+
interval: Yup.number().when('type', {
|
|
98
|
+
is: 'global',
|
|
99
|
+
otherwise: Yup.number().nullable(),
|
|
100
|
+
then: Yup.number()
|
|
101
|
+
.min(1, ({ min }) => t(labelMustBeAtLeast, { min }))
|
|
102
|
+
.required(t(labelRequired) as string)
|
|
106
103
|
}),
|
|
107
|
-
type: string()
|
|
104
|
+
type: Yup.string()
|
|
108
105
|
}),
|
|
109
|
-
name: string()
|
|
106
|
+
name: Yup.string()
|
|
110
107
|
.label(labels?.entity?.name)
|
|
111
108
|
.min(3, ({ min, label }) => t(labelMustBeAtLeast, { label, min }))
|
|
112
109
|
.max(50, ({ max, label }) => t(labelMustBeMost, { label, max }))
|