1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { InjectedFormProps } from 'redux-form';
7 import { WithDialogProps } from 'store/dialog/with-dialog';
8 import { ProjectCreateFormDialogData, PROJECT_CREATE_FORM_NAME } from 'store/projects/project-create-actions';
9 import { FormDialog } from 'components/form-dialog/form-dialog';
10 import { ProjectNameField, ProjectDescriptionField, UsersField } from 'views-components/form-fields/project-form-fields';
11 import { CreateProjectPropertiesForm } from 'views-components/project-properties/create-project-properties-form';
12 import { ResourceParentField } from '../form-fields/resource-form-fields';
13 import { FormGroup, FormLabel, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
14 import { resourcePropertiesList } from 'views-components/resource-properties/resource-properties-list';
15 import { GroupClass } from 'models/group';
17 type CssRules = 'propertiesForm' | 'description';
19 const styles: StyleRulesCallback<CssRules> = theme => ({
21 marginTop: theme.spacing.unit * 2,
22 marginBottom: theme.spacing.unit * 2,
25 marginTop: theme.spacing.unit * 2,
26 marginBottom: theme.spacing.unit * 2,
30 type DialogProjectProps = WithDialogProps<{sourcePanel: GroupClass}> & InjectedFormProps<ProjectCreateFormDialogData>;
32 export const DialogProjectCreate = (props: DialogProjectProps) => {
33 let title = 'New Project';
34 let fields = ProjectAddFields;
35 const sourcePanel = props.data.sourcePanel || '';
37 if (sourcePanel === GroupClass.ROLE) {
39 fields = GroupAddFields;
44 formFields={fields as any}
50 const CreateProjectPropertiesList = resourcePropertiesList(PROJECT_CREATE_FORM_NAME);
52 const ProjectAddFields = withStyles(styles)(
53 ({ classes }: WithStyles<CssRules>) => <span>
54 <ResourceParentField />
56 <div className={classes.description}>
57 <ProjectDescriptionField />
59 <div className={classes.propertiesForm}>
60 <FormLabel>Properties</FormLabel>
62 <CreateProjectPropertiesForm />
63 <CreateProjectPropertiesList />
68 const GroupAddFields = withStyles(styles)(
69 ({ classes }: WithStyles<CssRules>) => <span>
72 <div className={classes.description}>
73 <ProjectDescriptionField />
75 <div className={classes.propertiesForm}>
76 <FormLabel>Properties</FormLabel>
78 <CreateProjectPropertiesForm />
79 <CreateProjectPropertiesList />