@centreon/ui 23.10.94 → 23.10.95

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "23.10.94",
3
+ "version": "23.10.95",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -3,27 +3,37 @@ import { useTranslation } from 'react-i18next';
3
3
  import { equals } from 'ramda';
4
4
 
5
5
  import {
6
- SvgIconProps,
7
6
  MenuList,
8
7
  MenuItem,
9
8
  ListItemText,
10
9
  ListItemIcon,
11
- Divider
10
+ Divider,
11
+ SvgIconTypeMap
12
12
  } from '@mui/material';
13
+ import { OverridableComponent } from '@mui/material/OverridableComponent';
14
+
15
+ import { sanitizedHTML } from '..';
13
16
 
14
17
  import { useStyles } from './ActionsList.styles';
15
18
  import { ActionVariants } from './models';
16
19
 
17
20
  interface ActionsType {
18
- Icon?: (props: SvgIconProps) => JSX.Element;
21
+ Icon?: OverridableComponent<SvgIconTypeMap<object, 'svg'>> & {
22
+ muiName: string;
23
+ };
19
24
  label: string;
20
25
  onClick?: (e?) => void;
21
26
  secondaryLabel?: string;
22
27
  variant?: ActionVariants;
23
28
  }
24
29
 
30
+ export enum ActionsListActionDivider {
31
+ divider = 'divider'
32
+ }
33
+ export type ActionsListActions = Array<ActionsType | ActionsListActionDivider>;
34
+
25
35
  interface Props {
26
- actions: Array<ActionsType | 'divider'>;
36
+ actions: ActionsListActions;
27
37
  className?: string;
28
38
  listItemClassName?: string;
29
39
  }
