From e039a6f51ca398dae75a76cf2817b3f91bc0c1a6 Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Tue, 27 Nov 2018 23:56:03 +0100 Subject: [PATCH] Reuse ResourcePropertiesForm as ProjectPropertiesForm Feature #14393 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- .../project-properties-form.tsx | 96 ++----------------- 1 file changed, 8 insertions(+), 88 deletions(-) diff --git a/src/views-components/project-properties-dialog/project-properties-form.tsx b/src/views-components/project-properties-dialog/project-properties-form.tsx index 82ae0406..bd72bcff 100644 --- a/src/views-components/project-properties-dialog/project-properties-form.tsx +++ b/src/views-components/project-properties-dialog/project-properties-form.tsx @@ -2,94 +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 } from '@material-ui/core'; -import { TagProperty } from '~/models/tag'; -import { TextField } from '~/components/text-field/text-field'; -import { TAG_VALUE_VALIDATION, TAG_KEY_VALIDATION } from '~/validators/validators'; +import { reduxForm, reset } from 'redux-form'; import { PROJECT_PROPERTIES_FORM_NAME, createProjectProperty } from '~/store/details-panel/details-panel-action'; +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: '40%', - 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 ProjectPropertiesForm = reduxForm({ + form: PROJECT_PROPERTIES_FORM_NAME, + onSubmit: (data, dispatch) => { + dispatch(createProjectProperty(data)); + dispatch(reset(PROJECT_PROPERTIES_FORM_NAME)); } -}); - -interface ProjectPropertiesFormDataProps { - submitting: boolean; - invalid: boolean; - pristine: boolean; -} - -interface ProjectPropertiesFormActionProps { - handleSubmit: any; -} - -type ProjectPropertiesFormProps = ProjectPropertiesFormDataProps & ProjectPropertiesFormActionProps & WithStyles; - -export const ProjectPropertiesForm = compose( - reduxForm({ - form: PROJECT_PROPERTIES_FORM_NAME, - onSubmit: (data: TagProperty, dispatch: Dispatch) => { - dispatch(createProjectProperty(data)); - dispatch(reset(PROJECT_PROPERTIES_FORM_NAME)); - } - }), - withStyles(styles))( - ({ classes, submitting, pristine, invalid, handleSubmit }: ProjectPropertiesFormProps) => -
-
- -
-
- -
-
- - {submitting && } -
-
- ); +})(ResourcePropertiesForm); -- 2.30.2