@centreon/ui 25.1.0 → 25.1.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.
- package/package.json +1 -1
- package/src/Dashboard/Dashboard.styles.ts +4 -0
- package/src/Dashboard/Item.tsx +68 -43
- package/src/Dialog/UnsavedChanges/index.tsx +3 -3
- package/src/components/ExpandableContainer/ExpandableContainer.tsx +63 -0
- package/src/components/ExpandableContainer/expandableContainer.styles.ts +9 -0
- package/src/components/ExpandableContainer/index.tsx +3 -0
- package/src/components/ExpandableContainer/models.ts +12 -0
- package/src/components/ExpandableContainer/translatedLabels.ts +2 -0
package/package.json
CHANGED
|
@@ -80,6 +80,10 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
|
80
80
|
height: '100%',
|
|
81
81
|
width: '100%'
|
|
82
82
|
},
|
|
83
|
+
widgetSubContainer: {
|
|
84
|
+
height: '100%',
|
|
85
|
+
width: '100%'
|
|
86
|
+
},
|
|
83
87
|
widgetContent: {
|
|
84
88
|
height: hasHeader
|
|
85
89
|
? `calc(100% - ${theme.spacing(3.5)} - ${theme.spacing(0.5)})`
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
} from 'react';
|
|
10
10
|
|
|
11
11
|
import { useAtomValue } from 'jotai';
|
|
12
|
-
import { equals, isNil, prop } from 'ramda';
|
|
12
|
+
import { equals, isNil, prop, type } from 'ramda';
|
|
13
13
|
|
|
14
14
|
import { Card, useTheme } from '@mui/material';
|
|
15
|
-
|
|
16
15
|
import LoadingSkeleton from '../LoadingSkeleton';
|
|
16
|
+
import ExpandableContainer from '../components/ExpandableContainer';
|
|
17
|
+
import { Parameters } from '../components/ExpandableContainer/models';
|
|
17
18
|
import { useMemoComponent, useViewportIntersection } from '../utils';
|
|
18
|
-
|
|
19
19
|
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
20
20
|
import { isResizingItemAtom } from './atoms';
|
|
21
21
|
|
|
@@ -25,7 +25,7 @@ interface DashboardItemProps {
|
|
|
25
25
|
children: ReactElement;
|
|
26
26
|
className?: string;
|
|
27
27
|
disablePadding?: boolean;
|
|
28
|
-
header?: ReactElement;
|
|
28
|
+
header?: ReactElement | ((params: Parameters) => ReactElement);
|
|
29
29
|
id: string;
|
|
30
30
|
onMouseDown?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
31
31
|
onMouseUp?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
@@ -86,51 +86,76 @@ const Item = forwardRef<HTMLDivElement, DashboardItemProps>(
|
|
|
86
86
|
setElement(ref.current);
|
|
87
87
|
}, [ref]);
|
|
88
88
|
|
|
89
|
+
const originStyle = {
|
|
90
|
+
...style,
|
|
91
|
+
width: `calc(${prop('width', style) || '0px'} - 12px)`
|
|
92
|
+
};
|
|
93
|
+
|
|
89
94
|
return useMemoComponent({
|
|
90
95
|
Component: (
|
|
91
96
|
<div
|
|
97
|
+
ref={ref}
|
|
92
98
|
{...cardContainerListeners}
|
|
93
99
|
className={sanitizedReactGridLayoutClassName}
|
|
94
|
-
|
|
95
|
-
style={{
|
|
96
|
-
...style,
|
|
97
|
-
width: `calc(${prop('width', style) || '0px'} - 12px)`
|
|
98
|
-
}}
|
|
100
|
+
style={originStyle}
|
|
99
101
|
>
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
102
|
+
<ExpandableContainer>
|
|
103
|
+
{({ isExpanded, label, key, ...rest }) => {
|
|
104
|
+
const canControl = isExpanded ? false : canMove;
|
|
105
|
+
|
|
106
|
+
const childrenHeader = equals(type(header), 'Function')
|
|
107
|
+
? (header as (params: Parameters) => ReactElement)({
|
|
108
|
+
isExpanded,
|
|
109
|
+
label,
|
|
110
|
+
ref,
|
|
111
|
+
key,
|
|
112
|
+
...rest
|
|
113
|
+
})
|
|
114
|
+
: header;
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div key={key} className={classes.widgetSubContainer}>
|
|
118
|
+
<Card
|
|
119
|
+
className={classes.widgetContainer}
|
|
120
|
+
data-padding={!disablePadding}
|
|
121
|
+
>
|
|
122
|
+
{childrenHeader && (
|
|
123
|
+
<div
|
|
124
|
+
className={classes.widgetHeader}
|
|
125
|
+
data-canMove={canControl}
|
|
126
|
+
>
|
|
127
|
+
{canControl && (
|
|
128
|
+
<div
|
|
129
|
+
{...listeners}
|
|
130
|
+
className={classes.widgetHeaderDraggable}
|
|
131
|
+
data-testid={`${id}_move_panel`}
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
134
|
+
{childrenHeader}
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
<div
|
|
138
|
+
className={cx(
|
|
139
|
+
classes.widgetContent,
|
|
140
|
+
!disablePadding && classes.widgetPadding
|
|
141
|
+
)}
|
|
142
|
+
>
|
|
143
|
+
{!isInViewport ? (
|
|
144
|
+
<LoadingSkeleton
|
|
145
|
+
animation={false}
|
|
146
|
+
data-widget-skeleton={id}
|
|
147
|
+
height="100%"
|
|
148
|
+
width="100%"
|
|
149
|
+
/>
|
|
150
|
+
) : (
|
|
151
|
+
children
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
</Card>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}}
|
|
158
|
+
</ExpandableContainer>
|
|
134
159
|
</div>
|
|
135
160
|
),
|
|
136
161
|
memoProps: isInViewport
|
|
@@ -38,9 +38,9 @@ const UnsavedChangesDialog = ({
|
|
|
38
38
|
|
|
39
39
|
const labelConfirm = isValidForm ? labelSave : labelResolve;
|
|
40
40
|
|
|
41
|
-
const labelMessage =
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const labelMessage = isValidForm
|
|
42
|
+
? labelIfYouClickOnDiscard
|
|
43
|
+
: `${labelThereAreErrorsInTheForm} ${labelDoYouWantToQuitWithoutResolving}`;
|
|
44
44
|
|
|
45
45
|
if (not(dialogOpened)) {
|
|
46
46
|
return null;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { OpenInFull } from '@mui/icons-material';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Modal } from '../Modal';
|
|
4
|
+
import { useStyles } from './expandableContainer.styles';
|
|
5
|
+
import { Parameters } from './models';
|
|
6
|
+
import { labelExpand, labelReduce } from './translatedLabels';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
children: (params: Omit<Parameters, 'ref'>) => JSX.Element;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ExpandableContainer = ({ children }: Props) => {
|
|
13
|
+
const { classes } = useStyles();
|
|
14
|
+
|
|
15
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
16
|
+
|
|
17
|
+
const toggleExpand = (): void => {
|
|
18
|
+
setIsExpanded(!isExpanded);
|
|
19
|
+
};
|
|
20
|
+
const currentMode = isExpanded ? labelExpand : labelReduce;
|
|
21
|
+
|
|
22
|
+
const reducedChildrenData = {
|
|
23
|
+
toggleExpand,
|
|
24
|
+
isExpanded: false,
|
|
25
|
+
label: labelExpand,
|
|
26
|
+
Icon: OpenInFull,
|
|
27
|
+
key: currentMode
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const expandedChildrenData = {
|
|
31
|
+
toggleExpand,
|
|
32
|
+
isExpanded,
|
|
33
|
+
label: labelReduce,
|
|
34
|
+
Icon: OpenInFull,
|
|
35
|
+
key: currentMode
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
{children(reducedChildrenData)}
|
|
41
|
+
{isExpanded && (
|
|
42
|
+
<Modal
|
|
43
|
+
open={isExpanded}
|
|
44
|
+
size="xlarge"
|
|
45
|
+
classes={{
|
|
46
|
+
paper: classes.papper
|
|
47
|
+
}}
|
|
48
|
+
PaperProps={{
|
|
49
|
+
style: {
|
|
50
|
+
width: '90vw',
|
|
51
|
+
maxWidth: '90vw'
|
|
52
|
+
}
|
|
53
|
+
}}
|
|
54
|
+
hasCloseButton={false}
|
|
55
|
+
>
|
|
56
|
+
{children(expandedChildrenData)}
|
|
57
|
+
</Modal>
|
|
58
|
+
)}
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default ExpandableContainer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SvgIconComponent } from '@mui/icons-material';
|
|
2
|
+
import { CSSProperties, ForwardedRef } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface Parameters {
|
|
5
|
+
toggleExpand: () => void;
|
|
6
|
+
Icon: SvgIconComponent;
|
|
7
|
+
isExpanded: boolean;
|
|
8
|
+
label: string;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
ref: ForwardedRef<HTMLDivElement>;
|
|
11
|
+
key: string;
|
|
12
|
+
}
|