@@ -39,7 +49,7 @@ const ActionsList = ({
39
49
  return (
40
50
  <MenuList className={cx(classes.list, className)}>
41
51
  {actions?.map((action, idx) => {
42
- if (equals(action, 'divider')) {
52
+ if (equals(action, ActionsListActionDivider.divider)) {
43
53
  return <Divider key={`divider_${idx}`} />;
44
54
  }
45
55
 
@@ -63,7 +73,10 @@ const ActionsList = ({
63
73
  <ListItemText
64
74
  className={listItemClassName}
65
75
  primary={t(label)}
66
- secondary={secondaryLabel && t(secondaryLabel)}
76
+ secondary={
77
+ secondaryLabel &&
78
+ sanitizedHTML({ initialContent: t(secondaryLabel) })
79
+ }
67
80
  />
68
81
  </MenuItem>
69
82
  );
@@ -69,6 +69,9 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
69
69
  export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
70
70
  (theme, { hasHeader }) => ({
71
71
  widgetContainer: {
72
+ '&[data-padding="false"]': {
73
+ padding: 0
74
+ },
72
75
  background: theme.palette.background.widget,
73
76
  border: 'none',
74
77
  borderRadius: theme.spacing(1),
@@ -67,7 +67,10 @@ const Item = forwardRef(
67
67
  width: `calc(${prop('width', style) || '0px'} - 12px)`
68
68
  }}
69
69
  >
70
- <Card className={classes.widgetContainer}>
70
+ <Card
71
+ className={classes.widgetContainer}
72
+ data-padding={!disablePadding}
73
+ >
71
74
  {header && (
72
75
  <div
73
76
  {...listeners}
@@ -14,6 +14,7 @@ import { has, includes, not, omit } from 'ramda';
14
14
 
15
15
  import { CatchErrorProps, customFetch, ResponseError } from '../customFetch';
16
16
  import useSnackbar from '../../Snackbar/useSnackbar';
17
+ import { useDeepCompare } from '../../utils';
17
18
 
18
19
  export interface UseFetchQueryProps<T> {
19
20
  catchError?: (props: CatchErrorProps) => void;
@@ -162,7 +163,7 @@ const useFetchQuery = <T extends object>({
162
163
 
163
164
  useEffect(() => {
164
165
  manageError();
165
- }, [queryData.data]);
166
+ }, useDeepCompare([queryData.data]));
166
167
 
167
168
  return {
168
169
  ...omit(['data'], queryData),
@@ -12,6 +12,7 @@ import { includes } from 'ramda';
12
12
 
13
13
  import { CatchErrorProps, customFetch, ResponseError } from '../customFetch';
14
14
  import useSnackbar from '../../Snackbar/useSnackbar';
15
+ import { useDeepCompare } from '../../utils';
15
16
 
16
17
  export enum Method {
17
18
  DELETE = 'DELETE',
@@ -98,7 +99,7 @@ const useMutationQuery = <T extends object, TMeta>({
98
99
 
99
100
  useEffect(() => {
100
101
  manageError();
101
- }, [queryData.data]);
102
+ }, useDeepCompare([queryData.data]));
102
103
 
103
104
  return {
104
105
  ...queryData,
@@ -14,6 +14,7 @@ import {
14
14
  } from '@mui/icons-material';
15
15
 
16
16
  import { IconButton } from '../../Button';
17
+ import { ConfirmationTooltip } from '../../Tooltip/ConfirmationTooltip';
17
18
 
18
19
  import { useStyles } from './DataTableItem.styles';
19
20
 
@@ -21,6 +22,13 @@ export interface DataTableItemProps {
21
22
  description?: string;
22
23
  hasActions?: boolean;
23
24
  hasCardAction?: boolean;
25
+ labelsDelete: {
26
+ cancel: string;
27
+ confirm: {
28
+ label: string;
29
+ secondaryLabel?: string;
30
+ };
31
+ };
24
32
  onClick?: () => void;
25
33
  onDelete?: () => void;
26
34
  onEdit?: () => void;
@@ -38,7 +46,8 @@ const DataTableItem = forwardRef(
38
46
  onClick,
39
47
  onEdit,
40
48
  onDelete,
41
- onEditAccessRights
49
+ onEditAccessRights,
50
+ labelsDelete
42
51
  }: DataTableItemProps,
43
52
  ref
44
53
  ): ReactElement => {
@@ -67,14 +76,24 @@ const DataTableItem = forwardRef(
67
76
  {hasActions && (
68
77
  <MuiCardActions>
69
78
  <span>
70
- <IconButton
71
- aria-label="delete"
72
- data-testid="delete"
73
- icon={<DeleteIcon />}
74
- size="small"
75
- variant="ghost"
76
- onClick={() => onDelete?.()}
77
- />
79
+ {onDelete && (
80
+ <ConfirmationTooltip
81
+ confirmVariant="error"
82
+ labels={labelsDelete}
83
+ onConfirm={onDelete}
84
+ >
85
+ {(openTooltip) => (
86
+ <IconButton
87
+ aria-label="delete"
88
+ data-testid="delete"
89
+ icon={<DeleteIcon />}
90
+ size="small"
91
+ variant="ghost"
92
+ onClick={openTooltip}
93
+ />
94
+ )}
95
+ </ConfirmationTooltip>
96
+ )}
78
97
  </span>
79
98
  <span>
80
99
  <IconButton
@@ -15,5 +15,8 @@ export const useStyles = makeStyles()((theme) => ({
15
15
  boxShadow: theme.shadows[3],
16
16
  marginLeft: theme.spacing(2),
17
17
  maxWidth: '350px'
18
+ },
19
+ popper: {
20
+ zIndex: theme.zIndex.tooltip + 1
18
21
  }
19
22
  }));
@@ -52,6 +52,7 @@ export const ConfirmationTooltip = ({
52
52
  {children(isOpen ? close : open)}
53
53
  <Popper
54
54
  anchorEl={anchorElement}
55
+ className={classes.popper}
55
56
  open={isOpen}
56
57
  popperOptions={{
57
58
  placement: 'bottom-start'
@@ -0,0 +1 @@
1
+ export * from './ConfirmationTooltip';
@@ -1 +1,2 @@
1
1
  export * from './Tooltip';
2
+ export * from './ConfirmationTooltip';
package/src/index.ts CHANGED
@@ -140,7 +140,12 @@ export * from './TopCounterElements';
140
140
  export { default as Image, ImageVariant } from './Image/Image';
141
141
  export { default as WallpaperPage } from './WallpaperPage';
142
142
  export { RichTextEditor } from './RichTextEditor';
143
- export { default as ActionsList } from './ActionsList';
143
+ export {
144
+ default as ActionsList,
145
+ ActionsListActionDivider
146
+ } from './ActionsList';
147
+ export type { ActionsListActions } from './ActionsList';
148
+ export type { ActionVariants } from './ActionsList/models';
144
149
 
145
150
  export type { ResponseError, CatchErrorProps } from './api/customFetch';
146
151