From 6fbf6c43b2f7e1f8770cbcd245cbffc7ce0715be Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Tue, 27 Nov 2018 23:54:45 +0100 Subject: [PATCH] Reuse ResourcePropertiesForm as CollectionTagForm Feature #14393 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- .../collection-panel/collection-tag-form.tsx | 105 ++---------------- 1 file changed, 8 insertions(+), 97 deletions(-) diff --git a/src/views/collection-panel/collection-tag-form.tsx b/src/views/collection-panel/collection-tag-form.tsx index 9aa88128..04e37f2b 100644 --- a/src/views/collection-panel/collection-tag-form.tsx +++ b/src/views/collection-panel/collection-tag-form.tsx @@ -2,103 +2,14 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; -import { reduxForm, Field, reset } from 'redux-form'; -import { compose, Dispatch } from 'redux'; -import { ArvadosTheme } from '~/common/custom-theme'; -import { StyleRulesCallback, withStyles, WithStyles, Button, CircularProgress, Grid, Typography } from '@material-ui/core'; -import { TagProperty } from '~/models/tag'; -import { TextField } from '~/components/text-field/text-field'; +import { reduxForm, reset } from 'redux-form'; import { createCollectionTag, COLLECTION_TAG_FORM_NAME } from '~/store/collection-panel/collection-panel-action'; -import { TAG_VALUE_VALIDATION, TAG_KEY_VALIDATION } from '~/validators/validators'; +import { ResourcePropertiesForm, ResourcePropertiesFormData } from '~/views-components/resource-properties-form/resource-properties-form'; -type CssRules = 'root' | 'keyField' | 'valueField' | 'buttonWrapper' | 'saveButton' | 'circularProgress'; - -const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ - root: { - width: '100%', - display: 'flex' - }, - keyField: { - width: '25%', - marginRight: theme.spacing.unit * 3 - }, - valueField: { - width: '40%', - marginRight: theme.spacing.unit * 3 - }, - buttonWrapper: { - paddingTop: '14px', - position: 'relative', - }, - saveButton: { - boxShadow: 'none' - }, - circularProgress: { - position: 'absolute', - top: -9, - bottom: 0, - left: 0, - right: 0, - margin: 'auto' +export const CollectionTagForm = reduxForm({ + form: COLLECTION_TAG_FORM_NAME, + onSubmit: (data, dispatch) => { + dispatch(createCollectionTag(data)); + dispatch(reset(COLLECTION_TAG_FORM_NAME)); } -}); - -interface CollectionTagFormDataProps { - submitting: boolean; - invalid: boolean; - pristine: boolean; -} - -interface CollectionTagFormActionProps { - handleSubmit: any; -} - -type CollectionTagFormProps = CollectionTagFormDataProps & CollectionTagFormActionProps & WithStyles; - -export const CollectionTagForm = compose( - reduxForm({ - form: COLLECTION_TAG_FORM_NAME, - onSubmit: (data: TagProperty, dispatch: Dispatch) => { - dispatch(createCollectionTag(data)); - dispatch(reset(COLLECTION_TAG_FORM_NAME)); - } - }), - withStyles(styles))( - - class CollectionTagForm extends React.Component { - - render() { - const { classes, submitting, pristine, invalid, handleSubmit } = this.props; - return ( -
-
- -
-
- -
-
- - {submitting && } -
-
- ); - } - } - - ); +})(ResourcePropertiesForm); -- 2.30.2