1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import TextField from '@material-ui/core/TextField';
7 import Dialog from '@material-ui/core/Dialog';
8 import DialogActions from '@material-ui/core/DialogActions';
9 import DialogContent from '@material-ui/core/DialogContent';
10 import DialogTitle from '@material-ui/core/DialogTitle';
11 import { Button, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
13 import Validator from '../../utils/dialog-validator';
15 interface ProjectCreateProps {
17 handleClose: () => void;
20 interface DialogState {
24 isDescriptionValid: boolean;
27 class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyles<CssRules>> {
28 state: DialogState = {
32 isDescriptionValid: true
36 const { name, description } = this.state;
37 const { classes, open, handleClose } = this.props;
42 onClose={handleClose}>
43 <div className={classes.dialog}>
44 <DialogTitle id="form-dialog-title" className={classes.dialogTitle}>Create a project</DialogTitle>
45 <DialogContent className={classes.dialogContent}>
48 onChange={e => this.isNameValid(e)}
53 className={classes.textField}
55 onChange={e => this.handleProjectName(e)}
61 onChange={e => this.isDescriptionValid(e)}
66 className={classes.textField}
68 onChange={e => this.handleDescriptionValue(e)}
69 label="Description - optional"
74 <Button onClick={handleClose} className={classes.button} color="primary">CANCEL</Button>
75 <Button onClick={handleClose} className={classes.lastButton} color="primary" disabled={!this.state.isNameValid || (!this.state.isDescriptionValid && description.length > 0)} variant="raised">CREATE A PROJECT</Button>
82 handleProjectName(e: any) {
88 handleDescriptionValue(e: any) {
90 description: e.target.value,
94 isNameValid(value: boolean | string) {
100 isDescriptionValid(value: boolean | string) {
102 isDescriptionValid: value,
107 type CssRules = "button" | "lastButton" | "dialogContent" | "textField" | "dialog" | "dialogTitle";
109 const styles: StyleRulesCallback<CssRules> = theme => ({
111 marginLeft: theme.spacing.unit
114 marginLeft: theme.spacing.unit,
132 export default withStyles(styles)(DialogProjectCreate);