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

main
Tsu-ba-me 2 years ago
parent 4c13c7c15a
commit ac0c17396f
  1. 8
      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', actionCancelText = 'Cancel',
actionProceedText, actionProceedText,
closeOnProceed = false,
content, content,
dialogProps: { dialogProps: {
open: baseOpen = false, open: baseOpen = false,
PaperProps: paperProps = {}, PaperProps: paperProps = {},
...restDialogProps ...restDialogProps
} = {}, } = {},
onActionAppend,
onCancelAppend, onCancelAppend,
onProceedAppend, onProceedAppend,
openInitially = false, openInitially = false,
@ -95,6 +97,7 @@ const ConfirmDialog = forwardRef<
onClick={(...args) => { onClick={(...args) => {
setIsOpen(false); setIsOpen(false);
onActionAppend?.call(null, ...args);
onCancelAppend?.call(null, ...args); onCancelAppend?.call(null, ...args);
}} }}
> >
@ -102,8 +105,11 @@ const ConfirmDialog = forwardRef<
</ContainedButton> </ContainedButton>
<ContainedButton <ContainedButton
onClick={(...args) => { onClick={(...args) => {
setIsOpen(false); if (closeOnProceed) {
setIsOpen(false);
}
onActionAppend?.call(null, ...args);
onProceedAppend?.call(null, ...args); onProceedAppend?.call(null, ...args);
}} }}
{...restProceedButtonProps} {...restProceedButtonProps}

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

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

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

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

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

Loading…
Cancel
Save