[test] popup

This commit is contained in:
baha 2025-01-27 14:32:56 +00:00
parent 65831c91d5
commit 780de61378
2 changed files with 27 additions and 9 deletions

View File

@ -43,11 +43,18 @@ export class BaseLayout extends Component {
super(props);
this.state = {
collapsed: false,
isOpenedInPopup: false, // State to track if opened in a popup
};
this.init();
}
componentDidMount() {
// Listen for postMessage from the parent app
window.addEventListener('message', this.handleMessage, false);
}
componentWillUnmount() {
window.removeEventListener('message', this.handleMessage, false);
this.autoReaction();
}
@ -134,6 +141,19 @@ export class BaseLayout extends Component {
return newMenu;
};
handleMessage = (event) => {
const trustedOrigins = [
'https://baha-dev.felcloud.io',
'https://demo.felcloud.io',
];
if (trustedOrigins.includes(event.origin)) {
const { message } = event.data;
if (message === 'openedInPopup') {
this.setState({ isOpenedInPopup: true });
}
}
};
checkItemEndpoints = (key) => this.rootStore.checkEndpoint(key);
getMenuAllowed = (menu) => {
@ -260,8 +280,8 @@ export class BaseLayout extends Component {
render() {
const { pathname } = this.props.location;
const currentRoutes = this.getCurrentMenu(pathname);
console.log('hapened');
if (window.opener) {
console.log('testing popup');
if (this.state.isOpenedInPopup) {
return (
<Modal
visible
@ -283,17 +303,15 @@ export class BaseLayout extends Component {
padding: '20px',
}}
>
<p>Connexion... Please wait !</p>
<p>Connexion... Please wait!</p>
</Modal>
);
}
return (
<div className={styles['base-layout']}>
{this.renderNotice()}
<Header className={styles.header}>
{/* {this.renderLogo()} */}
{this.renderHeader()}
</Header>
<Header className={styles.header}>{this.renderHeader()}</Header>
<LayoutMenu
pathname={pathname}
isAdminPage={this.isAdminPage}

View File

@ -26,8 +26,8 @@
.ant-menu.ant-menu-dark {
background: linear-gradient(
-240deg,
#411e49 50%,
#411e49 150%
#470056 50%,
#000 150%
) !important;
}