@centreon/ui 23.10.93 → 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 +2 -2
- package/src/ActionsList/index.tsx +19 -6
- package/src/Dashboard/Dashboard.styles.ts +3 -0
- package/src/Dashboard/Item.tsx +4 -1
- package/src/Graph/Gauge/AnimatedPie.tsx +16 -12
- package/src/api/useFetchQuery/index.ts +2 -1
- package/src/api/useMutationQuery/index.ts +2 -1
- package/src/components/DataTable/Item/DataTableItem.tsx +28 -9
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.styles.tsx +3 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -0
- package/src/components/Tooltip/ConfirmationTooltip/index.ts +1 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/index.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.
|
|
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",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@lexical/rich-text": "^0.11.3",
|
|
108
108
|
"@lexical/selection": "0.11.3",
|
|
109
109
|
"@lexical/utils": "0.11.3",
|
|
110
|
-
"@react-spring/web": "
|
|
110
|
+
"@react-spring/web": "9.6.0",
|
|
111
111
|
"@visx/curve": "^2.1.0",
|
|
112
112
|
"@visx/group": "^3.3.0",
|
|
113
113
|
"@visx/pattern": "^3.0.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?:
|
|
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:
|
|
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,
|
|
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={
|
|
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),
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -67,7 +67,10 @@ const Item = forwardRef(
|
|
|
67
67
|
width: `calc(${prop('width', style) || '0px'} - 12px)`
|
|
68
68
|
}}
|
|
69
69
|
>
|
|
70
|
-
<Card
|
|
70
|
+
<Card
|
|
71
|
+
className={classes.widgetContainer}
|
|
72
|
+
data-padding={!disablePadding}
|
|
73
|
+
>
|
|
71
74
|
{header && (
|
|
72
75
|
<div
|
|
73
76
|
{...listeners}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { PieArcDatum, ProvidedProps } from '@visx/shape/lib/shapes/Pie';
|
|
2
2
|
import { useTransition, to, animated } from '@react-spring/web';
|
|
3
|
-
import { equals, includes, pluck } from 'ramda';
|
|
3
|
+
import { equals, includes, isNil, pluck } from 'ramda';
|
|
4
4
|
|
|
5
5
|
import { Typography } from '@mui/material';
|
|
6
6
|
|
|
7
|
-
import { Metric } from '../common/timeSeries/models';
|
|
8
7
|
import { Thresholds } from '../common/models';
|
|
9
8
|
|
|
10
9
|
type AnimatedStyles = { endAngle: number; opacity: number; startAngle: number };
|
|
@@ -25,11 +24,9 @@ const enterUpdateTransition = <T,>({
|
|
|
25
24
|
|
|
26
25
|
type AnimatedPieProps<Datum> = ProvidedProps<Datum> & {
|
|
27
26
|
animate?: boolean;
|
|
28
|
-
delay?: number;
|
|
29
27
|
getColor: (d: PieArcDatum<Datum>) => string;
|
|
30
28
|
getKey: (d: PieArcDatum<Datum>) => string;
|
|
31
29
|
hideTooltip?: () => void;
|
|
32
|
-
metric?: Metric;
|
|
33
30
|
showTooltip?: (args) => void;
|
|
34
31
|
thresholds: Thresholds;
|
|
35
32
|
};
|
|
@@ -43,14 +40,21 @@ const AnimatedPie = <Datum,>({
|
|
|
43
40
|
showTooltip,
|
|
44
41
|
hideTooltip,
|
|
45
42
|
thresholds
|
|
46
|
-
}: AnimatedPieProps<Datum>): JSX.Element => {
|
|
47
|
-
const transitions = useTransition
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
}: AnimatedPieProps<Datum>): JSX.Element | null => {
|
|
44
|
+
const transitions = useTransition?.<PieArcDatum<Datum>, AnimatedStyles>(
|
|
45
|
+
arcs,
|
|
46
|
+
{
|
|
47
|
+
enter: enterUpdateTransition,
|
|
48
|
+
from: animate ? fromLeaveTransition : enterUpdateTransition,
|
|
49
|
+
keys: getKey,
|
|
50
|
+
leave: animate ? fromLeaveTransition : enterUpdateTransition,
|
|
51
|
+
update: enterUpdateTransition
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (isNil(useTransition)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
54
58
|
|
|
55
59
|
return transitions((props, arc, { key }) => (
|
|
56
60
|
<g key={key}>
|
|
@@ -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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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 {
|
|
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
|
|