@centreon/ui 23.10.1-MON-20802-fe-implement-new-visualization.2 → 23.10.1-MON-21543-implement-top-bottom-widget.0
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 +6 -1
- package/src/Dashboard/Item.tsx +4 -1
- package/src/Dashboard/Layout.tsx +1 -1
- package/src/Graph/Gauge/Gauge.stories.tsx +10 -0
- package/src/Graph/Gauge/Gauge.tsx +10 -1
- package/src/Graph/Gauge/PieData.tsx +8 -8
- package/src/Graph/Gauge/ResponsiveGauge.tsx +32 -23
- package/src/Graph/Gauge/Thresholds.tsx +2 -25
- package/src/Graph/Gauge/models.ts +1 -0
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +41 -24
- package/src/Graph/SingleBar/SingleBar.stories.tsx +46 -0
- package/src/Graph/SingleBar/ThresholdLine.tsx +31 -12
- package/src/Graph/SingleBar/Thresholds.tsx +5 -1
- package/src/Graph/SingleBar/models.ts +4 -0
- package/src/Graph/Text/Text.stories.tsx +13 -0
- package/src/Graph/Text/Text.tsx +19 -12
- package/src/Graph/common/timeSeries/index.test.ts +106 -3
- package/src/Graph/common/timeSeries/index.ts +67 -4
- package/src/Graph/common/timeSeries/models.ts +6 -3
- package/src/Graph/common/utils.ts +4 -2
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +4 -2
- package/src/InputField/Select/Autocomplete/index.tsx +3 -1
- package/src/InputField/Text/index.tsx +10 -7
- package/src/RichTextEditor/ContentEditable.tsx +0 -1
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +5 -13
- package/src/RichTextEditor/RichTextEditor.tsx +5 -2
- package/src/RichTextEditor/plugins/AutoLinkPlugin/index.tsx +40 -1
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +33 -8
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +10 -4
- package/src/ThemeProvider/index.tsx +6 -4
- package/src/TopCounterElements/index.tsx +0 -1
- package/src/api/useFetchQuery/index.ts +10 -8
- package/src/components/Inputs/Switch/Switch.stories.tsx +22 -0
- package/src/components/Inputs/Switch/Switch.styles.ts +13 -0
- package/src/components/Inputs/Switch/Switch.tsx +18 -0
- package/src/components/Inputs/index.ts +1 -0
- package/src/components/Modal/Modal.styles.ts +3 -1
- package/src/components/index.ts +1 -0
|
@@ -11,7 +11,7 @@ import { mergeRegister } from '@lexical/utils';
|
|
|
11
11
|
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
|
|
12
12
|
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
|
-
import { equals, isNil } from 'ramda';
|
|
14
|
+
import { dec, equals, gt, isNil, replace } from 'ramda';
|
|
15
15
|
|
|
16
16
|
import { Popper, IconButton, Paper, Link, Box } from '@mui/material';
|
|
17
17
|
import EditIcon from '@mui/icons-material/Edit';
|
|
@@ -56,6 +56,7 @@ const FloatingLinkEditor = ({
|
|
|
56
56
|
x: 0,
|
|
57
57
|
y: 0
|
|
58
58
|
});
|
|
59
|
+
const [editedUrl, setEditedUrl] = useState('');
|
|
59
60
|
|
|
60
61
|
const [editMode, setEditMode] = useAtom(editLinkModeAtom);
|
|
61
62
|
const [linkUrl, setLinkUrl] = useAtom(linkValueAtom);
|
|
@@ -65,9 +66,10 @@ const FloatingLinkEditor = ({
|
|
|
65
66
|
const acceptOrCancelNewLinkValue = useCallback(
|
|
66
67
|
(event): void => {
|
|
67
68
|
const { value } = event.target;
|
|
68
|
-
if (event.key === 'Enter') {
|
|
69
|
-
event.preventDefault();
|
|
70
69
|
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
|
|
72
|
+
if (event.key === 'Enter') {
|
|
71
73
|
if (value !== '') {
|
|
72
74
|
editor.dispatchCommand(TOGGLE_LINK_COMMAND, {
|
|
73
75
|
target: openLinkInNewTab ? '_blank' : undefined,
|
|
@@ -75,14 +77,36 @@ const FloatingLinkEditor = ({
|
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
79
|
setEditMode(false);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (event.key === 'Escape') {
|
|
80
83
|
setEditMode(false);
|
|
81
84
|
}
|
|
82
85
|
},
|
|
83
86
|
[setEditMode, setLinkUrl]
|
|
84
87
|
);
|
|
85
88
|
|
|
89
|
+
const enterInEditMode = useCallback(() => {
|
|
90
|
+
setEditedUrl(linkUrl);
|
|
91
|
+
setEditMode(true);
|
|
92
|
+
}, [linkUrl]);
|
|
93
|
+
|
|
94
|
+
const changeValue = useCallback((event): void => {
|
|
95
|
+
const { value } = event.target;
|
|
96
|
+
|
|
97
|
+
const matched = value.match(/https?:\/\//g);
|
|
98
|
+
|
|
99
|
+
if (gt(matched.length, 1)) {
|
|
100
|
+
setEditedUrl(
|
|
101
|
+
replace(matched.join(''), matched[dec(matched.length)], value)
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setEditedUrl(value);
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
86
110
|
useEffect(() => {
|
|
87
111
|
const isPositioned =
|
|
88
112
|
rangeRect && (!equals(rangeRect.x, 0) || !equals(rangeRect.y, 0));
|
|
@@ -126,9 +150,9 @@ const FloatingLinkEditor = ({
|
|
|
126
150
|
<InputField
|
|
127
151
|
autoFocus
|
|
128
152
|
dataTestId="InputLinkField"
|
|
129
|
-
defaultValue={linkUrl}
|
|
130
153
|
label={t(labelInputLink)}
|
|
131
154
|
size="small"
|
|
155
|
+
value={editedUrl}
|
|
132
156
|
onBlur={(event): void => {
|
|
133
157
|
const { value } = event.target;
|
|
134
158
|
|
|
@@ -139,7 +163,8 @@ const FloatingLinkEditor = ({
|
|
|
139
163
|
}
|
|
140
164
|
setEditMode(false);
|
|
141
165
|
}}
|
|
142
|
-
|
|
166
|
+
onChange={changeValue}
|
|
167
|
+
onKeyUp={acceptOrCancelNewLinkValue}
|
|
143
168
|
/>
|
|
144
169
|
) : (
|
|
145
170
|
<Box component="span" sx={{ margin: '10px' }}>
|
|
@@ -156,7 +181,7 @@ const FloatingLinkEditor = ({
|
|
|
156
181
|
aria-label={labelEditLink}
|
|
157
182
|
size="small"
|
|
158
183
|
sx={{ marginLeft: '5px' }}
|
|
159
|
-
onClick={
|
|
184
|
+
onClick={enterInEditMode}
|
|
160
185
|
>
|
|
161
186
|
<EditIcon fontSize="small" />
|
|
162
187
|
</IconButton>
|
|
@@ -8,7 +8,8 @@ import MacrosButton from './MacrosButton';
|
|
|
8
8
|
import BlockButtons from './BlockButtons';
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
11
|
-
disabled
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
displayBlockButtons: boolean;
|
|
12
13
|
displayMacrosButton?: boolean;
|
|
13
14
|
editable: boolean;
|
|
14
15
|
}
|
|
@@ -33,15 +34,20 @@ export const useStyles = makeStyles()((theme) => ({
|
|
|
33
34
|
const ToolbarPlugin = ({
|
|
34
35
|
editable,
|
|
35
36
|
displayMacrosButton,
|
|
36
|
-
disabled
|
|
37
|
+
disabled,
|
|
38
|
+
displayBlockButtons
|
|
37
39
|
}: Props): JSX.Element | null => {
|
|
38
40
|
const { classes } = useStyles();
|
|
39
41
|
|
|
40
42
|
return editable ? (
|
|
41
43
|
<div className={classes.container}>
|
|
42
44
|
<UndoRedoButtons disabled={disabled} />
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
{displayBlockButtons && (
|
|
46
|
+
<>
|
|
47
|
+
<Divider flexItem orientation="vertical" />
|
|
48
|
+
<BlockButtons disabled={disabled} />
|
|
49
|
+
</>
|
|
50
|
+
)}
|
|
45
51
|
<Divider flexItem orientation="vertical" />
|
|
46
52
|
<FormatButtons disabled={disabled} />
|
|
47
53
|
{displayMacrosButton && (
|
|
@@ -48,8 +48,7 @@ const getInputBaseRootStyle = ({
|
|
|
48
48
|
|
|
49
49
|
if (equals(size, 'compact')) {
|
|
50
50
|
return {
|
|
51
|
-
padding: '
|
|
52
|
-
paddingRight: '0px'
|
|
51
|
+
padding: '0px 0px 0px 8px'
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
if (equals(size, 'small')) {
|
|
@@ -75,7 +74,6 @@ const getInputBaseRootStyle = ({
|
|
|
75
74
|
const getInputBaseInputStyle = ({ size }: InputBaseProps): CSSInterpolation => {
|
|
76
75
|
if (equals(size, 'compact')) {
|
|
77
76
|
return {
|
|
78
|
-
fontSize: 'x-small',
|
|
79
77
|
minHeight: '32px'
|
|
80
78
|
};
|
|
81
79
|
}
|
|
@@ -123,6 +121,7 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
|
|
|
123
121
|
MuiChip: {
|
|
124
122
|
styleOverrides: {
|
|
125
123
|
root: ({ ownerState, theme }) => ({
|
|
124
|
+
backgroundColor: !ownerState.color && theme.palette.divider,
|
|
126
125
|
...(equals(ownerState.size, 'medium') && {
|
|
127
126
|
borderRadius: theme.spacing(1.25),
|
|
128
127
|
fontSize: theme.typography.body2.fontSize,
|
|
@@ -189,7 +188,10 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
|
|
|
189
188
|
},
|
|
190
189
|
MuiInputBase: {
|
|
191
190
|
styleOverrides: {
|
|
192
|
-
root: ({ ownerState }) =>
|
|
191
|
+
root: ({ ownerState, theme }) => ({
|
|
192
|
+
...getInputBaseInputStyle(ownerState),
|
|
193
|
+
backgroundColor: theme.palette.background.paper
|
|
194
|
+
})
|
|
193
195
|
}
|
|
194
196
|
},
|
|
195
197
|
MuiList: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { default as TopCounterLayout } from './TopCounterLayout';
|
|
2
2
|
export { default as TopCounterResourceCounters } from './ResourceCounters';
|
|
3
3
|
export { default as TopCounterResourceSubMenu } from './ResourceSubMenu';
|
|
4
|
-
export { default as StatusCounter } from './StatusCounter';
|
|
5
4
|
export * from './formaters';
|
|
6
5
|
export type { CounterProps } from './ResourceCounters';
|
|
7
6
|
export type { SubMenuProps } from './ResourceSubMenu';
|
|
@@ -90,14 +90,6 @@ const useFetchQuery = <T extends object>({
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
return (): void => {
|
|
95
|
-
queryClient.cancelQueries(getQueryKey());
|
|
96
|
-
};
|
|
97
|
-
}, []);
|
|
98
|
-
|
|
99
|
-
manageError();
|
|
100
|
-
|
|
101
93
|
const prefetchQuery = ({ endpointParams, queryKey }): void => {
|
|
102
94
|
queryClient.prefetchQuery(
|
|
103
95
|
queryKey,
|
|
@@ -162,6 +154,16 @@ const useFetchQuery = <T extends object>({
|
|
|
162
154
|
|
|
163
155
|
const errorData = queryData.data as ResponseError | undefined;
|
|
164
156
|
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
return (): void => {
|
|
159
|
+
queryClient.cancelQueries(getQueryKey());
|
|
160
|
+
};
|
|
161
|
+
}, []);
|
|
162
|
+
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
manageError();
|
|
165
|
+
}, [queryData.data]);
|
|
166
|
+
|
|
165
167
|
return {
|
|
166
168
|
...omit(['data'], queryData),
|
|
167
169
|
data,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import Switch from './Switch';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Switch> = {
|
|
6
|
+
component: Switch
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof Switch>;
|
|
11
|
+
|
|
12
|
+
export const notChecked: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
checked: false
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const checked: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
checked: true
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
export const useSwitchStyles = makeStyles()((theme) => ({
|
|
4
|
+
switch: {
|
|
5
|
+
'& .MuiSwitch-thumb': {
|
|
6
|
+
backgroundColor: theme.palette.common.white
|
|
7
|
+
},
|
|
8
|
+
'& span[data-checked="true"] + .MuiSwitch-track': {
|
|
9
|
+
backgroundColor: theme.palette.success.main,
|
|
10
|
+
opacity: 1
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SwitchProps, Switch as MuiSwitch } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import { useSwitchStyles } from './Switch.styles';
|
|
4
|
+
|
|
5
|
+
const Switch = ({ checked, ...props }: SwitchProps): JSX.Element => {
|
|
6
|
+
const { classes } = useSwitchStyles();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<MuiSwitch
|
|
10
|
+
checked={checked}
|
|
11
|
+
className={classes.switch}
|
|
12
|
+
data-checked={checked}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default Switch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Switch } from './Switch/Switch';
|
|
@@ -48,10 +48,12 @@ const useStyles = makeStyles<{
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
modalActions: {
|
|
51
|
+
bottom: 0,
|
|
51
52
|
display: 'flex',
|
|
52
53
|
flexDirection: 'row',
|
|
53
54
|
gap: theme.spacing(2),
|
|
54
|
-
justifyContent: 'flex-end'
|
|
55
|
+
justifyContent: 'flex-end',
|
|
56
|
+
position: 'sticky'
|
|
55
57
|
},
|
|
56
58
|
modalBody: {
|
|
57
59
|
'& > p': {
|
package/src/components/index.ts
CHANGED