From ac0c17396f9b06ac8c47775f1b2b460effb27006 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 25 Nov 2022 16:16:41 -0500 Subject: [PATCH] fix(striker-ui): don't close onProceed by default in ConfirmDialog --- striker-ui/components/ConfirmDialog.tsx | 8 +++++++- striker-ui/components/PrepareHostForm.tsx | 1 + striker-ui/components/StrikerConfig/ConfigPeersForm.tsx | 6 +++++- .../components/StrikerConfig/ManageChangedSSHKeysForm.tsx | 6 +++++- striker-ui/pages/config/index.tsx | 1 + striker-ui/types/ConfirmDialog.d.ts | 2 ++ 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/striker-ui/components/ConfirmDialog.tsx b/striker-ui/components/ConfirmDialog.tsx index 145067da..29e1aca4 100644 --- a/striker-ui/components/ConfirmDialog.tsx +++ b/striker-ui/components/ConfirmDialog.tsx @@ -23,12 +23,14 @@ const ConfirmDialog = forwardRef< { actionCancelText = 'Cancel', actionProceedText, + closeOnProceed = false, content, dialogProps: { open: baseOpen = false, PaperProps: paperProps = {}, ...restDialogProps } = {}, + onActionAppend, onCancelAppend, onProceedAppend, openInitially = false, @@ -95,6 +97,7 @@ const ConfirmDialog = forwardRef< onClick={(...args) => { setIsOpen(false); + onActionAppend?.call(null, ...args); onCancelAppend?.call(null, ...args); }} > @@ -102,8 +105,11 @@ const ConfirmDialog = forwardRef< { - setIsOpen(false); + if (closeOnProceed) { + setIsOpen(false); + } + onActionAppend?.call(null, ...args); onProceedAppend?.call(null, ...args); }} {...restProceedButtonProps} diff --git a/striker-ui/components/PrepareHostForm.tsx b/striker-ui/components/PrepareHostForm.tsx index 8d9330ad..185ab4d0 100644 --- a/striker-ui/components/PrepareHostForm.tsx +++ b/striker-ui/components/PrepareHostForm.tsx @@ -556,6 +556,7 @@ const PrepareHostForm: FC = () => { ({ diff --git a/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx b/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx index e10437e3..4f18a79b 100644 --- a/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx +++ b/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx @@ -225,7 +225,11 @@ const ConfigPeersForm: FC = ({ - + ); }; diff --git a/striker-ui/components/StrikerConfig/ManageChangedSSHKeysForm.tsx b/striker-ui/components/StrikerConfig/ManageChangedSSHKeysForm.tsx index 4f8052d9..128e2c94 100644 --- a/striker-ui/components/StrikerConfig/ManageChangedSSHKeysForm.tsx +++ b/striker-ui/components/StrikerConfig/ManageChangedSSHKeysForm.tsx @@ -225,7 +225,11 @@ const ManageChangedSSHKeysForm: FC = ({ {apiMessageElement} - + ); }; diff --git a/striker-ui/pages/config/index.tsx b/striker-ui/pages/config/index.tsx index 197478ab..0513b3d0 100644 --- a/striker-ui/pages/config/index.tsx +++ b/striker-ui/pages/config/index.tsx @@ -25,6 +25,7 @@ const Config: FC<{ refreshInterval?: number }> = ({ const [confirmDialogProps, setConfirmDialogProps] = useState({ actionProceedText: '', + closeOnProceed: true, content: '', dialogProps: { open: isOpenConfirmDialog }, onCancelAppend: () => { diff --git a/striker-ui/types/ConfirmDialog.d.ts b/striker-ui/types/ConfirmDialog.d.ts index bc7d10b3..707869f1 100644 --- a/striker-ui/types/ConfirmDialog.d.ts +++ b/striker-ui/types/ConfirmDialog.d.ts @@ -1,6 +1,8 @@ type ConfirmDialogOptionalProps = { actionCancelText?: string; + closeOnProceed?: boolean; dialogProps?: Partial; + onActionAppend?: ContainedButtonProps['onClick']; onProceedAppend?: ContainedButtonProps['onClick']; onCancelAppend?: ContainedButtonProps['onClick']; openInitially?: boolean;