From 991fed565e258c8d94d2f6ed4b3a3eeed78b31fb Mon Sep 17 00:00:00 2001 From: yangon <2689991790@qq.com> Date: Wed, 28 Aug 2024 11:55:05 +0800 Subject: [PATCH] Optimize CustomModal (#528) --- .../customModal/ActivateTenantModal.tsx | 8 ++--- ui/src/components/customModal/AddNSModal.tsx | 8 ++--- .../components/customModal/AddZoneModal.tsx | 8 ++--- .../customModal/HandleAccountModal.tsx | 6 ++-- .../customModal/HandleRoleModal.tsx | 6 ++-- .../components/customModal/LogReplayModal.tsx | 8 ++--- .../customModal/ModifyPasswordModal.tsx | 8 ++--- .../customModal/ModifyUnitDetailModal.tsx | 8 ++--- .../customModal/ModifyUnitModal.tsx | 8 ++--- ui/src/components/customModal/MyInfoModal.tsx | 15 +++++---- .../components/customModal/ResetPwdModal.tsx | 6 ++-- ui/src/components/customModal/ScaleModal.tsx | 6 ++-- .../customModal/SwitchTenantModal.tsx | 8 ++--- .../components/customModal/UpgradeModal.tsx | 8 ++--- .../customModal/UpgradeTenantModal.tsx | 8 ++--- ui/src/components/customModal/index.tsx | 33 ++++++++----------- ui/src/i18n/strings/zh-CN.json | 2 +- ui/src/pages/Access/Accounts.tsx | 3 +- ui/src/pages/Access/Roles.tsx | 1 + ui/src/pages/Layouts/BasicLayout/index.tsx | 9 ++++- ui/src/pages/Login/index.tsx | 25 ++++++++++---- 21 files changed, 104 insertions(+), 88 deletions(-) diff --git a/ui/src/components/customModal/ActivateTenantModal.tsx b/ui/src/components/customModal/ActivateTenantModal.tsx index c216c9e4d..cb2b93b70 100644 --- a/ui/src/components/customModal/ActivateTenantModal.tsx +++ b/ui/src/components/customModal/ActivateTenantModal.tsx @@ -31,7 +31,7 @@ export default function ActivateTenantModal({ const handleSubmit = async () => { await activateTenant({ ns, name, failover: true }); }; - const handleCancel = () => setVisible(false); + const onCancel = () => setVisible(false); return (

{intl.formatMessage({ diff --git a/ui/src/components/customModal/AddNSModal.tsx b/ui/src/components/customModal/AddNSModal.tsx index c9e07d094..ce65d626f 100644 --- a/ui/src/components/customModal/AddNSModal.tsx +++ b/ui/src/components/customModal/AddNSModal.tsx @@ -39,7 +39,7 @@ export default function AddNSModal({ form.submit(); } catch (err) {} }; - const handleCancel = () => setVisible(false); + const onCancel = () => setVisible(false); const onFinish = async (val: FormData) => { newNamespace.current = val.namespace; await createNS(val.namespace); @@ -50,9 +50,9 @@ export default function AddNSModal({ id: 'OBDashboard.components.customModal.AddNSModal.AddNamespace', defaultMessage: '新增命名空间', })} - isOpen={visible} - handleOk={handleSubmit} - handleCancel={handleCancel} + open={visible} + onOk={handleSubmit} + onCancel={onCancel} >

{ + const onCancel = () => { form.resetFields(); setVisible(false); }; @@ -62,9 +62,9 @@ export default function AddZoneModal({ id: 'OBDashboard.components.customModal.AddZoneModal.AddZone', defaultMessage: '新增Zone', })} - isOpen={visible} - handleOk={handleSubmit} - handleCancel={handleCancel} + open={visible} + onOk={handleSubmit} + onCancel={onCancel} > { + open={visible} + onOk={handleSubmit} + onCancel={() => { form.resetFields(); setVisible(false); }} diff --git a/ui/src/components/customModal/HandleRoleModal.tsx b/ui/src/components/customModal/HandleRoleModal.tsx index b14df28fd..65a07d860 100644 --- a/ui/src/components/customModal/HandleRoleModal.tsx +++ b/ui/src/components/customModal/HandleRoleModal.tsx @@ -227,9 +227,9 @@ export default function HandleRoleModal({ }), }, )} - isOpen={visible} - handleOk={handleSubmit} - handleCancel={() => { + open={visible} + onOk={handleSubmit} + onCancel={() => { form.resetFields(); setVisible(false); }} diff --git a/ui/src/components/customModal/LogReplayModal.tsx b/ui/src/components/customModal/LogReplayModal.tsx index 47ee3834b..cea77fa9c 100644 --- a/ui/src/components/customModal/LogReplayModal.tsx +++ b/ui/src/components/customModal/LogReplayModal.tsx @@ -24,7 +24,7 @@ export default function LogReplayModal({ } catch (err) {} }; - const handleCancel = () => setVisible(false); + const onCancel = () => setVisible(false); const onFinish = async (values: any) => { const res = await replayLogOfTenant({ namespace, name, ...values }); if (res.successful) { @@ -46,9 +46,9 @@ export default function LogReplayModal({ id: 'Dashboard.components.customModal.LogReplayModal.StandbyTenantLogPlayback', defaultMessage: '备租户日志回放', })} - isOpen={visible} - handleOk={handleSubmit} - handleCancel={handleCancel} + open={visible} + onOk={handleSubmit} + onCancel={onCancel} > setVisible(false); + const onCancel = () => setVisible(false); const onFinish = async (values: any) => { const res = await changeTenantPassword({ ns, @@ -53,9 +53,9 @@ export default function ModifyPasswordModal({ id: 'Dashboard.components.customModal.ModifyPasswordModal.ModifyRootPassword', defaultMessage: '修改 root 密码', })} - isOpen={visible} - handleOk={handleSubmit} - handleCancel={handleCancel} + open={visible} + onOk={handleSubmit} + onCancel={onCancel} > { + const onCancel = () => { if (setEditZone) { setEditZone(''); setSelectZones([]); @@ -255,9 +255,9 @@ export default function ModifyUnitDetailModal({ defaultMessage: '编辑资源池', }) } - isOpen={visible} - handleOk={handleSubmit} - handleCancel={handleCancel} + open={visible} + onOk={handleSubmit} + onCancel={onCancel} > setVisible(false); + const onCancel = () => setVisible(false); const onFinish = async (values: any) => { const res = await modifyUnitNumReportWrap({ ns, @@ -61,9 +61,9 @@ export default function ModifyUnitModal({ id: 'Dashboard.components.customModal.ModifyUnitModal.ModifyTheNumberOfUnits', defaultMessage: '修改 Unit 数量', })} - isOpen={visible} - handleOk={handleSubmit} - handleCancel={handleCancel} + open={visible} + onOk={handleSubmit} + onCancel={onCancel} > { + open={visible} + onCancel={() => { setVisible(false); }} + maskClosable={true} footer={