Add classes prop to ResourcePropertiesForm
[arvados-workbench2.git] / src / views-components / resource-properties-form / resource-properties-form.tsx
index df9ff84925e92b0717cf8e7321700ecc7f38c2d7..a62b3d1563a8459333d7ae1be58c62ca97812256 100644 (file)
@@ -3,19 +3,23 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { InjectedFormProps, reduxForm } from 'redux-form';
-import { Grid, Button } from '@material-ui/core';
+import { InjectedFormProps } from 'redux-form';
+import { Grid, withStyles, WithStyles } from '@material-ui/core';
 import { PropertyKeyField, PROPERTY_KEY_FIELD_NAME } from './property-key-field';
 import { PropertyValueField, PROPERTY_VALUE_FIELD_NAME } from './property-value-field';
+import { ProgressButton } from '~/components/progress-button/progress-button';
+import { GridClassKey } from '@material-ui/core/Grid';
 
 export interface ResourcePropertiesFormData {
     [PROPERTY_KEY_FIELD_NAME]: string;
     [PROPERTY_VALUE_FIELD_NAME]: string;
 }
 
-export const ResourcePropertiesForm = ({ handleSubmit }: InjectedFormProps<ResourcePropertiesFormData>) =>
+export type ResourcePropertiesFormProps = InjectedFormProps<ResourcePropertiesFormData> & WithStyles<GridClassKey>;
+
+export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid, classes }: ResourcePropertiesFormProps ) =>
     <form onSubmit={handleSubmit}>
-        <Grid container spacing={16}>
+        <Grid container spacing={16} classes={classes}>
             <Grid item xs>
                 <PropertyKeyField />
             </Grid>
@@ -23,7 +27,18 @@ export const ResourcePropertiesForm = ({ handleSubmit }: InjectedFormProps<Resou
                 <PropertyValueField />
             </Grid>
             <Grid item xs>
-                <Button variant='contained' type='submit'>Add</Button>
+                <Button
+                    disabled={invalid}
+                    loading={submitting}
+                    color='primary'
+                    variant='contained'
+                    type='submit'>
+                    Add
+                </Button>
             </Grid>
         </Grid>
     </form>;
+
+const Button = withStyles(theme => ({
+    root: { marginTop: theme.spacing.unit }
+}))(ProgressButton);