@centreon/ui 24.4.1-MON-develop-BOOSTER.3 → 24.4.1-MON-23368-containers.90
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 +24 -26
- package/src/Dialog/Confirm/index.tsx +2 -10
- package/src/Dialog/index.tsx +1 -8
- package/src/Form/Inputs/CheckboxGroup.tsx +4 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +4 -5
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +3 -2
- package/src/utils/index.ts +1 -0
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +109 -0
- package/src/utils/useFullscreen/atoms.ts +3 -0
- package/src/utils/useFullscreen/index.ts +2 -0
- package/src/utils/useFullscreen/translatedLabels.ts +1 -0
- package/src/utils/useFullscreen/useFullscreen.ts +73 -0
- package/src/utils/useFullscreen/useFullscreenListener.ts +54 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.4.1-MON-
|
|
3
|
+
"version": "24.4.1-MON-23368-containers.90",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"test/*"
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@cypress/react": "^
|
|
52
|
-
"@cypress/webpack-dev-server": "^3.
|
|
51
|
+
"@cypress/react": "^8.0.0",
|
|
52
|
+
"@cypress/webpack-dev-server": "^3.7.3",
|
|
53
53
|
"@faker-js/faker": "^8.0.2",
|
|
54
|
-
"@mdx-js/react": "^
|
|
55
|
-
"@simonsmith/cypress-image-snapshot": "^
|
|
54
|
+
"@mdx-js/react": "^3.0.0",
|
|
55
|
+
"@simonsmith/cypress-image-snapshot": "^9.0.1",
|
|
56
56
|
"@storybook/addon-a11y": "^7.0.9",
|
|
57
57
|
"@storybook/addon-docs": "^7.0.9",
|
|
58
58
|
"@storybook/addon-essentials": "^7.0.9",
|
|
@@ -73,16 +73,15 @@
|
|
|
73
73
|
"@testing-library/jest-dom": "^5.16.5",
|
|
74
74
|
"@testing-library/react": "^13.4.0",
|
|
75
75
|
"@testing-library/react-hooks": "^8.0.1",
|
|
76
|
-
"@types/
|
|
77
|
-
"@types/jest": "^27.5.0",
|
|
76
|
+
"@types/jest": "^29.5.11",
|
|
78
77
|
"@types/mocha": "^10.0.6",
|
|
79
|
-
"@types/ramda": "^0.29.
|
|
80
|
-
"@types/react": "^18.
|
|
81
|
-
"@types/testing-library__jest-dom": "^
|
|
78
|
+
"@types/ramda": "^0.29.9",
|
|
79
|
+
"@types/react": "^18.2.48",
|
|
80
|
+
"@types/testing-library__jest-dom": "^6.0.0",
|
|
82
81
|
"@vitejs/plugin-react": "^4.0.0",
|
|
83
82
|
"@vitejs/plugin-react-swc": "^3.3.0",
|
|
84
|
-
"axios-mock-adapter": "^1.
|
|
85
|
-
"cypress": "^13.
|
|
83
|
+
"axios-mock-adapter": "^1.22.0",
|
|
84
|
+
"cypress": "^13.6.2",
|
|
86
85
|
"identity-obj-proxy": "^3.0.0",
|
|
87
86
|
"jest-transform-stub": "^2.0.0",
|
|
88
87
|
"mochawesome": "^7.1.3",
|
|
@@ -93,27 +92,26 @@
|
|
|
93
92
|
"react-dom": "^18.2.0",
|
|
94
93
|
"react-test-renderer": "^18.2.0",
|
|
95
94
|
"remark-gfm": "^3.0.1",
|
|
96
|
-
"sass": "^1.62.1",
|
|
97
95
|
"speed-measure-vite-plugin": "^0.1.2",
|
|
98
|
-
"storybook": "^7.
|
|
96
|
+
"storybook": "^7.6.8",
|
|
99
97
|
"storybook-addon-mock": "^4.0.0",
|
|
100
|
-
"storybook-dark-mode": "^3.0.
|
|
98
|
+
"storybook-dark-mode": "^3.0.3",
|
|
101
99
|
"style-dictionary": "^3.8.0",
|
|
102
|
-
"ts-node": "^10.9.
|
|
100
|
+
"ts-node": "^10.9.2",
|
|
103
101
|
"use-resize-observer": "^9.1.0",
|
|
104
102
|
"vite": "^4.3.5",
|
|
105
103
|
"vite-plugin-istanbul": "^5.0.0",
|
|
106
104
|
"vite-plugin-svgr": "^3.2.0",
|
|
107
|
-
"vite-plugin-turbosnap": "^1.0.
|
|
105
|
+
"vite-plugin-turbosnap": "^1.0.3"
|
|
108
106
|
},
|
|
109
107
|
"dependencies": {
|
|
110
|
-
"@lexical/html": "^0.12.
|
|
111
|
-
"@lexical/link": "^0.12.
|
|
112
|
-
"@lexical/list": "^0.12.
|
|
113
|
-
"@lexical/react": "^0.12.
|
|
114
|
-
"@lexical/rich-text": "^0.12.
|
|
115
|
-
"@lexical/selection": "^0.12.
|
|
116
|
-
"@lexical/utils": "^0.12.
|
|
108
|
+
"@lexical/html": "^0.12.6",
|
|
109
|
+
"@lexical/link": "^0.12.6",
|
|
110
|
+
"@lexical/list": "^0.12.6",
|
|
111
|
+
"@lexical/react": "^0.12.6",
|
|
112
|
+
"@lexical/rich-text": "^0.12.6",
|
|
113
|
+
"@lexical/selection": "^0.12.6",
|
|
114
|
+
"@lexical/utils": "^0.12.6",
|
|
117
115
|
"@react-spring/web": "^9.7.3",
|
|
118
116
|
"@visx/curve": "^2.1.0",
|
|
119
117
|
"@visx/group": "^3.3.0",
|
|
@@ -125,9 +123,9 @@
|
|
|
125
123
|
"@visx/threshold": "^2.12.2",
|
|
126
124
|
"@visx/visx": "2.16.0",
|
|
127
125
|
"anylogger": "^1.0.11",
|
|
128
|
-
"d3-array": "3.2.
|
|
126
|
+
"d3-array": "3.2.4",
|
|
129
127
|
"humanize-duration": "^3.27.3",
|
|
130
|
-
"lexical": "^0.12.
|
|
128
|
+
"lexical": "^0.12.6",
|
|
131
129
|
"notistack": "^3.0.1",
|
|
132
130
|
"numeral": "^2.0.6",
|
|
133
131
|
"ramda": "0.29.1",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DialogContentText, Typography } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
import Dialog, { Props as DialogProps } from '..';
|
|
4
4
|
|
|
@@ -6,23 +6,15 @@ type Props = DialogProps & {
|
|
|
6
6
|
children?: JSX.Element;
|
|
7
7
|
labelMessage?: string | null;
|
|
8
8
|
labelSecondMessage?: string | null;
|
|
9
|
-
restCancelButtonProps?: ButtonProps;
|
|
10
|
-
restConfirmButtonProps?: ButtonProps;
|
|
11
9
|
};
|
|
12
10
|
|
|
13
11
|
const Confirm = ({
|
|
14
12
|
labelMessage,
|
|
15
13
|
labelSecondMessage,
|
|
16
14
|
children,
|
|
17
|
-
restCancelButtonProps,
|
|
18
|
-
restConfirmButtonProps,
|
|
19
15
|
...rest
|
|
20
16
|
}: Props): JSX.Element => (
|
|
21
|
-
<Dialog
|
|
22
|
-
restCancelButtonProps={restCancelButtonProps}
|
|
23
|
-
restConfirmButtonProps={restConfirmButtonProps}
|
|
24
|
-
{...rest}
|
|
25
|
-
>
|
|
17
|
+
<Dialog {...rest}>
|
|
26
18
|
<DialogContentText>
|
|
27
19
|
{labelMessage && <Typography>{labelMessage}</Typography>}
|
|
28
20
|
{labelSecondMessage && <Typography>{labelSecondMessage}</Typography>}
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -9,8 +9,7 @@ import {
|
|
|
9
9
|
DialogContent,
|
|
10
10
|
DialogActions,
|
|
11
11
|
DialogProps,
|
|
12
|
-
CircularProgress
|
|
13
|
-
ButtonProps
|
|
12
|
+
CircularProgress
|
|
14
13
|
} from '@mui/material';
|
|
15
14
|
|
|
16
15
|
import { DataTestAttributes } from '../@types/data-attributes';
|
|
@@ -49,8 +48,6 @@ export type Props = {
|
|
|
49
48
|
onClose?: () => void;
|
|
50
49
|
onConfirm: (event, value?) => void;
|
|
51
50
|
open: boolean;
|
|
52
|
-
restCancelButtonProps?: ButtonProps;
|
|
53
|
-
restConfirmButtonProps?: ButtonProps;
|
|
54
51
|
submitting?: boolean;
|
|
55
52
|
} & DialogProps &
|
|
56
53
|
DataTestAttributes;
|
|
@@ -73,8 +70,6 @@ const Dialog = ({
|
|
|
73
70
|
dialogContentClassName,
|
|
74
71
|
dialogActionsClassName,
|
|
75
72
|
dialogConfirmButtonClassName,
|
|
76
|
-
restCancelButtonProps,
|
|
77
|
-
restConfirmButtonProps,
|
|
78
73
|
...rest
|
|
79
74
|
}: Props): JSX.Element => {
|
|
80
75
|
const { classes, cx } = useStyles({ contentWidth });
|
|
@@ -106,7 +101,6 @@ const Dialog = ({
|
|
|
106
101
|
data-testid="Cancel"
|
|
107
102
|
disabled={cancelDisabled}
|
|
108
103
|
onClick={onCancel}
|
|
109
|
-
{...restCancelButtonProps}
|
|
110
104
|
>
|
|
111
105
|
{labelCancel}
|
|
112
106
|
</Button>
|
|
@@ -119,7 +113,6 @@ const Dialog = ({
|
|
|
119
113
|
disabled={confirmDisabled}
|
|
120
114
|
endIcon={submitting && <CircularProgress size={15} />}
|
|
121
115
|
onClick={onConfirm}
|
|
122
|
-
{...restConfirmButtonProps}
|
|
123
116
|
>
|
|
124
117
|
{labelConfirm}
|
|
125
118
|
</Button>
|
|
@@ -130,11 +130,10 @@ const WrapperThresholdLines = ({
|
|
|
130
130
|
|
|
131
131
|
return (
|
|
132
132
|
<g>
|
|
133
|
-
{filteredThresholdLines.map(
|
|
134
|
-
(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
))
|
|
133
|
+
{filteredThresholdLines.map((element) =>
|
|
134
|
+
element?.map(({ Component, props, key }) => (
|
|
135
|
+
<Component {...props} id={key} key={key} />
|
|
136
|
+
))
|
|
138
137
|
)}
|
|
139
138
|
</g>
|
|
140
139
|
);
|
|
@@ -43,8 +43,9 @@ const Annotation = ({
|
|
|
43
43
|
|
|
44
44
|
const setAnnotationHovered = useSetAtom(annotationHoveredAtom);
|
|
45
45
|
|
|
46
|
-
const content = `${truncate(event.content)} (${t(labelBy)} ${
|
|
47
|
-
?.name
|
|
46
|
+
const content = `${truncate(event.content)} (${t(labelBy)} ${
|
|
47
|
+
event.contact?.name
|
|
48
|
+
})`;
|
|
48
49
|
|
|
49
50
|
return (
|
|
50
51
|
<g>
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Provider, createStore } from 'jotai';
|
|
2
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import { Button } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
import { useFullscreen } from './useFullscreen';
|
|
7
|
+
import { router, useFullscreenListener } from './useFullscreenListener';
|
|
8
|
+
|
|
9
|
+
const labelEnterFullscreen = 'Enter fullscreen';
|
|
10
|
+
const labelExitFullscreen = 'Exit fullscreen';
|
|
11
|
+
|
|
12
|
+
const ChildComponent = (): JSX.Element => {
|
|
13
|
+
const { toggleFullscreen, fullscreenEnabled, isFullscreenActivated } =
|
|
14
|
+
useFullscreen();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
data-fullscreenActivated={isFullscreenActivated}
|
|
19
|
+
data-fullscreenEnabled={fullscreenEnabled}
|
|
20
|
+
id="test"
|
|
21
|
+
>
|
|
22
|
+
<Button onClick={() => toggleFullscreen(document.body)}>
|
|
23
|
+
{isFullscreenActivated ? labelExitFullscreen : labelEnterFullscreen}
|
|
24
|
+
</Button>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const TestComponent = (): JSX.Element => {
|
|
30
|
+
useFullscreenListener();
|
|
31
|
+
|
|
32
|
+
return <ChildComponent />;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const initialize = (): void => {
|
|
36
|
+
const store = createStore();
|
|
37
|
+
|
|
38
|
+
const queryParameters = new Map();
|
|
39
|
+
|
|
40
|
+
cy.stub(router, 'useSearchParams', () => queryParameters);
|
|
41
|
+
|
|
42
|
+
cy.mount({
|
|
43
|
+
Component: (
|
|
44
|
+
<BrowserRouter>
|
|
45
|
+
<Provider store={store}>
|
|
46
|
+
<TestComponent />
|
|
47
|
+
</Provider>
|
|
48
|
+
</BrowserRouter>
|
|
49
|
+
)
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
describe('Fullscreen', () => {
|
|
54
|
+
it('enters fullscreen mode when the button is clicked', () => {
|
|
55
|
+
initialize();
|
|
56
|
+
|
|
57
|
+
cy.get('#test')
|
|
58
|
+
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
59
|
+
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
60
|
+
|
|
61
|
+
cy.contains(labelEnterFullscreen).realClick();
|
|
62
|
+
|
|
63
|
+
cy.get('#test')
|
|
64
|
+
.should('have.attr', 'data-fullscreenActivated', 'true')
|
|
65
|
+
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
66
|
+
|
|
67
|
+
cy.contains(labelExitFullscreen).realClick();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('exits fullscreen mode when the button is clicked', () => {
|
|
71
|
+
initialize();
|
|
72
|
+
|
|
73
|
+
cy.get('#test')
|
|
74
|
+
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
75
|
+
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
76
|
+
|
|
77
|
+
cy.contains(labelEnterFullscreen).realClick();
|
|
78
|
+
|
|
79
|
+
cy.get('#test')
|
|
80
|
+
.should('have.attr', 'data-fullscreenActivated', 'true')
|
|
81
|
+
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
82
|
+
|
|
83
|
+
cy.contains(labelExitFullscreen).realClick();
|
|
84
|
+
|
|
85
|
+
cy.get('#test')
|
|
86
|
+
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
87
|
+
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('toggles fullscreen mode when the corresponding shortcut is clicked', () => {
|
|
91
|
+
initialize();
|
|
92
|
+
|
|
93
|
+
cy.get('#test')
|
|
94
|
+
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
95
|
+
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
96
|
+
|
|
97
|
+
cy.get('#test').realPress(['Alt', 'F']);
|
|
98
|
+
|
|
99
|
+
cy.get('#test')
|
|
100
|
+
.should('have.attr', 'data-fullscreenActivated', 'true')
|
|
101
|
+
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
102
|
+
|
|
103
|
+
cy.get('#test').realPress(['Alt', 'F']);
|
|
104
|
+
|
|
105
|
+
cy.get('#test')
|
|
106
|
+
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
107
|
+
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const labelCannotEnterInFullscreen = 'Cannot enter fullscreen mode';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next';
|
|
2
|
+
import { useAtom } from 'jotai';
|
|
3
|
+
|
|
4
|
+
import { useSnackbar } from '../..';
|
|
5
|
+
|
|
6
|
+
import { labelCannotEnterInFullscreen } from './translatedLabels';
|
|
7
|
+
import { isFullscreenActivatedAtom } from './atoms';
|
|
8
|
+
|
|
9
|
+
interface UseFullscreenState {
|
|
10
|
+
enterInFullscreen: (element: HTMLElement | null) => void;
|
|
11
|
+
exitFullscreen: () => void;
|
|
12
|
+
fullscreenEnabled: boolean;
|
|
13
|
+
isFullscreenActivated: boolean;
|
|
14
|
+
resetVariables: () => void;
|
|
15
|
+
toggleFullscreen: (element: HTMLElement | null) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const useFullscreen = (): UseFullscreenState => {
|
|
19
|
+
const { t } = useTranslation();
|
|
20
|
+
|
|
21
|
+
const { showErrorMessage } = useSnackbar();
|
|
22
|
+
|
|
23
|
+
const [isFullscreenActivated, setIsFullscreenActivated] = useAtom(
|
|
24
|
+
isFullscreenActivatedAtom
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const resetVariables = (): void => {
|
|
28
|
+
setIsFullscreenActivated(false);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const enterInFullscreen = (element: HTMLElement | null): void => {
|
|
32
|
+
if (!document.fullscreenEnabled) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!element) {
|
|
37
|
+
showErrorMessage(t(labelCannotEnterInFullscreen));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
element
|
|
41
|
+
?.requestFullscreen({ navigationUI: 'show' })
|
|
42
|
+
.then(() => {
|
|
43
|
+
setIsFullscreenActivated(true);
|
|
44
|
+
})
|
|
45
|
+
.catch(() => {
|
|
46
|
+
showErrorMessage(t(labelCannotEnterInFullscreen));
|
|
47
|
+
setIsFullscreenActivated(false);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const exitFullscreen = (): void => {
|
|
52
|
+
document.exitFullscreen().then(resetVariables);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const toggleFullscreen = (element: HTMLElement | null): void => {
|
|
56
|
+
if (isFullscreenActivated) {
|
|
57
|
+
exitFullscreen();
|
|
58
|
+
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
enterInFullscreen(element);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
enterInFullscreen,
|
|
67
|
+
exitFullscreen,
|
|
68
|
+
fullscreenEnabled: document.fullscreenEnabled,
|
|
69
|
+
isFullscreenActivated,
|
|
70
|
+
resetVariables,
|
|
71
|
+
toggleFullscreen
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { equals } from 'ramda';
|
|
4
|
+
import { useSearchParams } from 'react-router-dom';
|
|
5
|
+
|
|
6
|
+
import { useDeepCompare } from '../useMemoComponent';
|
|
7
|
+
|
|
8
|
+
import { useFullscreen } from './useFullscreen';
|
|
9
|
+
|
|
10
|
+
export const router = {
|
|
11
|
+
useSearchParams
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const useFullscreenListener = (): boolean => {
|
|
15
|
+
const { toggleFullscreen, resetVariables, isFullscreenActivated } =
|
|
16
|
+
useFullscreen();
|
|
17
|
+
|
|
18
|
+
const toggle = (event: KeyboardEvent): void => {
|
|
19
|
+
if (!event.altKey || !equals(event.code, 'KeyF')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
toggleFullscreen(document.querySelector('body'));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const changeFullscreen = (): void => {
|
|
27
|
+
if (document.fullscreenElement) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
resetVariables();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
useEffect(
|
|
35
|
+
() => {
|
|
36
|
+
document.addEventListener('fullscreenchange', changeFullscreen);
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
document.removeEventListener('fullscreenchange', changeFullscreen);
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
useDeepCompare([document.fullscreenElement])
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
window.addEventListener('keypress', toggle);
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
window.removeEventListener('keypress', toggle);
|
|
50
|
+
};
|
|
51
|
+
}, [isFullscreenActivated]);
|
|
52
|
+
|
|
53
|
+
return isFullscreenActivated;
|
|
54
|
+
};
|