@centreon/ui 24.4.1-MON-34494-delete-action.2 → 24.4.1-MON-24235-Filter-App-token.19

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": "24.4.1-MON-34494-delete-action.2",
3
+ "version": "24.4.1-MON-24235-Filter-App-token.19",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -1,4 +1,4 @@
1
- import { includes, map, prop, reject } from 'ramda';
1
+ import { includes, map, prop, reject, sortBy, toLower, compose } from 'ramda';
2
2
  import { makeStyles } from 'tss-react/mui';
3
3
 
4
4
  import { Chip, ChipProps, Tooltip } from '@mui/material';
@@ -85,9 +85,11 @@ const MultiAutocompleteField = ({
85
85
  return includes(id, valueIds);
86
86
  };
87
87
 
88
+ const sortByName = sortBy(compose(toLower, prop('name')));
89
+
88
90
  const autocompleteOptions = disableSortedOptions
89
91
  ? options
90
- : [...values, ...reject(isOptionSelected, options)];
92
+ : sortByName([...values, ...reject(isOptionSelected, options)]);
91
93
 
92
94
  return (
93
95
  <Autocomplete
@@ -216,7 +216,8 @@ const AutocompleteField = React.forwardRef(
216
216
  ...params.inputProps,
217
217
  'aria-label': label,
218
218
  'data-testid': dataTestId || label,
219
- id: getNormalizedId(label || '')
219
+ id: getNormalizedId(label || ''),
220
+ ...autocompleteProps?.inputProps
220
221
  }}
221
222
  label={label}
222
223
  placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
@@ -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 && labelsDelete && (
80
+ <ConfirmationTooltip
81
+ confirmVariant="error"
82
+ labels={labelsDelete}
83
+ onConfirm={onDelete}
84
+ >
85
+ {({ toggleTooltip }) => (
86
+ <IconButton
87
+ aria-label="delete"
88
+ data-testid="delete"
89
+ icon={<DeleteIcon />}
90
+ size="small"
91
+ variant="ghost"
92
+ onClick={toggleTooltip}
93
+ />
94
+ )}
95
+ </ConfirmationTooltip>
96
+ )}
78
97
  </span>
79
98
  <span>
80
99
  <IconButton
@@ -1,10 +1,10 @@
1
1
  import { ForwardedRef, forwardRef, ReactElement, ReactNode } from 'react';
2
2
 
3
- import { ListItem as MuiListItem } from '@mui/material';
3
+ import { ListItemProps, ListItem as MuiListItem } from '@mui/material';
4
4
 
5
5
  import { useStyles } from './ListItem.styles';
6
6
 
7
- type ListItemProps = {
7
+ type Props = {
8
8
  action?: ReactElement;
9
9
  children: ReactNode | Array<ReactNode>;
10
10
  className?: string;
@@ -12,7 +12,7 @@ type ListItemProps = {
12
12
 
13
13
  export const ListItem = forwardRef(
14
14
  (
15
- { action, children, className, ...attr }: ListItemProps,
15
+ { action, children, className, ...attr }: Props & ListItemProps,
16
16
  ref?: ForwardedRef<HTMLLIElement>
17
17
  ) => {
18
18
  const { classes, cx } = useStyles();