1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { reduxForm, reset, InjectedFormProps } from 'redux-form';
7 import { PROJECT_CREATE_PROPERTIES_FORM_NAME, addPropertyToCreateProjectForm } from '~/store/projects/project-create-actions';
8 import { ResourcePropertiesFormData } from '~/views-components/resource-properties-form/resource-properties-form';
9 import { StyleRulesCallback, WithStyles, withStyles, Grid } from '@material-ui/core';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { PropertyKeyField } from '~/views-components/resource-properties-form/property-key-field';
12 import { PropertyValueField } from '~/views-components/resource-properties-form/property-value-field';
13 import { Button } from '~/views-components/resource-properties-form/resource-properties-form';
15 type CssRules = 'root';
17 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
19 paddingTop: theme.spacing.unit,
24 type CreateProjectPropertiesFormProps = InjectedFormProps<ResourcePropertiesFormData> & WithStyles<CssRules>;
26 const Form = withStyles(styles)(
27 ({ handleSubmit, submitting, invalid, classes }: CreateProjectPropertiesFormProps) =>
28 <Grid container spacing={16} className={classes.root}>
33 <PropertyValueField />
41 onClick={handleSubmit}>
48 export const CreateProjectPropertiesForm = reduxForm<ResourcePropertiesFormData>({
49 form: PROJECT_CREATE_PROPERTIES_FORM_NAME,
50 onSubmit: (data, dispatch) => {
51 dispatch(addPropertyToCreateProjectForm(data));
52 dispatch(reset(PROJECT_CREATE_PROPERTIES_FORM_NAME));