From f4ba64531ad3700167b778a9920ffc7be5829ec2 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Fri, 30 Jun 2023 18:18:22 +0000 Subject: [PATCH] fix login drawer logics --- packages/app/src/App.jsx | 13 ++++++++++--- packages/app/src/components/Layout/drawer/index.jsx | 1 + packages/app/src/components/Login/index.jsx | 8 +++++++- packages/app/src/components/UserRegister/index.jsx | 10 ++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/app/src/App.jsx b/packages/app/src/App.jsx index 5d188d36..ff05c310 100755 --- a/packages/app/src/App.jsx +++ b/packages/app/src/App.jsx @@ -187,10 +187,17 @@ class ComtyApp extends React.Component { } }) }, - openRegisterForm: async () => { + openRegisterForm: async (options = {}) => { app.DrawerController.open("Register", UserRegister, { - allowMultiples: false, - panel: true, + defaultLocked: options.defaultLocked ?? false, + componentProps: { + sessionController: this.sessionController, + }, + props: { + bodyStyle: { + height: "100%", + } + }, }) }, // Opens the notification window and sets up the UI for the notification to be displayed diff --git a/packages/app/src/components/Layout/drawer/index.jsx b/packages/app/src/components/Layout/drawer/index.jsx index 010fdec9..7051e98b 100755 --- a/packages/app/src/components/Layout/drawer/index.jsx +++ b/packages/app/src/components/Layout/drawer/index.jsx @@ -180,6 +180,7 @@ export class Drawer extends React.Component { } const componentProps = { ...this.options.componentProps, + locked: this.state.locked, lock: this.lock, unlock: this.unlock, events: this.events, diff --git a/packages/app/src/components/Login/index.jsx b/packages/app/src/components/Login/index.jsx index 87451a95..e5c2dac7 100755 --- a/packages/app/src/components/Login/index.jsx +++ b/packages/app/src/components/Login/index.jsx @@ -79,11 +79,17 @@ export default class Login extends React.Component { } onClickRegister = () => { + if (this.props.locked) { + this.props.unlock() + } + if (typeof this.props.close === "function") { this.props.close() } - app.eventBus.emit("app.createRegister") + app.controls.openRegisterForm({ + defaultLocked: this.props.locked + }) } toggleLoading = (to) => { diff --git a/packages/app/src/components/UserRegister/index.jsx b/packages/app/src/components/UserRegister/index.jsx index 39dd589e..4cbb6582 100755 --- a/packages/app/src/components/UserRegister/index.jsx +++ b/packages/app/src/components/UserRegister/index.jsx @@ -349,9 +349,19 @@ export default (props) => { antd.message.success("User registered successfully.") } + if (props.locked) { + props.unlock() + } + if (typeof props.close === "function") { props.close() } + + if (app.isMobile) { + app.controls.openLoginForm({ + defaultLocked: props.locked, + }) + } } return