[ARVADOS-WORKBENCH2] updated: 1.1.4-252-g0240e28
Git user
git at public.curoverse.com
Tue Jul 10 07:22:53 EDT 2018
Summary of changes:
src/store/project/project-action.ts | 11 +++++++----
src/store/project/project-reducer.ts | 2 +-
.../create-project-dialog/create-project-dialog.tsx | 5 ++++-
src/views-components/dialog-create/dialog-project-create.tsx | 10 +++++++++-
4 files changed, 21 insertions(+), 7 deletions(-)
via 0240e28950f94b0911f2b22d55cc719d94bdff0e (commit)
from 1933452553965a2066191eccaaa40943d6d5c5d8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 0240e28950f94b0911f2b22d55cc719d94bdff0e
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Tue Jul 10 13:22:24 2018 +0200
Handle project form submission
Feature #13694
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/store/project/project-action.ts b/src/store/project/project-action.ts
index 184922e..c1a002f 100644
--- a/src/store/project/project-action.ts
+++ b/src/store/project/project-action.ts
@@ -9,9 +9,10 @@ import { Dispatch } from "redux";
import { getResourceKind } from "../../models/resource";
import FilterBuilder from "../../common/api/filter-builder";
import { ThunkAction } from "../../../node_modules/redux-thunk";
+import { RootState } from "../store";
const actions = unionize({
- OPEN_PROJECT_CREATOR: ofType<{ownerUuid: string}>(),
+ OPEN_PROJECT_CREATOR: ofType<{ ownerUuid: string }>(),
CLOSE_PROJECT_CREATOR: ofType<{}>(),
CREATE_PROJECT: ofType<Partial<ProjectResource>>(),
CREATE_PROJECT_SUCCESS: ofType<ProjectResource>(),
@@ -44,10 +45,12 @@ export const getProjectList = (parentUuid: string = '') => (dispatch: Dispatch)
};
export const createProject = (project: Partial<ProjectResource>) =>
- (dispatch: Dispatch) => {
- dispatch(actions.CREATE_PROJECT(project));
+ (dispatch: Dispatch, getState: () => RootState) => {
+ const { ownerUuid } = getState().projects.creator;
+ const projectData = { ownerUuid, ...project };
+ dispatch(actions.CREATE_PROJECT(projectData));
return projectService
- .create(project)
+ .create(projectData)
.then(project => dispatch(actions.CREATE_PROJECT_SUCCESS(project)))
.catch(() => dispatch(actions.CREATE_PROJECT_ERROR("Could not create a project")));
};
diff --git a/src/store/project/project-reducer.ts b/src/store/project/project-reducer.ts
index 2c1ab81..8ee9e9f 100644
--- a/src/store/project/project-reducer.ts
+++ b/src/store/project/project-reducer.ts
@@ -115,7 +115,7 @@ const projectsReducer = (state: ProjectState = initialState, action: ProjectActi
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, { pending: true }),
+ CREATE_PROJECT: () => updateCreator(state, { opened: false, pending: true }),
CREATE_PROJECT_SUCCESS: () => updateCreator(state, { ownerUuid: "", pending: false }),
CREATE_PROJECT_ERROR: () => updateCreator(state, { ownerUuid: "", pending: false }),
REMOVE_PROJECT: () => state,
diff --git a/src/views-components/create-project-dialog/create-project-dialog.tsx b/src/views-components/create-project-dialog/create-project-dialog.tsx
index c7a7852..c1d4e06 100644
--- a/src/views-components/create-project-dialog/create-project-dialog.tsx
+++ b/src/views-components/create-project-dialog/create-project-dialog.tsx
@@ -6,7 +6,7 @@ import { connect } from "react-redux";
import { Dispatch } from "../../../node_modules/redux";
import { RootState } from "../../store/store";
import DialogProjectCreate from "../dialog-create/dialog-project-create";
-import actions from "../../store/project/project-action";
+import actions, { createProject } from "../../store/project/project-action";
const mapStateToProps = (state: RootState) => ({
open: state.projects.creator.opened
@@ -15,6 +15,9 @@ const mapStateToProps = (state: RootState) => ({
const mapDispatchToProps = (dispatch: Dispatch) => ({
handleClose: () => {
dispatch(actions.CLOSE_PROJECT_CREATOR());
+ },
+ onSubmit: (data: { name: string, description: string }) => {
+ dispatch<any>(createProject(data));
}
});
diff --git a/src/views-components/dialog-create/dialog-project-create.tsx b/src/views-components/dialog-create/dialog-project-create.tsx
index 475f837..ef07ea2 100644
--- a/src/views-components/dialog-create/dialog-project-create.tsx
+++ b/src/views-components/dialog-create/dialog-project-create.tsx
@@ -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 {
@@ -72,13 +73,20 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
</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={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>
);
}
+ handleSubmit = () => {
+ this.props.onSubmit({
+ name: this.state.name,
+ description: this.state.description
+ });
+ }
+
handleProjectName(e: any) {
this.setState({
name: e.target.value,
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list