X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1933452553965a2066191eccaaa40943d6d5c5d8..109103ee47da299c04ffdcabebc38bcd665555d9:/src/views-components/dialog-create/dialog-project-create.tsx

diff --git a/src/views-components/dialog-create/dialog-project-create.tsx b/src/views-components/dialog-create/dialog-project-create.tsx
index 475f83714d..48b89115e4 100644
--- a/src/views-components/dialog-create/dialog-project-create.tsx
+++ b/src/views-components/dialog-create/dialog-project-create.tsx
@@ -8,13 +8,15 @@ import Dialog from '@material-ui/core/Dialog';
 import DialogActions from '@material-ui/core/DialogActions';
 import DialogContent from '@material-ui/core/DialogContent';
 import DialogTitle from '@material-ui/core/DialogTitle';
-import { Button, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
+import { Button, StyleRulesCallback, WithStyles, withStyles, CircularProgress } from '@material-ui/core';
 
 import Validator from '../../utils/dialog-validator';
 
 interface ProjectCreateProps {
   open: boolean;
+  pending: boolean;
   handleClose: () => void;
+  onSubmit: (data: { name: string, description: string }) => void;
 }
 
 interface DialogState {
@@ -33,8 +35,8 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
   };
 
   render() {
-    const { name, description } = this.state;
-    const { classes, open, handleClose } = this.props;
+    const { name, description, isNameValid, isDescriptionValid } = this.state;
+    const { classes, open, handleClose, pending } = this.props;
 
     return (
       <Dialog
@@ -71,14 +73,28 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
                   fullWidth />} />
           </DialogContent>
           <DialogActions>
-            <Button onClick={handleClose} className={classes.button} color="primary">CANCEL</Button>
-            <Button onClick={handleClose} className={classes.lastButton} color="primary" disabled={!this.state.isNameValid || (!this.state.isDescriptionValid && description.length > 0)} variant="raised">CREATE A PROJECT</Button>
+            <Button onClick={handleClose} className={classes.button} color="primary" disabled={pending}>CANCEL</Button>
+            <Button onClick={this.handleSubmit} 
+              className={classes.lastButton} 
+              color="primary" 
+              disabled={!isNameValid || (!isDescriptionValid && description.length > 0) || pending} 
+              variant="contained">
+              CREATE A PROJECT
+              </Button>
+              {pending && <CircularProgress size={20} className={classes.createProgress} />}
           </DialogActions>
         </div>
       </Dialog>
     );
   }
 
+  handleSubmit = () => {
+    this.props.onSubmit({
+      name: this.state.name,
+      description: this.state.description
+    });
+  }
+
   handleProjectName(e: any) {
     this.setState({
       name: e.target.value,
@@ -104,7 +120,7 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
   }
 }
 
-type CssRules = "button" | "lastButton" | "dialogContent" | "textField" | "dialog" | "dialogTitle";
+type CssRules = "button" | "lastButton" | "dialogContent" | "textField" | "dialog" | "dialogTitle" | "createProgress";
 
 const styles: StyleRulesCallback<CssRules> = theme => ({
   button: {
@@ -126,6 +142,11 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
   dialog: {
     minWidth: "600px",
     minHeight: "320px"
+  },
+  createProgress: {
+    position: "absolute",
+    minWidth: "20px",
+    right: "95px"
   }
 });
 
