@centreon/ui 23.10.32-MON-19938-cloud-notifications-fix-search-select-boxes.2 → 23.10.32

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 (92) hide show
  1. package/package.json +2 -12
  2. package/src/Dashboard/DashboardLayout.stories.tsx +5 -3
  3. package/src/Dashboard/Layout.tsx +4 -4
  4. package/src/Dashboard/utils.ts +28 -28
  5. package/src/Form/Inputs/ConnectedAutocomplete.tsx +3 -13
  6. package/src/Form/Inputs/models.ts +0 -13
  7. package/src/InputField/Select/Autocomplete/Connected/index.tsx +0 -10
  8. package/src/ThemeProvider/index.tsx +5 -6
  9. package/src/ThemeProvider/palettes.ts +215 -389
  10. package/src/api/TestQueryProvider.tsx +1 -2
  11. package/src/api/useFetchQuery/index.ts +7 -8
  12. package/src/api/useMutationQuery/index.ts +10 -11
  13. package/src/components/Button/Button.styles.ts +3 -17
  14. package/src/components/Button/Button.tsx +3 -6
  15. package/src/components/Button/Icon/IconButton.styles.ts +2 -9
  16. package/src/components/DataTable/DataTable.stories.tsx +0 -9
  17. package/src/components/DataTable/DataTable.styles.ts +0 -5
  18. package/src/components/DataTable/DataTable.tsx +6 -8
  19. package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +1 -4
  20. package/src/components/DataTable/Item/DataTableItem.styles.ts +2 -5
  21. package/src/components/DataTable/Item/DataTableItem.tsx +18 -36
  22. package/src/components/Header/Header.stories.tsx +27 -0
  23. package/src/components/Header/Header.styles.ts +27 -0
  24. package/src/components/Header/Header.tsx +23 -0
  25. package/src/components/Header/index.ts +1 -1
  26. package/src/components/Modal/index.ts +0 -2
  27. package/src/components/index.ts +0 -3
  28. package/src/index.ts +2 -0
  29. package/src/layout/TiledListingPage/TiledListingActions.tsx +15 -0
  30. package/src/layout/TiledListingPage/TiledListingContent.tsx +21 -0
  31. package/src/layout/TiledListingPage/TiledListingList.tsx +11 -0
  32. package/src/layout/TiledListingPage/TiledListingPage.styles.ts +16 -0
  33. package/src/layout/TiledListingPage/TiledListingPage.tsx +15 -0
  34. package/src/layout/TiledListingPage/index.ts +4 -0
  35. package/src/screens/dashboard/DashboardsOverview.stories.tsx +102 -110
  36. package/src/utils/index.ts +1 -1
  37. package/src/utils/sanitizedHTML.ts +1 -1
  38. package/test/setupTests.js +1 -1
  39. package/src/base/tokens/README.md +0 -3
  40. package/src/base/tokens/source/$metadata.json +0 -5
  41. package/src/base/tokens/source/base.json +0 -142
  42. package/src/base/tokens/themes/base.tokens.d.ts +0 -38
  43. package/src/base/tokens/themes/base.tokens.json +0 -695
  44. package/src/base/tokens/themes/base.tokens.ts +0 -38
  45. package/src/base/tokens/themes/ui-dark.tokens.d.ts +0 -38
  46. package/src/base/tokens/themes/ui-dark.tokens.json +0 -695
  47. package/src/base/tokens/themes/ui-dark.tokens.ts +0 -38
  48. package/src/base/tokens/themes/ui-light.tokens.d.ts +0 -38
  49. package/src/base/tokens/themes/ui-light.tokens.json +0 -695
  50. package/src/base/tokens/themes/ui-light.tokens.ts +0 -38
  51. package/src/components/Header/PageHeader/PageHeader.stories.tsx +0 -88
  52. package/src/components/Header/PageHeader/PageHeader.styles.ts +0 -99
  53. package/src/components/Header/PageHeader/PageHeader.tsx +0 -15
  54. package/src/components/Header/PageHeader/PageHeaderActions.tsx +0 -17
  55. package/src/components/Header/PageHeader/PageHeaderMain.tsx +0 -15
  56. package/src/components/Header/PageHeader/PageHeaderMenu.tsx +0 -15
  57. package/src/components/Header/PageHeader/PageHeaderTitle.tsx +0 -47
  58. package/src/components/Header/PageHeader/index.ts +0 -12
  59. package/src/components/Layout/AreaIndicator.styles.ts +0 -33
  60. package/src/components/Layout/AreaIndicator.tsx +0 -35
  61. package/src/components/Layout/PageLayout/PageLayout.stories.tsx +0 -81
  62. package/src/components/Layout/PageLayout/PageLayout.styles.ts +0 -40
  63. package/src/components/Layout/PageLayout/PageLayout.tsx +0 -21
  64. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -15
  65. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -24
  66. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +0 -15
  67. package/src/components/Layout/PageLayout/index.ts +0 -10
  68. package/src/components/Layout/index.ts +0 -1
  69. package/src/components/Menu/Button/MenuButton.stories.tsx +0 -16
  70. package/src/components/Menu/Button/MenuButton.styles.ts +0 -27
  71. package/src/components/Menu/Button/MenuButton.tsx +0 -62
  72. package/src/components/Menu/Button/index.ts +0 -1
  73. package/src/components/Menu/Menu.stories.tsx +0 -71
  74. package/src/components/Menu/Menu.styles.ts +0 -70
  75. package/src/components/Menu/Menu.tsx +0 -25
  76. package/src/components/Menu/MenuDivider.tsx +0 -13
  77. package/src/components/Menu/MenuItem.tsx +0 -36
  78. package/src/components/Menu/MenuItems.tsx +0 -35
  79. package/src/components/Menu/index.ts +0 -12
  80. package/src/components/Menu/useMenu.tsx +0 -79
  81. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.stories.tsx +0 -70
  82. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.styles.ts +0 -5
  83. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +0 -115
  84. package/src/components/Tooltip/TextOverflowTooltip/index.tsx +0 -1
  85. package/src/components/Tooltip/Tooltip.stories.tsx +0 -41
  86. package/src/components/Tooltip/Tooltip.styles.ts +0 -5
  87. package/src/components/Tooltip/Tooltip.tsx +0 -46
  88. package/src/components/Tooltip/index.ts +0 -1
  89. package/src/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
  90. package/src/styles/tokens/themes/_ui-dark.tokens.json +0 -695
  91. package/src/styles/tokens/themes/_ui-light.tokens.json +0 -695
  92. package/src/utils/useResizeObserver.ts +0 -6
