@centreon/ui 24.11.0 → 24.11.2

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.
Files changed (70) hide show
  1. package/package.json +3 -2
  2. package/src/Dashboard/Dashboard.styles.ts +3 -4
  3. package/src/Dashboard/DashboardLayout.stories.tsx +1 -1
  4. package/src/Dashboard/Grid.tsx +11 -17
  5. package/src/Dashboard/Layout.tsx +27 -56
  6. package/src/FileDropZone/index.tsx +23 -21
  7. package/src/Form/CollapsibleGroup.tsx +2 -3
  8. package/src/Form/Form.cypress.spec.tsx +0 -39
  9. package/src/Form/Form.tsx +0 -1
  10. package/src/Form/Inputs/Autocomplete.tsx +4 -27
  11. package/src/Form/Inputs/ConnectedAutocomplete.tsx +10 -20
  12. package/src/Form/Inputs/Grid.tsx +2 -30
  13. package/src/Form/Inputs/Radio.tsx +4 -12
  14. package/src/Form/Inputs/Switch.tsx +2 -10
  15. package/src/Form/Inputs/Text.tsx +4 -13
  16. package/src/Form/Inputs/index.tsx +2 -5
  17. package/src/Form/Inputs/models.ts +2 -18
  18. package/src/Form/storiesData.tsx +3 -15
  19. package/src/Form/translatedLabels.ts +0 -1
  20. package/src/Graph/BarChart/BarChart.tsx +1 -4
  21. package/src/Graph/BarChart/ResponsiveBarChart.tsx +2 -3
  22. package/src/Graph/Chart/Chart.tsx +2 -9
  23. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +2 -2
  24. package/src/Graph/Chart/InteractiveComponents/index.tsx +2 -10
  25. package/src/Graph/Chart/helpers/index.ts +5 -5
  26. package/src/Graph/Chart/index.tsx +0 -7
  27. package/src/Graph/Chart/models.ts +0 -1
  28. package/src/InputField/Text/index.tsx +1 -1
  29. package/src/Listing/index.tsx +27 -39
  30. package/src/Listing/models.ts +0 -8
  31. package/src/MultiSelectEntries/index.tsx +2 -0
  32. package/src/PopoverMenu/index.tsx +2 -9
  33. package/src/SortableItems/index.tsx +0 -1
  34. package/src/ThemeProvider/index.tsx +1 -1
  35. package/src/ThemeProvider/palettes.ts +4 -4
  36. package/src/components/DataTable/DataTable.cypress.spec.tsx +1 -2
  37. package/src/components/DataTable/DataTable.stories.tsx +0 -17
  38. package/src/components/DataTable/EmptyState/DataTableEmptyState.styles.ts +1 -3
  39. package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +0 -6
  40. package/src/components/Layout/AreaIndicator.tsx +1 -1
  41. package/src/components/Layout/PageLayout/PageLayout.styles.ts +2 -7
  42. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
  43. package/src/components/Modal/Modal.styles.ts +1 -1
  44. package/src/components/Zoom/Zoom.tsx +2 -2
  45. package/src/components/Zoom/ZoomContent.tsx +2 -2
  46. package/src/components/index.ts +0 -1
  47. package/src/Form/Inputs/File.tsx +0 -69
  48. package/src/components/CrudPage/Actions/Actions.styles.ts +0 -16
  49. package/src/components/CrudPage/Actions/Actions.tsx +0 -24
  50. package/src/components/CrudPage/Actions/AddButton.tsx +0 -23
  51. package/src/components/CrudPage/Actions/Filters.tsx +0 -25
  52. package/src/components/CrudPage/Actions/Search.tsx +0 -31
  53. package/src/components/CrudPage/Actions/useSearch.tsx +0 -24
  54. package/src/components/CrudPage/Columns/Actions.tsx +0 -88
  55. package/src/components/CrudPage/CrudPage.cypress.spec.tsx +0 -559
  56. package/src/components/CrudPage/CrudPage.stories.tsx +0 -278
  57. package/src/components/CrudPage/CrudPageRoot.tsx +0 -142
  58. package/src/components/CrudPage/DeleteModal.tsx +0 -77
  59. package/src/components/CrudPage/Form/AddModal.tsx +0 -35
  60. package/src/components/CrudPage/Form/Buttons.tsx +0 -98
  61. package/src/components/CrudPage/Form/UpdateModal.tsx +0 -60
  62. package/src/components/CrudPage/Listing.tsx +0 -63
  63. package/src/components/CrudPage/atoms.ts +0 -30
  64. package/src/components/CrudPage/hooks/useDeleteItem.ts +0 -53
  65. package/src/components/CrudPage/hooks/useGetItem.ts +0 -36
  66. package/src/components/CrudPage/hooks/useGetItems.ts +0 -67
  67. package/src/components/CrudPage/hooks/useListingQueryKey.ts +0 -31
  68. package/src/components/CrudPage/index.tsx +0 -7
  69. package/src/components/CrudPage/models.ts +0 -118
  70. package/src/components/CrudPage/utils.ts +0 -4
