From d65e25a10eba29a57d96d567d3a6a2a8b993af86 Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Fri, 9 Dec 2022 19:57:28 +0800 Subject: [PATCH] refactor(console): support close modal on `esc` pressed (#2627) --- .../components/Sidebar/components/Contact/index.tsx | 2 ++ .../console/src/components/ConfirmModal/index.tsx | 2 ++ packages/console/src/pages/ApiResources/index.tsx | 4 ++++ .../Applications/components/CreateForm/index.tsx | 7 ++++++- packages/console/src/pages/Applications/index.tsx | 9 +++++++-- .../pages/Connectors/components/CreateForm/index.tsx | 11 ++++++++++- .../src/pages/Settings/components/ChangePassword.tsx | 4 ++++ .../components/Welcome/GuideModal.tsx | 7 ++++++- .../ManageLanguage/LanguageEditor/index.tsx | 8 +++++++- .../pages/UserDetails/components/CreateSuccess.tsx | 8 +++++++- packages/console/src/pages/UserDetails/index.tsx | 4 ++++ packages/console/src/pages/Users/index.tsx | 4 ++++ packages/ui/src/components/ConfirmModal/AcModal.tsx | 2 ++ .../ui/src/components/ConfirmModal/MobileModal.tsx | 2 ++ 14 files changed, 67 insertions(+), 7 deletions(-) diff --git a/packages/console/src/components/AppContent/components/Sidebar/components/Contact/index.tsx b/packages/console/src/components/AppContent/components/Sidebar/components/Contact/index.tsx index 5904145c0..16a8b0328 100644 --- a/packages/console/src/components/AppContent/components/Sidebar/components/Contact/index.tsx +++ b/packages/console/src/components/AppContent/components/Sidebar/components/Contact/index.tsx @@ -19,9 +19,11 @@ const Contact = ({ isOpen, onCancel }: Props) => { return (
diff --git a/packages/console/src/components/ConfirmModal/index.tsx b/packages/console/src/components/ConfirmModal/index.tsx index 495053b80..dd85c6e93 100644 --- a/packages/console/src/components/ConfirmModal/index.tsx +++ b/packages/console/src/components/ConfirmModal/index.tsx @@ -39,9 +39,11 @@ const ConfirmModal = ({ }: ConfirmModalProps) => { return ( { }} /> { + setIsCreateFormOpen(false); + }} > { diff --git a/packages/console/src/pages/Applications/components/CreateForm/index.tsx b/packages/console/src/pages/Applications/components/CreateForm/index.tsx index ccf8c2722..ba5eee512 100644 --- a/packages/console/src/pages/Applications/components/CreateForm/index.tsx +++ b/packages/console/src/pages/Applications/components/CreateForm/index.tsx @@ -118,7 +118,12 @@ const CreateForm = ({ onClose }: Props) => { {createdApp && ( - + )} diff --git a/packages/console/src/pages/Applications/index.tsx b/packages/console/src/pages/Applications/index.tsx index 4442e7a9c..52f65dc06 100644 --- a/packages/console/src/pages/Applications/index.tsx +++ b/packages/console/src/pages/Applications/index.tsx @@ -54,18 +54,23 @@ const Applications = () => { }} /> { + navigate('/applications'); + }} > { - navigate('/applications'); - if (createdApp) { toast.success(t('applications.application_created', { name: createdApp.name })); navigate(`/applications/${createdApp.id}`); + + return; } + navigate('/applications'); }} /> diff --git a/packages/console/src/pages/Connectors/components/CreateForm/index.tsx b/packages/console/src/pages/Connectors/components/CreateForm/index.tsx index fa127654b..8cc3d233f 100644 --- a/packages/console/src/pages/Connectors/components/CreateForm/index.tsx +++ b/packages/console/src/pages/Connectors/components/CreateForm/index.tsx @@ -124,9 +124,13 @@ const CreateForm = ({ onClose, isOpen: isFormOpen, type }: Props) => { return ( { + onClose?.(); + }} > { /> )} {activeFactory && ( - + )} diff --git a/packages/console/src/pages/Settings/components/ChangePassword.tsx b/packages/console/src/pages/Settings/components/ChangePassword.tsx index f3903eecf..97e8372d2 100644 --- a/packages/console/src/pages/Settings/components/ChangePassword.tsx +++ b/packages/console/src/pages/Settings/components/ChangePassword.tsx @@ -60,9 +60,13 @@ const ChangePassword = () => {
{ + setIsOpen(false); + }} > { }; return ( - +
diff --git a/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/index.tsx b/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/index.tsx index a97263df4..15e24a1dc 100644 --- a/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/index.tsx +++ b/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/index.tsx @@ -71,7 +71,13 @@ const LanguageEditorModal = ({ isOpen, onClose }: Props) => { }; return ( - +
+ { { + setIsResetPasswordFormOpen(false); + }} > { }} /> { + setIsCreateFormOpen(false); + }} > { diff --git a/packages/ui/src/components/ConfirmModal/AcModal.tsx b/packages/ui/src/components/ConfirmModal/AcModal.tsx index 0ed4b1645..a019afe90 100644 --- a/packages/ui/src/components/ConfirmModal/AcModal.tsx +++ b/packages/ui/src/components/ConfirmModal/AcModal.tsx @@ -27,6 +27,7 @@ const AcModal = ({ return ( { contentRef.current?.focus(); }} + onRequestClose={onClose} >
{ return (
{children}