@centreon/ui 24.4.71 → 24.4.72
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,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { makeStyles } from 'tss-react/mui';
|
|
4
4
|
|
|
5
|
-
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
6
5
|
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
7
|
-
import
|
|
6
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
8
7
|
import type { SvgIcon } from '@mui/material';
|
|
8
|
+
import { Badge, ClickAwayListener } from '@mui/material';
|
|
9
|
+
|
|
10
|
+
import useCloseOnLegacyPage from './useCloseOnLegacyPage';
|
|
9
11
|
|
|
10
12
|
const useStyles = makeStyles()((theme) => ({
|
|
11
13
|
button: {
|
|
@@ -113,8 +115,8 @@ const TopCounterLayout = ({
|
|
|
113
115
|
}: TopCounterLayoutProps): JSX.Element => {
|
|
114
116
|
const { classes, cx } = useStyles();
|
|
115
117
|
const [toggled, setToggled] = useState(false);
|
|
116
|
-
|
|
117
118
|
const subMenuId = title.replace(/[^A-Za-z]/, '-');
|
|
119
|
+
useCloseOnLegacyPage({ setToggled });
|
|
118
120
|
|
|
119
121
|
useEffect(() => {
|
|
120
122
|
const closeMenu = (): void => setToggled(false);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
setToggled: Dispatch<SetStateAction<boolean>>;
|
|
7
|
+
}
|
|
8
|
+
const useCloseOnLegacyPage = ({ setToggled }: Props): void => {
|
|
9
|
+
const { pathname, search } = useLocation();
|
|
10
|
+
const isLegacyRoute = pathname.includes('main.php');
|
|
11
|
+
|
|
12
|
+
const closeSubMenu = (): void => {
|
|
13
|
+
setToggled(false);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const iframe = document.getElementById('main-content') as HTMLIFrameElement;
|
|
18
|
+
|
|
19
|
+
if (!isLegacyRoute) {
|
|
20
|
+
return () => undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const closeSubMenuOnLegacyPage = (): void => {
|
|
24
|
+
iframe.contentWindow?.document?.addEventListener('click', closeSubMenu);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
iframe.addEventListener('load', closeSubMenuOnLegacyPage);
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
iframe.removeEventListener('load', closeSubMenuOnLegacyPage);
|
|
31
|
+
iframe.contentWindow?.document?.removeEventListener(
|
|
32
|
+
'click',
|
|
33
|
+
closeSubMenu
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
}, [pathname, search]);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default useCloseOnLegacyPage;
|