@@ -1,11 +1,7 @@
1
1
  import 'ulog';
2
2
  import { useEffect } from 'react';
3
3
 
4
- import {
5
- useMutation,
6
- UseMutationOptions,
7
- UseMutationResult
8
- } from '@tanstack/react-query';
4
+ import { useMutation } from '@tanstack/react-query';
9
5
  import { JsonDecoder } from 'ts.data.json';
10
6
  import anylogger from 'anylogger';
11
7
  import { includes } from 'ramda';
@@ -21,7 +17,7 @@ export enum Method {
21
17
  PUT = 'PUT'
22
18
  }
23
19
 
24
- export type UseMutationQueryProps<T> = {
20
+ export interface UseMutationQueryProps<T> {
25
21
  catchError?: (props: CatchErrorProps) => void;
26
22
  decoder?: JsonDecoder.Decoder<T>;
27
23
  defaultFailureMessage?: string;
@@ -29,14 +25,16 @@ export type UseMutationQueryProps<T> = {
29
25
  getEndpoint: (payload) => string;
30
26
  httpCodesBypassErrorSnackbar?: Array<number>;
31
27
  method: Method;
32
- } & Omit<UseMutationOptions<T>, 'mutationFn'>;
28
+ }
33
29
 
34
30
  const log = anylogger('API Request');
35
31
 
36
- export type UseMutationQueryState<T> = {
32
+ export interface UseMutationQueryState<T> {
37
33
  isError: boolean;
38
34
  isMutating: boolean;
39
- } & UseMutationResult<T | ResponseError>;
35
+ mutate: (payload) => void;
36
+ mutateAsync: (payload) => Promise<T | ResponseError>;
37
+ }
40
38
 
41
39
  const useMutationQuery = <T extends object>({
42
40
  getEndpoint,
@@ -86,9 +84,10 @@ const useMutationQuery = <T extends object>({
86
84
  }, [queryData.data]);
87
85
 
88
86
  return {
89
- ...queryData,
90
87
  isError: (queryData.data as ResponseError | undefined)?.isError || false,
91
- isMutating: queryData.isLoading
88
+ isMutating: queryData.isLoading,
89
+ mutate: queryData.mutate,
90
+ mutateAsync: queryData.mutateAsync
92
91
  };
93
92
  };
94
93
 
@@ -2,20 +2,9 @@ import { makeStyles } from 'tss-react/mui';
2
2
 
3
3
  const useStyles = makeStyles()((theme) => ({
4
4
  button: {
5
- '&[data-size="medium"]': {
6
- fontSize: '16px',
7
- height: 'unset',
8
- lineHeight: '24px'
9
- },
10
-
11
5
  '&[data-size="small"]': {
12
- '&[data-variant="primary"], &[data-variant="secondary"]': {
13
- paddingLeft: theme.spacing(2),
14
- paddingRight: theme.spacing(2)
15
- },
16
- fontSize: '14px',
17
- height: 'unset',
18
- lineHeight: '22px'
6
+ paddingLeft: theme.spacing(2),
7
+ paddingRight: theme.spacing(2)
19
8
  },
20
9
 
21
10
  '&[data-variant="primary"]:not(:disabled)': {
@@ -34,10 +23,7 @@ const useStyles = makeStyles()((theme) => ({
34
23
 
35
24
  borderColor: theme.palette.primary.main,
36
25
  color: theme.palette.primary.main
37
- },
38
-
39
- textWrap: 'noWrap',
40
- transition: 'unset'
26
+ }
41
27
  }
42
28
  }));
43
29
 
@@ -16,15 +16,13 @@ const muiVariantMap: Record<
16
16
  secondary: 'outlined'
17
17
  };
18
18
 
19
- export type ButtonProps = {
19
+ type ButtonProps = {
20
20
  children: ReactNode;
21
- className?: string;
22
21
  disabled?: boolean;
23
22
  icon?: string | ReactNode;
24
23
  iconVariant?: 'none' | 'start' | 'end';
25
24
  isDanger?: boolean;
26
25
  onClick?: (e) => void;
27
- ref?: React.Ref<HTMLButtonElement>;
28
26
  size?: 'small' | 'medium' | 'large';
29
27
  type?: 'button' | 'submit' | 'reset';
30
28
  variant?: 'primary' | 'secondary' | 'ghost';
@@ -41,10 +39,9 @@ const Button = ({
41
39
  disabled = false,
42
40
  onClick,
43
41
  isDanger = false,
44
- className = '',
45
42
  ...attr
46
43
  }: ButtonProps): ReactElement => {
47
- const { classes, cx } = useStyles();
44
+ const { classes } = useStyles();
48
45
 
49
46
  const MuiOverrideProps = useMemo(
50
47
  () => ({
@@ -57,7 +54,7 @@ const Button = ({
57
54
 
58
55
  return (
59
56
  <MuiButton
60
- className={cx(classes.button, className)}
57
+ className={classes.button}
61
58
  data-icon-variant={iconVariant}
62
59
  data-is-danger={isDanger}
63
60
  data-size={size}
@@ -1,14 +1,7 @@
1
1
  import { makeStyles } from 'tss-react/mui';
2
2
 
3
- const useStyles = makeStyles()((theme) => ({
4
- iconButton: {
5
- '&[data-size="small"]': {
6
- '& > svg, & > .MuiSvgIcon-root': {
7
- fontSize: '1.125rem'
8
- },
9
- padding: theme.spacing(0.75)
10
- }
11
- }
3
+ const useStyles = makeStyles()(() => ({
4
+ iconButton: {}
12
5
  }));
13
6
 
14
7
  export { useStyles };
@@ -40,12 +40,3 @@ export const AsEmptyState: Story = {
40
40
  isEmpty: true
41
41
  }
42
42
  };
43
-
44
- export const withFixedHeightContainer: Story = {
45
- args: { ...Default.args },
46
- render: (args) => (
47
- <div style={{ height: '400px' }}>
48
- <DataTable {...args} />
49
- </div>
50
- )
51
- };
@@ -16,11 +16,6 @@ const useStyles = makeStyles()((theme) => ({
16
16
  width: '100%'
17
17
  },
18
18
  display: 'flex'
19
- },
20
- dataTableScrollContainer: {
21
- // FIXME the global -webkit-scrollbar styles are not optimal for this component in grid variant
22
- height: '100%',
23
- overflowY: 'auto'
24
19
  }
25
20
  }));
26
21
 
@@ -20,14 +20,12 @@ const DataTable = ({
20
20
  const { classes } = useStyles();
21
21
 
22
22
  return (
23
- <div className={classes.dataTableScrollContainer}>
24
- <div
25
- className={classes.dataTable}
26
- data-is-empty={isEmpty}
27
- data-variant={variant}
28
- >
29
- {children}
30
- </div>
23
+ <div
24
+ className={classes.dataTable}
25
+ data-is-empty={isEmpty}
26
+ data-variant={variant}
27
+ >
28
+ {children}
31
29
  </div>
32
30
  );
33
31
  };
@@ -29,10 +29,7 @@ const DataTableEmptyState = ({
29
29
  const { t } = useTranslation();
30
30
 
31
31
  return (
32
- <div
33
- className={classes.dataTableEmptyState}
34
- data-testid="data-table-empty-state"
35
- >
32
+ <div className={classes.dataTableEmptyState}>
36
33
  <MuiTypography variant="h2">{t(labels.title)}</MuiTypography>
37
34
  <div className={classes.actions}>
38
35
  {canCreate && (
@@ -10,13 +10,10 @@ const useStyles = makeStyles()((theme) => ({
10
10
  justifyContent: 'space-between'
11
11
  },
12
12
  '& .MuiCardActions-root': {
13
- '& > span': {
14
- display: 'flex',
15
- gap: theme.spacing(1)
16
- },
17
13
  display: 'flex',
14
+ flexDirection: 'row-reverse',
15
+ gap: theme.spacing(1),
18
16
 
19
- justifyContent: 'space-between',
20
17
  opacity: 0
21
18
  },
22
19
  '&:hover .MuiCardActions-root': {
@@ -7,11 +7,7 @@ import {
7
7
  CardContent as MuiCardContent,
8
8
  Typography as MuiTypography
9
9
  } from '@mui/material';
10
- import {
11
- Delete as DeleteIcon,
12
- Settings as SettingsIcon,
13
- Share as ShareIcon
14
- } from '@mui/icons-material';
10
+ import { Delete as DeleteIcon, Edit as EditIcon } from '@mui/icons-material';
15
11
 
16
12
  import { IconButton } from '../../Button';
17
13
 
@@ -24,7 +20,6 @@ export interface DataTableItemProps {
24
20
  onClick?: () => void;
25
21
  onDelete?: () => void;
26
22
  onEdit?: () => void;
27
- onEditAccessRights?: () => void;
28
23
  title: string;
29
24
  }
30
25
 
@@ -37,8 +32,7 @@ const DataTableItem = forwardRef(
37
32
  hasActions = false,
38
33
  onClick,
39
34
  onEdit,
40
- onDelete,
41
- onEditAccessRights
35
+ onDelete
42
36
  }: DataTableItemProps,
43
37
  ref
44
38
  ): ReactElement => {
@@ -64,34 +58,22 @@ const DataTableItem = forwardRef(
64
58
  </ActionArea>
65
59
  {hasActions && (
66
60
  <MuiCardActions>
67
- <span>
68
- <IconButton
69
- aria-label="delete"
70
- data-testid="delete"
71
- icon={<DeleteIcon />}
72
- size="small"
73
- variant="ghost"
74
- onClick={() => onDelete?.()}
75
- />
76
- </span>
77
- <span>
78
- <IconButton
79
- aria-label="edit access rights"
80
- data-testid="edit-access-rights"
81
- icon={<ShareIcon />}
82
- size="small"
83
- variant="primary"
84
- onClick={() => onEditAccessRights?.()}
85
- />
86
- <IconButton
87
- aria-label="edit"
88
- data-testid="edit"
89
- icon={<SettingsIcon />}
90
- size="small"
91
- variant="primary"
92
- onClick={() => onEdit?.()}
93
- />
94
- </span>
61
+ <IconButton
62
+ aria-label="edit"
63
+ data-testid="edit"
64
+ icon={<EditIcon />}
65
+ size="small"
66
+ variant="primary"
67
+ onClick={() => onEdit?.()}
68
+ />
69
+ <IconButton
70
+ aria-label="delete"
71
+ data-testid="delete"
72
+ icon={<DeleteIcon />}
73
+ size="small"
74
+ variant="ghost"
75
+ onClick={() => onDelete?.()}
76
+ />
95
77
  </MuiCardActions>
96
78
  )}
97
79
  </MuiCard>
@@ -0,0 +1,27 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { Settings as SettingsIcon } from '@mui/icons-material';
4
+
5
+ import { IconButton } from '../Button';
6
+
7
+ import { Header } from './Header';
8
+
9
+ const meta: Meta<typeof Header> = {
10
+ component: Header
11
+ };
12
+
13
+ export default meta;
14
+ type Story = StoryObj<typeof Header>;
15
+
16
+ export const Default: Story = {
17
+ args: {
18
+ title: 'Header'
19
+ }
20
+ };
21
+
22
+ export const WithNav: Story = {
23
+ args: {
24
+ nav: <IconButton icon={<SettingsIcon />} size="small" variant="ghost" />,
25
+ title: 'Header with nav'
26
+ }
27
+ };
@@ -0,0 +1,27 @@
1
+ import { makeStyles } from 'tss-react/mui';
2
+
3
+ const useStyles = makeStyles()((theme) => ({
4
+ header: {
5
+ alignItems: 'flex-start',
6
+ borderBottom: `1px solid ${theme.palette.primary.main}`,
7
+ display: 'flex',
8
+ flexDirection: 'row',
9
+ h1: {
10
+ font: 'normal normal 600 24px/24px Roboto',
11
+ letterSpacing: '0.18px',
12
+ margin: theme.spacing(0, 0, 1.5, 0)
13
+ },
14
+ justifyContent: 'space-between',
15
+ marginBottom: theme.spacing(2.5),
16
+
17
+ nav: {
18
+ display: 'flex',
19
+ gap: theme.spacing(1),
20
+ justifyContent: 'flex-end'
21
+ },
22
+
23
+ padding: theme.spacing(0, 0, 1.5, 0)
24
+ }
25
+ }));
26
+
27
+ export { useStyles };
@@ -0,0 +1,23 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+
3
+ import { Typography as MuiTypography } from '@mui/material';
4
+
5
+ import { useStyles } from './Header.styles';
6
+
7
+ type HeaderProps = {
8
+ nav?: ReactNode;
9
+ title: string;
10
+ };
11
+
12
+ const Header = ({ title, nav }: HeaderProps): ReactElement => {
13
+ const { classes } = useStyles();
14
+
15
+ return (
16
+ <header className={classes.header}>
17
+ <MuiTypography variant="h1">{title}</MuiTypography>
18
+ {nav && <nav>{nav}</nav>}
19
+ </header>
20
+ );
21
+ };
22
+
23
+ export { Header };
@@ -1 +1 @@
1
- export * from './PageHeader';
1
+ export * from './Header';
@@ -8,5 +8,3 @@ export const Modal = Object.assign(ModalRoot, {
8
8
  Body: ModalBody,
9
9
  Header: ModalHeader
10
10
  });
11
-
12
- export type { ModalActionsLabels } from './ModalActions';
@@ -3,6 +3,3 @@ export * from './Modal';
3
3
  export * from './Form';
4
4
  export * from './Header';
5
5
  export * from './DataTable';
6
- export * from './Layout';
7
- export * from './Tooltip';
8
- export * from './Menu';
package/src/index.ts CHANGED
@@ -140,6 +140,8 @@ export { default as ActionsList } from './ActionsList';
140
140
 
141
141
  export type { ResponseError, CatchErrorProps } from './api/customFetch';
142
142
 
143
+ export * from './layout/TiledListingPage';
144
+
143
145
  export * from './utils';
144
146
  export { default as FluidTypography } from './Typography/FluidTypography';
145
147
  export * from './Dashboard';
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ import { useTiledListingActionsStyles } from './TiledListingPage.styles';
4
+
5
+ interface TiledListingActionsProps {
6
+ children: Array<ReactNode> | ReactNode;
7
+ }
8
+
9
+ export const TiledListingActions = ({
10
+ children
11
+ }: TiledListingActionsProps): JSX.Element => {
12
+ const { classes } = useTiledListingActionsStyles();
13
+
14
+ return <div className={classes.actions}>{children}</div>;
15
+ };
@@ -0,0 +1,21 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ import Responsive from '../../Responsive';
4
+
5
+ import { useTiledListingActionsStyles } from './TiledListingPage.styles';
6
+
7
+ interface TiledListingContentProps {
8
+ children: ReactNode;
9
+ }
10
+
11
+ export const TiledListingContent = ({
12
+ children
13
+ }: TiledListingContentProps): JSX.Element => {
14
+ const { classes } = useTiledListingActionsStyles();
15
+
16
+ return (
17
+ <Responsive>
18
+ <div className={classes.actions}>{children}</div>
19
+ </Responsive>
20
+ );
21
+ };
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ interface TiledListingListProps {
4
+ children: Array<ReactNode>;
5
+ }
6
+
7
+ export const TiledListingList = ({
8
+ children
9
+ }: TiledListingListProps): JSX.Element => {
10
+ return <div>{children}</div>;
11
+ };
@@ -0,0 +1,16 @@
1
+ import { makeStyles } from 'tss-react/mui';
2
+
3
+ export const useTiledListPageStyles = makeStyles()((theme) => ({
4
+ listPage: {
5
+ display: 'flex',
6
+ flexDirection: 'column',
7
+ height: '100%',
8
+ padding: theme.spacing(1.5)
9
+ }
10
+ }));
11
+
12
+ export const useTiledListingActionsStyles = makeStyles()((theme) => ({
13
+ actions: {
14
+ paddingBottom: theme.spacing(2.5)
15
+ }
16
+ }));
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ import { useTiledListPageStyles } from './TiledListingPage.styles';
4
+
5
+ interface TiledListingPageProps {
6
+ children: Array<ReactNode>;
7
+ }
8
+
9
+ export const TiledListingPage = ({
10
+ children
11
+ }: TiledListingPageProps): JSX.Element => {
12
+ const { classes } = useTiledListPageStyles();
13
+
14
+ return <div className={classes.listPage}>{children}</div>;
15
+ };
@@ -0,0 +1,4 @@
1
+ export * from './TiledListingPage';
2
+ export * from './TiledListingActions';
3
+ export * from './TiledListingList';
4
+ export * from './TiledListingContent';