fix(striker-ui): don't close onProceed by default in ConfirmDialog

main
Tsu-ba-me 2 years ago
parent 4c13c7c15a
commit ac0c17396f
  1. 6
      striker-ui/components/ConfirmDialog.tsx
  2. 1
      striker-ui/components/PrepareHostForm.tsx
  3. 6
      striker-ui/components/StrikerConfig/ConfigPeersForm.tsx
  4. 6
      striker-ui/components/StrikerConfig/ManageChangedSSHKeysForm.tsx
  5. 1
      striker-ui/pages/config/index.tsx
  6. 2
      striker-ui/types/ConfirmDialog.d.ts

@ -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<
</ContainedButton>
<ContainedButton
onClick={(...args) => {
if (closeOnProceed) {
setIsOpen(false);
}
onActionAppend?.call(null, ...args);
onProceedAppend?.call(null, ...args);
}}
{...restProceedButtonProps}

@ -556,6 +556,7 @@ const PrepareHostForm: FC = () => {
</Panel>
<ConfirmDialog
actionProceedText="Prepare"
closeOnProceed
content={
<Grid
calculateItemBreakpoints={(index) => ({

@ -225,7 +225,11 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
</Grid>
</ExpandablePanel>
<AddPeerDialog ref={addPeerDialogRef} />
<ConfirmDialog {...confirmDialogProps} ref={confirmDialogRef} />
<ConfirmDialog
closeOnProceed
{...confirmDialogProps}
ref={confirmDialogRef}
/>
</>
);
};

@ -225,7 +225,11 @@ const ManageChangedSSHKeysForm: FC<ManageChangedSSHKeysFormProps> = ({
</FlexBox>
{apiMessageElement}
</ExpandablePanel>
<ConfirmDialog {...confirmDialogProps} ref={confirmDialogRef} />
<ConfirmDialog
closeOnProceed
{...confirmDialogProps}
ref={confirmDialogRef}
/>
</>
);
};

@ -25,6 +25,7 @@ const Config: FC<{ refreshInterval?: number }> = ({
const [confirmDialogProps, setConfirmDialogProps] =
useState<ConfirmDialogProps>({
actionProceedText: '',
closeOnProceed: true,
content: '',
dialogProps: { open: isOpenConfirmDialog },
onCancelAppend: () => {

@ -1,6 +1,8 @@
type ConfirmDialogOptionalProps = {
actionCancelText?: string;
closeOnProceed?: boolean;
dialogProps?: Partial<import('@mui/material').DialogProps>;
onActionAppend?: ContainedButtonProps['onClick'];
onProceedAppend?: ContainedButtonProps['onClick'];
onCancelAppend?: ContainedButtonProps['onClick'];
openInitially?: boolean;

Loading…
Cancel
Save