return actions.match(action, {
OPEN_PROJECT_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true, pending: false }),
CLOSE_PROJECT_CREATOR: () => updateCreator(state, { opened: false }),
- CREATE_PROJECT: () => updateCreator(state, { opened: false, pending: true }),
- CREATE_PROJECT_SUCCESS: () => updateCreator(state, { ownerUuid: "", pending: false }),
+ CREATE_PROJECT: () => updateCreator(state, { pending: true }),
+ CREATE_PROJECT_SUCCESS: () => updateCreator(state, { opened: false, ownerUuid: "", pending: false }),
CREATE_PROJECT_ERROR: () => updateCreator(state, { ownerUuid: "", pending: false }),
REMOVE_PROJECT: () => state,
PROJECTS_REQUEST: itemId => {
import { PROJECT_PANEL_ID } from "../../views/project-panel/project-panel";
const mapStateToProps = (state: RootState) => ({
- open: state.projects.creator.opened
+ open: state.projects.creator.opened,
+ pending: state.projects.creator.pending,
});
const submit = (data: { name: string, description: string }) =>
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;
}
};
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
</DialogContent>
<DialogActions>
<Button onClick={handleClose} className={classes.button} color="primary">CANCEL</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>
+ <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>
}
}
-type CssRules = "button" | "lastButton" | "dialogContent" | "textField" | "dialog" | "dialogTitle";
+type CssRules = "button" | "lastButton" | "dialogContent" | "textField" | "dialog" | "dialogTitle" | "createProgress";
const styles: StyleRulesCallback<CssRules> = theme => ({
button: {
dialog: {
minWidth: "600px",
minHeight: "320px"
+ },
+ createProgress: {
+ position: "absolute",
+ minWidth: "20px",
+ right: "95px"
}
});