@centreon/ui 24.10.12 → 24.10.13
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 +3 -2
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +3 -1
- package/src/Dashboard/Dashboard.styles.ts +3 -4
- package/src/Dashboard/DashboardLayout.stories.tsx +1 -1
- package/src/Dashboard/Grid.tsx +11 -17
- package/src/Dashboard/Layout.tsx +27 -56
- package/src/Dialog/UnsavedChanges/index.tsx +15 -13
- package/src/Dialog/UnsavedChanges/translatedLabels.ts +15 -13
- package/src/Form/Form.tsx +0 -1
- package/src/Form/Inputs/Autocomplete.tsx +1 -1
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +5 -2
- package/src/Form/Inputs/Grid.tsx +7 -1
- package/src/Form/Inputs/Radio.tsx +1 -1
- package/src/Form/Inputs/Switch.tsx +1 -1
- package/src/Form/Inputs/Text.tsx +1 -1
- package/src/Form/Inputs/index.tsx +25 -24
- package/src/Form/Inputs/models.ts +2 -0
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +3 -3
- package/src/Graph/BarChart/BarChart.tsx +24 -31
- package/src/Graph/BarChart/BarGroup.tsx +32 -59
- package/src/Graph/BarChart/BarStack.tsx +64 -13
- package/src/Graph/BarChart/MemoizedGroup.tsx +123 -0
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +21 -7
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +87 -9
- package/src/Graph/BarStack/BarStack.stories.tsx +13 -4
- package/src/Graph/BarStack/BarStack.styles.ts +57 -33
- package/src/Graph/BarStack/Graph.tsx +173 -0
- package/src/Graph/BarStack/GraphAndLegend.tsx +117 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +61 -168
- package/src/Graph/BarStack/constants.ts +5 -0
- package/src/Graph/BarStack/models.ts +0 -1
- package/src/Graph/BarStack/useGraphAndLegend.ts +84 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +73 -97
- package/src/Graph/Chart/Chart.cypress.spec.tsx +14 -26
- package/src/Graph/Chart/Chart.stories.tsx +1 -1
- package/src/Graph/Chart/Chart.tsx +53 -37
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +3 -3
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +19 -6
- package/src/Graph/Chart/Legend/Legend.styles.ts +25 -11
- package/src/Graph/Chart/Legend/index.tsx +6 -24
- package/src/Graph/Chart/index.tsx +34 -43
- package/src/Graph/Chart/models.ts +0 -1
- package/src/Graph/Chart/useChartData.ts +19 -1
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +20 -2
- package/src/Graph/HeatMap/model.ts +6 -2
- package/src/Graph/Legend/Legend.styles.ts +10 -0
- package/src/Graph/Legend/Legend.tsx +6 -1
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +9 -10
- package/src/Graph/SingleBar/ThresholdLine.tsx +6 -6
- package/src/Graph/Text/Text.styles.ts +2 -2
- package/src/Graph/Text/Text.tsx +23 -10
- package/src/Graph/Timeline/ResponsiveTimeline.tsx +152 -0
- package/src/Graph/Timeline/Timeline.cypress.spec.tsx +148 -0
- package/src/Graph/Timeline/Timeline.stories.tsx +91 -0
- package/src/Graph/Timeline/Timeline.tsx +28 -0
- package/src/Graph/Timeline/index.ts +1 -0
- package/src/Graph/Timeline/models.ts +20 -0
- package/src/Graph/Timeline/timeline.styles.ts +11 -0
- package/src/Graph/Timeline/translatedLabel.ts +6 -0
- package/src/Graph/Timeline/useTimeline.ts +90 -0
- package/src/Graph/Tree/Links.tsx +2 -2
- package/src/Graph/Tree/Tree.tsx +2 -2
- package/src/Graph/Tree/constants.ts +1 -1
- package/src/Graph/common/Axes/index.tsx +1 -1
- package/src/Graph/common/Axes/useAxisY.ts +8 -4
- package/src/Graph/common/BaseChart/BaseChart.tsx +3 -12
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +12 -4
- package/src/Graph/common/BaseChart/Header/index.tsx +3 -1
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +23 -11
- package/src/Graph/common/BaseChart/useComputeYAxisMaxCharacters.ts +92 -0
- package/src/Graph/common/models.ts +7 -8
- package/src/Graph/common/timeSeries/index.test.ts +1 -1
- package/src/Graph/common/timeSeries/index.ts +56 -29
- package/src/Graph/common/timeSeries/models.ts +2 -0
- package/src/Graph/common/utils.ts +51 -3
- package/src/Graph/index.ts +4 -1
- package/src/Graph/mockedData/lastDayWithNullValues.json +6 -6
- package/src/Graph/mockedData/pingServiceLinesBars.json +47 -47
- package/src/Icon/DowntimeIcon.tsx +8 -1
- package/src/Icon/FlappingIcon.tsx +22 -0
- package/src/Icon/index.ts +1 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +21 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +2 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +52 -15
- package/src/InputField/Select/Autocomplete/Multi/index.stories.tsx +19 -0
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +8 -5
- package/src/InputField/Select/Autocomplete/index.tsx +79 -54
- package/src/InputField/Text/index.tsx +6 -4
- package/src/InputField/translatedLabels.ts +2 -0
- package/src/Listing/ActionBar/index.tsx +1 -1
- package/src/Listing/Listing.styles.ts +3 -3
- package/src/Listing/index.tsx +40 -37
- package/src/Listing/models.ts +0 -8
- package/src/Listing/useStyleTable.ts +58 -32
- package/src/MultiSelectEntries/index.tsx +2 -0
- package/src/PopoverMenu/index.tsx +2 -9
- package/src/SortableItems/index.tsx +0 -1
- package/src/ThemeProvider/index.tsx +1 -1
- package/src/ThemeProvider/palettes.ts +6 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +2 -3
- package/src/TimePeriods/DateTimePickerInput.tsx +3 -1
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +7 -1
- package/src/api/buildListingEndpoint/models.ts +1 -0
- package/src/api/customFetch.ts +4 -1
- package/src/api/models.ts +9 -0
- package/src/api/useGraphQuery/index.ts +117 -20
- package/src/api/useGraphQuery/models.ts +1 -0
- package/src/api/useMutationQuery/index.ts +1 -1
- package/src/components/DataTable/DataTable.styles.ts +1 -1
- package/src/components/DataTable/EmptyState/DataTableEmptyState.styles.ts +2 -1
- package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +4 -1
- package/src/components/DataTable/Item/DataTableItem.styles.ts +28 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +19 -4
- package/src/components/Form/FormActions.tsx +21 -12
- package/src/components/Layout/AreaIndicator.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +2 -7
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
- package/src/components/Zoom/Zoom.tsx +9 -2
- package/src/components/Zoom/ZoomContent.tsx +143 -136
- package/src/components/Zoom/models.ts +18 -15
- package/src/components/Zoom/useMinimap.ts +5 -8
- package/src/components/Zoom/useZoom.ts +3 -3
- package/src/index.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/useLocale/index.ts +9 -0
- package/src/utils/useLocale/useLocale.cypress.spec.tsx +38 -0
- package/src/utils/useLocaleDateTimeFormat/index.ts +4 -2
- package/src/utils/usePluralizedTranslation.ts +2 -3
- package/src/Graph/common/timeSeries/index.test.ts-E +0 -622
- package/src/components/CrudPage/Actions/Actions.styles.ts +0 -16
- package/src/components/CrudPage/Actions/Actions.tsx +0 -24
- package/src/components/CrudPage/Actions/AddButton.tsx +0 -23
- package/src/components/CrudPage/Actions/Filters.tsx +0 -25
- package/src/components/CrudPage/Actions/Search.tsx +0 -31
- package/src/components/CrudPage/Actions/useSearch.tsx +0 -24
- package/src/components/CrudPage/Columns/Actions.tsx +0 -88
- package/src/components/CrudPage/CrudPage.cypress.spec.tsx +0 -559
- package/src/components/CrudPage/CrudPage.stories.tsx +0 -278
- package/src/components/CrudPage/CrudPageRoot.tsx +0 -142
- package/src/components/CrudPage/DeleteModal.tsx +0 -77
- package/src/components/CrudPage/Form/AddModal.tsx +0 -35
- package/src/components/CrudPage/Form/Buttons.tsx +0 -98
- package/src/components/CrudPage/Form/UpdateModal.tsx +0 -60
- package/src/components/CrudPage/Listing.tsx +0 -63
- package/src/components/CrudPage/atoms.ts +0 -30
- package/src/components/CrudPage/hooks/useDeleteItem.ts +0 -53
- package/src/components/CrudPage/hooks/useGetItem.ts +0 -36
- package/src/components/CrudPage/hooks/useGetItems.ts +0 -67
- package/src/components/CrudPage/hooks/useListingQueryKey.ts +0 -31
- package/src/components/CrudPage/index.tsx +0 -7
- package/src/components/CrudPage/models.ts +0 -118
- package/src/components/CrudPage/utils.ts +0 -4
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
|
|
2
|
-
import { ColumnType } from '../../../';
|
|
3
|
-
import { MemoizedListing } from '../../Listing';
|
|
4
|
-
import Actions from './Actions/Actions';
|
|
5
|
-
import ColumnActions from './Columns/Actions';
|
|
6
|
-
import {
|
|
7
|
-
changeSortAtom,
|
|
8
|
-
limitAtom,
|
|
9
|
-
pageAtom,
|
|
10
|
-
sortFieldAtom,
|
|
11
|
-
sortOrderAtom
|
|
12
|
-
} from './atoms';
|
|
13
|
-
import { ListingProps } from './models';
|
|
14
|
-
|
|
15
|
-
const Listing = <TData extends { id: number; name: string }>({
|
|
16
|
-
rows,
|
|
17
|
-
total,
|
|
18
|
-
isLoading,
|
|
19
|
-
columns,
|
|
20
|
-
subItems,
|
|
21
|
-
labels,
|
|
22
|
-
filters
|
|
23
|
-
}: ListingProps<TData> & {
|
|
24
|
-
labels: {
|
|
25
|
-
search: string;
|
|
26
|
-
add: string;
|
|
27
|
-
};
|
|
28
|
-
}): JSX.Element => {
|
|
29
|
-
const [page, setPage] = useAtom(pageAtom);
|
|
30
|
-
const [limit, setLimit] = useAtom(limitAtom);
|
|
31
|
-
const sortOrder = useAtomValue(sortOrderAtom);
|
|
32
|
-
const sortField = useAtomValue(sortFieldAtom);
|
|
33
|
-
const changeSort = useSetAtom(changeSortAtom);
|
|
34
|
-
|
|
35
|
-
const listingColumns = columns.concat({
|
|
36
|
-
type: ColumnType.component,
|
|
37
|
-
id: 'actions',
|
|
38
|
-
label: '',
|
|
39
|
-
Component: ColumnActions,
|
|
40
|
-
width: 'min-content',
|
|
41
|
-
clickable: true
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<MemoizedListing
|
|
46
|
-
actions={<Actions labels={labels} filters={filters} />}
|
|
47
|
-
columns={listingColumns}
|
|
48
|
-
subItems={subItems}
|
|
49
|
-
loading={isLoading}
|
|
50
|
-
rows={rows}
|
|
51
|
-
currentPage={page}
|
|
52
|
-
onPaginate={setPage}
|
|
53
|
-
limit={limit}
|
|
54
|
-
onLimitChange={setLimit}
|
|
55
|
-
totalRows={total}
|
|
56
|
-
sortField={sortField}
|
|
57
|
-
sortOrder={sortOrder}
|
|
58
|
-
onSort={changeSort}
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default Listing;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { atom } from 'jotai';
|
|
2
|
-
import { ItemToDelete } from './models';
|
|
3
|
-
|
|
4
|
-
export const pageAtom = atom(0);
|
|
5
|
-
export const limitAtom = atom(10);
|
|
6
|
-
export const searchAtom = atom('');
|
|
7
|
-
export const sortOrderAtom = atom('asc');
|
|
8
|
-
export const sortFieldAtom = atom('name');
|
|
9
|
-
export const openFormModalAtom = atom<number | 'add' | null>(null);
|
|
10
|
-
export const itemToDeleteAtom = atom<ItemToDelete | null>(null);
|
|
11
|
-
export const canDeleteSubItemsAtom = atom<boolean | undefined>(true);
|
|
12
|
-
export const formLabelButtonsAtom = atom({
|
|
13
|
-
add: {
|
|
14
|
-
cancel: 'Cancel',
|
|
15
|
-
confirm: 'Save'
|
|
16
|
-
},
|
|
17
|
-
update: {
|
|
18
|
-
cancel: 'Cancel',
|
|
19
|
-
confirm: 'Save'
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
export const askBeforeCloseFormModalAtom = atom(false);
|
|
23
|
-
|
|
24
|
-
export const changeSortAtom = atom(
|
|
25
|
-
null,
|
|
26
|
-
(_get, set, { sortOrder, sortField }) => {
|
|
27
|
-
set(sortOrderAtom, sortOrder);
|
|
28
|
-
set(sortFieldAtom, sortField);
|
|
29
|
-
}
|
|
30
|
-
);
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Method,
|
|
3
|
-
ResponseError,
|
|
4
|
-
useMutationQuery,
|
|
5
|
-
useSnackbar
|
|
6
|
-
} from '@centreon/ui';
|
|
7
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
8
|
-
import { ReactElement } from 'react';
|
|
9
|
-
import { ItemToDelete } from '../models';
|
|
10
|
-
import { isAFunction } from '../utils';
|
|
11
|
-
|
|
12
|
-
interface UseDeleteItem {
|
|
13
|
-
isMutating: boolean;
|
|
14
|
-
deleteItem: (item: ItemToDelete) => Promise<object | ResponseError>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface UseDeleteItemProps {
|
|
18
|
-
deleteEndpoint: (item: ItemToDelete) => string;
|
|
19
|
-
listingQueryKey: string;
|
|
20
|
-
successMessage:
|
|
21
|
-
| ((item: ItemToDelete) => string | ReactElement)
|
|
22
|
-
| string
|
|
23
|
-
| ReactElement;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const useDeleteItem = ({
|
|
27
|
-
deleteEndpoint,
|
|
28
|
-
listingQueryKey,
|
|
29
|
-
successMessage
|
|
30
|
-
}: UseDeleteItemProps): UseDeleteItem => {
|
|
31
|
-
const queryClient = useQueryClient();
|
|
32
|
-
|
|
33
|
-
const { showSuccessMessage } = useSnackbar();
|
|
34
|
-
|
|
35
|
-
const { mutateAsync, isMutating } = useMutationQuery<object, ItemToDelete>({
|
|
36
|
-
getEndpoint: (_meta) => deleteEndpoint(_meta),
|
|
37
|
-
method: Method.DELETE,
|
|
38
|
-
onSuccess: (_data, { _meta }) => {
|
|
39
|
-
queryClient.invalidateQueries({ queryKey: [listingQueryKey] });
|
|
40
|
-
showSuccessMessage(
|
|
41
|
-
isAFunction(successMessage) ? successMessage(_meta) : successMessage
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const deleteItem = (item: ItemToDelete): Promise<object | ResponseError> =>
|
|
47
|
-
mutateAsync({ _meta: item });
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
isMutating,
|
|
51
|
-
deleteItem
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { equals, isNotNil } from 'ramda';
|
|
2
|
-
import { useFetchQuery } from '../../..';
|
|
3
|
-
import { GetItem } from '../models';
|
|
4
|
-
|
|
5
|
-
interface UseGetItem<TItemForm> {
|
|
6
|
-
initialValues?: TItemForm;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const useGetItem = <
|
|
11
|
-
TItem extends { id: number; name: string },
|
|
12
|
-
TItemForm
|
|
13
|
-
>({
|
|
14
|
-
id,
|
|
15
|
-
decoder,
|
|
16
|
-
baseEndpoint,
|
|
17
|
-
itemQueryKey,
|
|
18
|
-
adapter
|
|
19
|
-
}: GetItem<TItem, TItemForm> & {
|
|
20
|
-
id: number | 'add' | null;
|
|
21
|
-
}): UseGetItem<TItemForm> => {
|
|
22
|
-
const { data, isLoading } = useFetchQuery<TItem>({
|
|
23
|
-
getEndpoint: () => baseEndpoint(id),
|
|
24
|
-
getQueryKey: () => [itemQueryKey, id],
|
|
25
|
-
decoder,
|
|
26
|
-
queryOptions: {
|
|
27
|
-
enabled: isNotNil(id) && !equals('add', id),
|
|
28
|
-
suspense: false
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
initialValues: data ? adapter(data) : undefined,
|
|
34
|
-
isLoading
|
|
35
|
-
};
|
|
36
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { useAtomValue } from 'jotai';
|
|
2
|
-
import { isEmpty } from 'ramda';
|
|
3
|
-
import { ListingModel, buildListingEndpoint } from '../../..';
|
|
4
|
-
import useFetchQuery from '../../../api/useFetchQuery';
|
|
5
|
-
import {
|
|
6
|
-
limitAtom,
|
|
7
|
-
pageAtom,
|
|
8
|
-
searchAtom,
|
|
9
|
-
sortFieldAtom,
|
|
10
|
-
sortOrderAtom
|
|
11
|
-
} from '../atoms';
|
|
12
|
-
import { UseGetItemsProps, UseGetItemsState } from '../models';
|
|
13
|
-
import { useListingQueryKey } from './useListingQueryKey';
|
|
14
|
-
|
|
15
|
-
export const useGetItems = <TData, TFilters>({
|
|
16
|
-
queryKeyName,
|
|
17
|
-
filtersAtom,
|
|
18
|
-
decoder,
|
|
19
|
-
getSearchParameters,
|
|
20
|
-
baseEndpoint
|
|
21
|
-
}: UseGetItemsProps<TData, TFilters>): UseGetItemsState<TData> => {
|
|
22
|
-
const queryKey = useListingQueryKey({ queryKeyName, filtersAtom });
|
|
23
|
-
|
|
24
|
-
const page = useAtomValue(pageAtom);
|
|
25
|
-
const limit = useAtomValue(limitAtom);
|
|
26
|
-
const search = useAtomValue(searchAtom);
|
|
27
|
-
const sortOrder = useAtomValue(sortOrderAtom);
|
|
28
|
-
const sortField = useAtomValue(sortFieldAtom);
|
|
29
|
-
const filters = useAtomValue(filtersAtom);
|
|
30
|
-
|
|
31
|
-
const { data, isLoading } = useFetchQuery<ListingModel<TData>>({
|
|
32
|
-
decoder,
|
|
33
|
-
getQueryKey: () => queryKey,
|
|
34
|
-
getEndpoint: () =>
|
|
35
|
-
buildListingEndpoint({
|
|
36
|
-
baseEndpoint,
|
|
37
|
-
parameters: {
|
|
38
|
-
page: page + 1,
|
|
39
|
-
limit,
|
|
40
|
-
sort: {
|
|
41
|
-
[sortField]: sortOrder
|
|
42
|
-
},
|
|
43
|
-
search: {
|
|
44
|
-
regex: {
|
|
45
|
-
fields: ['name'],
|
|
46
|
-
value: search
|
|
47
|
-
},
|
|
48
|
-
...getSearchParameters({ filters, search })
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}),
|
|
52
|
-
queryOptions: {
|
|
53
|
-
suspense: false
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const items = data?.result || [];
|
|
58
|
-
const hasItems = !!data;
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
items,
|
|
62
|
-
isDataEmpty: isEmpty(items),
|
|
63
|
-
hasItems,
|
|
64
|
-
isLoading,
|
|
65
|
-
total: data?.meta.total || 0
|
|
66
|
-
};
|
|
67
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useAtomValue } from 'jotai';
|
|
2
|
-
import {
|
|
3
|
-
limitAtom,
|
|
4
|
-
pageAtom,
|
|
5
|
-
searchAtom,
|
|
6
|
-
sortFieldAtom,
|
|
7
|
-
sortOrderAtom
|
|
8
|
-
} from '../atoms';
|
|
9
|
-
import { UseListingQueryKeyProps } from '../models';
|
|
10
|
-
|
|
11
|
-
export const useListingQueryKey = <TFilter>({
|
|
12
|
-
filtersAtom,
|
|
13
|
-
queryKeyName
|
|
14
|
-
}: UseListingQueryKeyProps<TFilter>): Array<string | number> => {
|
|
15
|
-
const page = useAtomValue(pageAtom);
|
|
16
|
-
const limit = useAtomValue(limitAtom);
|
|
17
|
-
const search = useAtomValue(searchAtom);
|
|
18
|
-
const sortOrder = useAtomValue(sortOrderAtom);
|
|
19
|
-
const sortField = useAtomValue(sortFieldAtom);
|
|
20
|
-
const filters = useAtomValue(filtersAtom);
|
|
21
|
-
|
|
22
|
-
return [
|
|
23
|
-
queryKeyName,
|
|
24
|
-
limit,
|
|
25
|
-
page,
|
|
26
|
-
search,
|
|
27
|
-
sortField,
|
|
28
|
-
sortOrder,
|
|
29
|
-
JSON.stringify(filters)
|
|
30
|
-
];
|
|
31
|
-
};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { PrimitiveAtom } from 'jotai';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { JsonDecoder } from 'ts.data.json';
|
|
4
|
-
import { Column, ListingModel, SearchParameter } from '../../..';
|
|
5
|
-
import { ListingSubItems } from '../../Listing/models';
|
|
6
|
-
|
|
7
|
-
interface CrudPageRootLabels {
|
|
8
|
-
title: string;
|
|
9
|
-
welcome: {
|
|
10
|
-
title: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
};
|
|
13
|
-
actions: {
|
|
14
|
-
create: string;
|
|
15
|
-
};
|
|
16
|
-
listing: {
|
|
17
|
-
search: string;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface UseListingQueryKeyProps<TFilters> {
|
|
22
|
-
queryKeyName: string;
|
|
23
|
-
filtersAtom: PrimitiveAtom<TFilters>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface UseGetItemsProps<TData, TFilters> {
|
|
27
|
-
queryKeyName: string;
|
|
28
|
-
filtersAtom: PrimitiveAtom<TFilters>;
|
|
29
|
-
decoder?: JsonDecoder.Decoder<ListingModel<TData>>;
|
|
30
|
-
baseEndpoint: string;
|
|
31
|
-
getSearchParameters: ({
|
|
32
|
-
search,
|
|
33
|
-
filters
|
|
34
|
-
}: { search: string; filters: TFilters }) => SearchParameter;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface UseGetItemsState<TData> {
|
|
38
|
-
items: Array<TData>;
|
|
39
|
-
hasItems: boolean;
|
|
40
|
-
isDataEmpty: boolean;
|
|
41
|
-
isLoading: boolean;
|
|
42
|
-
total: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface DeleteItem {
|
|
46
|
-
deleteEndpoint: (item: ItemToDelete) => string;
|
|
47
|
-
modalSize?: 'small' | 'medium' | 'large' | 'xlarge';
|
|
48
|
-
labels: {
|
|
49
|
-
successMessage:
|
|
50
|
-
| ((item: ItemToDelete) => string | ReactElement)
|
|
51
|
-
| string
|
|
52
|
-
| ReactElement;
|
|
53
|
-
title:
|
|
54
|
-
| ((item: ItemToDelete) => string | ReactElement)
|
|
55
|
-
| string
|
|
56
|
-
| ReactElement;
|
|
57
|
-
description:
|
|
58
|
-
| ((item: ItemToDelete) => string | ReactElement)
|
|
59
|
-
| string
|
|
60
|
-
| ReactElement;
|
|
61
|
-
cancel: string;
|
|
62
|
-
confirm: string;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface GetItem<TItem, TItemForm> {
|
|
67
|
-
baseEndpoint: (id: number) => string;
|
|
68
|
-
decoder?: JsonDecoder.Decoder<TItem>;
|
|
69
|
-
adapter: (item: TItem) => TItemForm;
|
|
70
|
-
itemQueryKey: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface Form<TItem, TItemForm> {
|
|
74
|
-
Form: (props: {
|
|
75
|
-
Buttons: () => JSX.Element;
|
|
76
|
-
initialValues?: TItemForm;
|
|
77
|
-
isLoading?: boolean;
|
|
78
|
-
}) => JSX.Element;
|
|
79
|
-
getItem: GetItem<TItem, TItemForm>;
|
|
80
|
-
modalSize?: 'small' | 'medium' | 'large' | 'xlarge';
|
|
81
|
-
labels: {
|
|
82
|
-
add: {
|
|
83
|
-
title: string;
|
|
84
|
-
cancel: string;
|
|
85
|
-
confirm: string;
|
|
86
|
-
};
|
|
87
|
-
update: {
|
|
88
|
-
title: string;
|
|
89
|
-
cancel: string;
|
|
90
|
-
confirm: string;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface ListingProps<TData> {
|
|
96
|
-
rows: Array<TData>;
|
|
97
|
-
total: number;
|
|
98
|
-
isLoading: boolean;
|
|
99
|
-
columns: Array<Column>;
|
|
100
|
-
subItems?: ListingSubItems & {
|
|
101
|
-
canDeleteSubItems?: boolean;
|
|
102
|
-
};
|
|
103
|
-
filters: JSX.Element;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface ItemToDelete {
|
|
107
|
-
id: number;
|
|
108
|
-
name: string;
|
|
109
|
-
parent?: { id: number; name: string };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface CrudPageRootProps<TData, TFilters, TItem, TItemForm>
|
|
113
|
-
extends UseGetItemsProps<TData, TFilters>,
|
|
114
|
-
Omit<ListingProps<TData>, 'rows' | 'total' | 'isLoading'> {
|
|
115
|
-
form: Form<TItem, TItemForm>;
|
|
116
|
-
labels: CrudPageRootLabels;
|
|
117
|
-
deleteItem: DeleteItem;
|
|
118
|
-
}
|