Merge branch 'master' into 15067-tag-editing-by-ids
[arvados-workbench2.git] / src / views-components / resource-properties-form / resource-properties-form.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { InjectedFormProps } from 'redux-form';
7 import { Grid, withStyles, WithStyles } from '@material-ui/core';
8 import { PropertyKeyField, PROPERTY_KEY_FIELD_NAME, PROPERTY_KEY_FIELD_ID } from './property-key-field';
9 import { PropertyValueField, PROPERTY_VALUE_FIELD_NAME, PROPERTY_VALUE_FIELD_ID } from './property-value-field';
10 import { ProgressButton } from '~/components/progress-button/progress-button';
11 import { GridClassKey } from '@material-ui/core/Grid';
12
13 export interface ResourcePropertiesFormData {
14     [PROPERTY_KEY_FIELD_NAME]: string;
15     [PROPERTY_KEY_FIELD_ID]: string;
16     [PROPERTY_VALUE_FIELD_NAME]: string;
17     [PROPERTY_VALUE_FIELD_ID]: string;
18 }
19
20 export type ResourcePropertiesFormProps = InjectedFormProps<ResourcePropertiesFormData> & WithStyles<GridClassKey>;
21
22 export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid, classes }: ResourcePropertiesFormProps ) =>
23     <form onSubmit={handleSubmit}>
24         <Grid container spacing={16} classes={classes}>
25             <Grid item xs>
26                 <PropertyKeyField />
27             </Grid>
28             <Grid item xs>
29                 <PropertyValueField />
30             </Grid>
31             <Grid item xs>
32                 <Button
33                     disabled={invalid}
34                     loading={submitting}
35                     color='primary'
36                     variant='contained'
37                     type='submit'>
38                     Add
39                 </Button>
40             </Grid>
41         </Grid>
42     </form>;
43
44 export const Button = withStyles(theme => ({
45     root: { marginTop: theme.spacing.unit }
46 }))(ProgressButton);