X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9f472b932176e09be950115feab148da3be5c321..1df2b7a4d6f599828f9ba81b325382fe5947e281:/src/components/form-dialog/form-dialog.tsx

diff --git a/src/components/form-dialog/form-dialog.tsx b/src/components/form-dialog/form-dialog.tsx
index dee89249e2..6970a38af8 100644
--- a/src/components/form-dialog/form-dialog.tsx
+++ b/src/components/form-dialog/form-dialog.tsx
@@ -16,40 +16,46 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
     },
     lastButton: {
         marginLeft: theme.spacing.unit,
-        marginRight: "20px",
+        marginRight: "0",
     },
     formContainer: {
         display: "flex",
         flexDirection: "column",
-        marginTop: "20px",
+        paddingBottom: "0",
     },
     dialogTitle: {
-        paddingBottom: "0"
+        paddingTop: theme.spacing.unit,
+        paddingBottom: theme.spacing.unit,
     },
     progressIndicator: {
         position: "absolute",
         minWidth: "20px",
     },
     dialogActions: {
-        marginBottom: "24px"
+        marginBottom: theme.spacing.unit,
+        marginRight: theme.spacing.unit * 3,
     }
 });
 
-interface DialogProjectProps {
+interface DialogProjectDataProps {
     cancelLabel?: string;
     dialogTitle: string;
     formFields: React.ComponentType<InjectedFormProps<any> & WithDialogProps<any>>;
     submitLabel?: string;
+    enableWhenPristine?: boolean;
 }
 
-export const FormDialog = withStyles(styles)((props: DialogProjectProps & WithDialogProps<{}> & InjectedFormProps<any> & WithStyles<CssRules>) =>
+type DialogProjectProps = DialogProjectDataProps & WithDialogProps<{}> & InjectedFormProps<any> & WithStyles<CssRules>;
+
+export const FormDialog = withStyles(styles)((props: DialogProjectProps) =>
     <Dialog
         open={props.open}
         onClose={props.closeDialog}
-        disableBackdropClick={props.submitting}
+        disableBackdropClick
         disableEscapeKeyDown={props.submitting}
-        fullWidth>
-        <form>
+        fullWidth
+        maxWidth='md'>
+        <form data-cy='form-dialog'>
             <DialogTitle className={props.classes.dialogTitle}>
                 {props.dialogTitle}
             </DialogTitle>
@@ -58,6 +64,7 @@ export const FormDialog = withStyles(styles)((props: DialogProjectProps & WithDi
             </DialogContent>
             <DialogActions className={props.classes.dialogActions}>
                 <Button
+                    data-cy='form-cancel-btn'
                     onClick={props.closeDialog}
                     className={props.classes.button}
                     color="primary"
@@ -65,10 +72,12 @@ export const FormDialog = withStyles(styles)((props: DialogProjectProps & WithDi
                     {props.cancelLabel || 'Cancel'}
                 </Button>
                 <Button
+                    data-cy='form-submit-btn'
+                    type="submit"
                     onClick={props.handleSubmit}
                     className={props.classes.lastButton}
                     color="primary"
-                    disabled={props.invalid || props.submitting || props.pristine}
+                    disabled={props.invalid || props.submitting || (props.pristine && !props.enableWhenPristine)}
                     variant="contained">
                     {props.submitLabel || 'Submit'}
                     {props.submitting && <CircularProgress size={20} className={props.classes.progressIndicator} />}
@@ -77,5 +86,3 @@ export const FormDialog = withStyles(styles)((props: DialogProjectProps & WithDi
         </form>
     </Dialog>
 );
-
-
