merge-conflicts
[arvados.git] / src / views-components / dialog-create / dialog-project-create.tsx
index 4cdf7468248e60e324b0a3e425dc9630156448ce..89deea6f86d8bfc94a7c36859c15a30b73c1faa8 100644 (file)
@@ -15,6 +15,7 @@ import Validator from '../../utils/dialog-validator';
 interface ProjectCreateProps {
   open: boolean;
   handleClose: () => void;
+  onSubmit: (data: { name: string, description: string }) => void;
 }
 
 interface DialogState {
@@ -28,7 +29,7 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
   state: DialogState = {
     name: '',
     description: '',
-    isNameValid: true,
+    isNameValid: false,
     isDescriptionValid: true
   };
 
@@ -70,22 +71,29 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
                   error={hasError}
                   fullWidth />} />
           </DialogContent>
-          <DialogActions className={classes.dialogActions}>
+          <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={this.handleSubmit} className={classes.lastButton} color="primary" disabled={!this.state.isNameValid || (!this.state.isDescriptionValid && description.length > 0)} variant="raised">CREATE A PROJECT</Button>
           </DialogActions>
         </div>
       </Dialog>
     );
   }
 
-  handleProjectName(e: any) {
+  handleSubmit = () => {
+    this.props.onSubmit({
+      name: this.state.name,
+      description: this.state.description
+    });
+  }
+
+  handleProjectName(e: React.ChangeEvent<HTMLInputElement>) {
     this.setState({
       name: e.target.value,
     });
   }
 
-  handleDescriptionValue(e: any) {
+  handleDescriptionValue(e: React.ChangeEvent<HTMLInputElement>) {
     this.setState({
       description: e.target.value,
     });
@@ -104,7 +112,7 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
   }
 }
 
-type CssRules = "button" | "lastButton" | "dialogContent" | "textField" | "dialog" | "dialogTitle" | "dialogActions";
+type CssRules = "button" | "lastButton" | "dialogContent" | "textField" | "dialog" | "dialogTitle";
 
 const styles: StyleRulesCallback<CssRules> = theme => ({
   button: {
@@ -120,9 +128,6 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
   dialogTitle: {
     paddingBottom: "0"
   },
-  dialogActions: {
-    marginBottom: "5px"
-  },
   textField: {
     marginTop: "32px",
   },