Merge branch 'jszlenk/create_new_subproject' refs #21937
[arvados.git] / services / workbench2 / src / views-components / dialog-forms / create-project-dialog.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { compose } from "redux";
6 import { reduxForm } from 'redux-form';
7 import { withDialog } from "store/dialog/with-dialog";
8 import { PROJECT_CREATE_FORM_NAME, ProjectCreateFormDialogData } from 'store/projects/project-create-actions';
9 import { DialogProjectCreate } from 'views-components/dialog-create/dialog-project-create';
10 import { createProject } from "store/workbench/workbench-actions";
11 import { GroupClass } from "models/group";
12 import { createGroup } from "store/groups-panel/groups-panel-actions";
13
14 export const CreateProjectDialog = compose(
15     withDialog(PROJECT_CREATE_FORM_NAME),
16     reduxForm<ProjectCreateFormDialogData>({
17         form: PROJECT_CREATE_FORM_NAME,
18         onSubmit: (data, dispatch, props) => {
19             switch (props.data.sourcePanel) {
20                 case GroupClass.PROJECT:
21                     dispatch(createProject(data));
22                     break;
23                 case GroupClass.ROLE:
24                     dispatch(createGroup(data));
25                     break;
26                 default:
27                     break;
28             }
29         }
30     })
31 )(DialogProjectCreate);