Merge branch '17308-property-editor-fixes'
[arvados-workbench2.git] / src / views-components / resource-properties-form / resource-properties-form.tsx
index c881928c3e1b3774624f515499a76afe23db4ae0..e8d2fc58e565616e30349d331c1528aad498d53d 100644 (file)
@@ -3,20 +3,25 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { InjectedFormProps, reduxForm } from 'redux-form';
-import { Grid, 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 { InjectedFormProps } from 'redux-form';
+import { Grid, withStyles, WithStyles } from '@material-ui/core';
+import { PropertyKeyField, PROPERTY_KEY_FIELD_NAME, PROPERTY_KEY_FIELD_ID } from './property-key-field';
+import { PropertyValueField, PROPERTY_VALUE_FIELD_NAME, PROPERTY_VALUE_FIELD_ID } 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_KEY_FIELD_ID]: string;
     [PROPERTY_VALUE_FIELD_NAME]: string;
+    [PROPERTY_VALUE_FIELD_ID]: string;
 }
 
-export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid }: InjectedFormProps<ResourcePropertiesFormData>) =>
-    <form onSubmit={handleSubmit}>
-        <Grid container spacing={16}>
+export type ResourcePropertiesFormProps = InjectedFormProps<ResourcePropertiesFormData> & WithStyles<GridClassKey>;
+
+export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid, classes }: ResourcePropertiesFormProps ) =>
+    <form data-cy='resource-properties-form' onSubmit={handleSubmit}>
+        <Grid container spacing={16} classes={classes}>
             <Grid item xs>
                 <PropertyKeyField />
             </Grid>
@@ -25,6 +30,7 @@ export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid }: In
             </Grid>
             <Grid item xs>
                 <Button
+                    data-cy='property-add-btn'
                     disabled={invalid}
                     loading={submitting}
                     color='primary'
@@ -36,6 +42,6 @@ export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid }: In
         </Grid>
     </form>;
 
-const Button = withStyles(theme => ({
+export const Button = withStyles(theme => ({
     root: { marginTop: theme.spacing.unit }
 }))(ProgressButton);