@@ -16,7 +16,6 @@ type ListEmptyStateProps = {
16
16
  create: string;
17
17
  };
18
18
  title: string;
19
- description?: string;
20
19
  };
21
20
  onCreate?: () => void;
22
21
  };
@@ -35,11 +34,6 @@ const DataTableEmptyState = ({
35
34
  data-testid="data-table-empty-state"
36
35
  >
37
36
  <MuiTypography variant="h2">{t(labels.title)}</MuiTypography>
38
- {labels.description && (
39
- <MuiTypography className={classes.description}>
40
- {t(labels.description)}
41
- </MuiTypography>
42
- )}
43
37
  <div className={classes.actions}>
44
38
  {canCreate && (
45
39
  <Button
@@ -25,7 +25,7 @@ const AreaIndicator = ({
25
25
  data-depth={depth}
26
26
  style={{ height, width }}
27
27
  >
28
- {/* biome-ignore lint/a11y: */}
28
+ {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
29
29
  <label>{name}</label>
30
30
  {children}
31
31
  </div>
@@ -2,10 +2,8 @@ import { makeStyles } from 'tss-react/mui';
2
2
 
3
3
  export const useStyles = makeStyles()((theme) => ({
4
4
  pageLayout: {
5
- height: '100%',
6
5
  display: 'grid',
7
- gridTemplateRows: 'auto 1fr',
8
- height: '100%',
6
+ gridTemplateRows: 'min-content',
9
7
  overflow: 'hidden'
10
8
  },
11
9
  pageLayoutActions: {
@@ -24,11 +22,8 @@ export const useStyles = makeStyles()((theme) => ({
24
22
  '&[data-has-background="true"]': {
25
23
  backgroundColor: theme.palette.layout.body.background
26
24
  },
27
- '&[data-has-actions="true"]': {
28
- gridTemplateRows: 'min-content auto',
29
- },
30
25
  display: 'grid',
31
- gridTemplateRows: 'auto',
26
+ gridTemplateRows: 'min-content',
32
27
  overflow: 'hidden',
33
28
  padding: theme.spacing(1.5, 3, 5)
34
29
  },
@@ -17,7 +17,6 @@ export const PageLayoutBody = ({
17
17
  <section
18
18
  className={classes.pageLayoutBody}
19
19
  data-has-background={hasBackground}
20
- data-has-actions={!!children?.length}
21
20
  id="page-body"
22
21
  >
23
22
  {children}
@@ -45,7 +45,7 @@ const useStyles = makeStyles<{
45
45
  width: '400px'
46
46
  },
47
47
  '&[data-size="xlarge"] .MuiDialog-paper': {
48
- maxWidth: '900px',
48
+ maxWidth: '1400px',
49
49
  width: 'calc(100% - 64px)'
50
50
  }
51
51
  },
@@ -3,10 +3,10 @@ import { Zoom as VisxZoom } from '@visx/zoom';
3
3
  import { ParentSize } from '../..';
4
4
 
5
5
  import ZoomContent from './ZoomContent';
6
- import type { MinimapPosition } from './models';
6
+ import { MinimapPosition } from './models';
7
7
 
8
8
  export interface ZoomProps {
9
- children: JSX.Element | (({ width, height, transformMatrix }) => JSX.Element);
9
+ children: JSX.Element | (({ width, height }) => JSX.Element);
10
10
  id?: number | string;
11
11
  minimapPosition?: MinimapPosition;
12
12
  scaleMax?: number;
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import { RectClipPath } from '@visx/clip-path';
4
- import type { ProvidedZoom } from '@visx/zoom/lib/types';
4
+ import { ProvidedZoom } from '@visx/zoom/lib/types';
5
5
 
6
6
  import ZoomInIcon from '@mui/icons-material/Add';
7
7
  import ZoomOutIcon from '@mui/icons-material/Remove';
@@ -12,7 +12,7 @@ import { IconButton } from '../Button';
12
12
  import Minimap from './Minimap';
13
13
  import { useZoomStyles } from './Zoom.styles';
14
14
  import { minimapScale, radius } from './constants';
15
- import type { ChildrenProps, MinimapPosition, ZoomState } from './models';
15
+ import { ChildrenProps, MinimapPosition, ZoomState } from './models';
16
16
  import { useZoom } from './useZoom';
17
17
 
18
18
  export interface Props {
@@ -12,6 +12,5 @@ export * from './Avatar';
12
12
  export * from './CollapsibleItem';
13
13
  export * from './Inputs';
14
14
  export { default as Zoom } from './Zoom/Zoom';
15
- export type { ZoomState } from './Zoom/models';
16
15
  export * from './Tabs';
17
16
  export { default as CopyCommand } from './CopyCommand/CopyCommand';
@@ -1,69 +0,0 @@
1
- import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined';
2
- import { Box, Typography } from '@mui/material';
3
- import { FormikValues, useFormikContext } from 'formik';
4
- import { path, split } from 'ramda';
5
- import { useMemo } from 'react';
6
- import { useTranslation } from 'react-i18next';
7
- import FileDropZone, { transformFileListToArray } from '../../FileDropZone';
8
- import { InputPropsWithoutGroup } from './models';
9
-
10
- const File = ({
11
- fieldName,
12
- file,
13
- change,
14
- dataTestId,
15
- label
16
- }: InputPropsWithoutGroup): JSX.Element => {
17
- const { t } = useTranslation();
18
-
19
- const { values, setFieldValue, setFieldTouched } =
20
- useFormikContext<FormikValues>();
21
-
22
- const fieldNamePath = split('.', fieldName);
23
-
24
- const files = useMemo(
25
- () => path(fieldNamePath, values),
26
- [values]
27
- ) as FileList;
28
-
29
- const filesArray = transformFileListToArray(files);
30
-
31
- const changeFiles = (newFiles: FileList | null): void => {
32
- if (change) {
33
- change({ setFieldValue, setFieldTouched, value: newFiles });
34
-
35
- return;
36
- }
37
-
38
- setFieldValue(fieldName, newFiles);
39
- };
40
-
41
- return (
42
- <Box data-testid={dataTestId} aria-label={t(label)}>
43
- <Typography variant="h6">{t(label)}</Typography>
44
- <Box sx={{ display: 'flex', gap: 1, flexDirection: 'column' }}>
45
- <FileDropZone
46
- {...file}
47
- accept={file?.accept || '*'}
48
- files={files || null}
49
- changeFiles={changeFiles}
50
- resetFilesStatusAndUploadData={() => undefined}
51
- label={label}
52
- />
53
- <Box sx={{ display: 'flex', gap: 1, flexDirection: 'column' }}>
54
- {filesArray.map((file) => (
55
- <Box
56
- key={file.name}
57
- sx={{ display: 'flex', gap: 1, flexDirection: 'row' }}
58
- >
59
- <DescriptionOutlinedIcon color="success" fontSize="small" />
60
- <Typography>{file.name}</Typography>
61
- </Box>
62
- ))}
63
- </Box>
64
- </Box>
65
- </Box>
66
- );
67
- };
68
-
69
- export default File;
@@ -1,16 +0,0 @@
1
- import { makeStyles } from 'tss-react/mui';
2
-
3
- export const useActionsStyles = makeStyles()((theme) => ({
4
- search: {
5
- maxWidth: theme.spacing(50)
6
- },
7
- clearButton: {
8
- alignSelf: 'flex-start'
9
- },
10
- tooltipFilters: {
11
- padding: theme.spacing(2, 3),
12
- display: 'flex',
13
- flexDirection: 'column',
14
- gap: theme.spacing(2)
15
- }
16
- }));
@@ -1,24 +0,0 @@
1
- import { Box } from '@mui/material';
2
- import AddButton from './AddButton';
3
- import Search from './Search';
4
-
5
- interface Props {
6
- labels: {
7
- search: string;
8
- add: string;
9
- };
10
- filters: JSX.Element;
11
- }
12
-
13
- const Actions = ({ labels, filters }: Props): JSX.Element => {
14
- return (
15
- <Box
16
- sx={{ display: 'grid', gridTemplateColumns: 'min-content auto', gap: 2 }}
17
- >
18
- <AddButton label={labels.add} />
19
- <Search label={labels.search} filters={filters} />
20
- </Box>
21
- );
22
- };
23
-
24
- export default Actions;
@@ -1,23 +0,0 @@
1
- import { Add } from '@mui/icons-material';
2
- import { useSetAtom } from 'jotai';
3
- import { useCallback } from 'react';
4
- import { Button } from '../../Button';
5
- import { openFormModalAtom } from '../atoms';
6
-
7
- interface Props {
8
- label: string;
9
- }
10
-
11
- const AddButton = ({ label }: Props): JSX.Element => {
12
- const setOpenFormModal = useSetAtom(openFormModalAtom);
13
-
14
- const add = useCallback(() => setOpenFormModal('add'), []);
15
-
16
- return (
17
- <Button size="small" icon={<Add />} iconVariant="start" onClick={add}>
18
- {label}
19
- </Button>
20
- );
21
- };
22
-
23
- export default AddButton;
@@ -1,25 +0,0 @@
1
- import { Tune } from '@mui/icons-material';
2
- import { isValidElement } from 'react';
3
- import PopoverMenu from '../../../PopoverMenu';
4
- import { useActionsStyles } from './Actions.styles';
5
-
6
- interface Props {
7
- label: string;
8
- filters: JSX.Element;
9
- }
10
-
11
- const Filters: React.FC<Props> = ({ label, filters }: Props): JSX.Element => {
12
- const { classes } = useActionsStyles();
13
-
14
- return (
15
- <PopoverMenu
16
- title={label}
17
- icon={<Tune />}
18
- tooltipClassName={classes.tooltipFilters}
19
- >
20
- {isValidElement(filters) ? filters : <div />}
21
- </PopoverMenu>
22
- );
23
- };
24
-
25
- export default Filters;
@@ -1,31 +0,0 @@
1
- import { SearchField } from '@centreon/ui';
2
- import { useActionsStyles } from './Actions.styles';
3
- import Filters from './Filters';
4
- import { useSearch } from './useSearch';
5
-
6
- interface Props {
7
- label: string;
8
- filters: JSX.Element;
9
- }
10
-
11
- const Search = ({ label, filters }: Props): JSX.Element => {
12
- const { classes } = useActionsStyles();
13
-
14
- const { change } = useSearch();
15
-
16
- return (
17
- <SearchField
18
- className={classes.search}
19
- debounced
20
- fullWidth
21
- dataTestId={label}
22
- placeholder={label}
23
- onChange={change}
24
- InputProps={{
25
- endAdornment: <Filters label="filters" filters={filters} />
26
- }}
27
- />
28
- );
29
- };
30
-
31
- export default Search;
@@ -1,24 +0,0 @@
1
- import { useAtom } from 'jotai';
2
- import { ChangeEvent, useCallback, useRef } from 'react';
3
- import { searchAtom } from '../atoms';
4
-
5
- interface UseSearchState {
6
- search: string;
7
- change: (event: ChangeEvent<HTMLInputElement>) => void;
8
- }
9
-
10
- export const useSearch = (): UseSearchState => {
11
- const timeoutRef = useRef<NodeJS.Timeout | null>(null);
12
-
13
- const [search, setSearch] = useAtom(searchAtom);
14
-
15
- const change = useCallback((event: ChangeEvent<HTMLInputElement>): void => {
16
- if (timeoutRef.current) {
17
- clearTimeout(timeoutRef.current);
18
- }
19
-
20
- timeoutRef.current = setTimeout(() => setSearch(event.target.value), 500);
21
- }, []);
22
-
23
- return { search, change };
24
- };
@@ -1,88 +0,0 @@
1
- import { EditOutlined } from '@mui/icons-material';
2
- import DeleteOutline from '@mui/icons-material/DeleteOutline';
3
- import { Box } from '@mui/material';
4
- import { useAtomValue, useSetAtom } from 'jotai';
5
- import { isNil } from 'ramda';
6
- import { useCallback } from 'react';
7
- import { useTranslation } from 'react-i18next';
8
- import { IconButton } from '../../Button';
9
- import {
10
- canDeleteSubItemsAtom,
11
- itemToDeleteAtom,
12
- openFormModalAtom
13
- } from '../atoms';
14
-
15
- interface Props<TData> {
16
- row: TData & {
17
- internalListingParentId?: number;
18
- internalListingParentRow: TData;
19
- };
20
- }
21
-
22
- const labelDelete = 'Delete';
23
- const labelUpdate = 'Update';
24
-
25
- const Actions = <TData extends { id: number; name: string }>({
26
- row
27
- }: Props<TData>): JSX.Element => {
28
- const { t } = useTranslation();
29
- const canDeleteSubItems = useAtomValue(canDeleteSubItemsAtom);
30
- const setItemToDelete = useSetAtom(itemToDeleteAtom);
31
- const setOpenFormModal = useSetAtom(openFormModalAtom);
32
-
33
- const askBeforeDelete = (): void => {
34
- setItemToDelete({
35
- id: row.id,
36
- name: row.name,
37
- parent: isNil(row.internalListingParentRow)
38
- ? undefined
39
- : {
40
- id: row.internalListingParentRow.id,
41
- name: row.internalListingParentRow.name
42
- }
43
- });
44
- };
45
-
46
- const updateRow = useCallback(() => setOpenFormModal(row.id), [row.id]);
47
-
48
- return (
49
- <Box
50
- sx={{
51
- display: 'flex',
52
- flexDirection: 'row',
53
- gap: 1,
54
- width: '100%',
55
- justifyContent: 'flex-end'
56
- }}
57
- >
58
- {isNil(row.internalListingParentRow) && (
59
- <IconButton
60
- size="small"
61
- icon={<EditOutlined fontSize="small" color="primary" />}
62
- onClick={updateRow}
63
- title={t(labelUpdate)}
64
- data-testid={
65
- row.internalListingParentRow
66
- ? `edit-${row.internalListingParentRow.id}-${row.id}`
67
- : `edit-${row.id}`
68
- }
69
- />
70
- )}
71
- {(canDeleteSubItems || isNil(row.internalListingParentRow)) && (
72
- <IconButton
73
- size="small"
74
- icon={<DeleteOutline fontSize="small" color="error" />}
75
- onClick={askBeforeDelete}
76
- title={t(labelDelete)}
77
- data-testid={
78
- row.internalListingParentRow
79
- ? `delete-${row.internalListingParentRow.id}-${row.id}`
80
- : `delete-${row.id}`
81
- }
82
- />
83
- )}
84
- </Box>
85
- );
86
- };
87
-
88
- export default Actions;