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 { CustomStyleRulesCallback } from 'common/custom-theme';
14 import { FormGroup, FormLabel } from '@mui/material';
15 import { WithStyles } from '@mui/styles';
16 import withStyles from '@mui/styles/withStyles';
17 import { resourcePropertiesList } from 'views-components/resource-properties/resource-properties-list';
18 import { GroupClass } from 'models/group';
20 type CssRules = 'propertiesForm' | 'description';
22 const styles: CustomStyleRulesCallback<CssRules> = theme => ({
24 marginTop: theme.spacing(2),
25 marginBottom: theme.spacing(2),
28 marginTop: theme.spacing(2),
29 marginBottom: theme.spacing(2),
33 type DialogProjectProps = WithDialogProps<{sourcePanel: GroupClass}> & InjectedFormProps<ProjectCreateFormDialogData>;
35 export const DialogProjectCreate = (props: DialogProjectProps) => {
36 let title = 'New Project';
37 let fields = ProjectAddFields;
38 const sourcePanel = props.data.sourcePanel || '';
40 if (sourcePanel === GroupClass.ROLE) {
42 fields = GroupAddFields;
47 formFields={fields as any}
53 const CreateProjectPropertiesList = resourcePropertiesList(PROJECT_CREATE_FORM_NAME);
55 const ProjectAddFields = withStyles(styles)(
56 ({ classes }: WithStyles<CssRules>) => <span>
57 <ResourceParentField />
59 <div className={classes.description}>
60 <ProjectDescriptionField />
62 <div className={classes.propertiesForm}>
63 <FormLabel>Properties</FormLabel>
65 <CreateProjectPropertiesForm />
66 <CreateProjectPropertiesList />
71 const GroupAddFields = withStyles(styles)(
72 ({ classes }: WithStyles<CssRules>) => <span>
75 <div className={classes.description}>
76 <ProjectDescriptionField />
78 <div className={classes.propertiesForm}>
79 <FormLabel>Properties</FormLabel>
81 <CreateProjectPropertiesForm />
82 <CreateProjectPropertiesList />