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

View File

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