X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3e56db626688ee6225d40b7e4c511e3217e84847..6f8dcb2b13f3058db656908fb26b09e23b527f08:/src/views-components/resource-properties-form/resource-properties-form.tsx diff --git a/src/views-components/resource-properties-form/resource-properties-form.tsx b/src/views-components/resource-properties-form/resource-properties-form.tsx index db40e4a7e8..0147312912 100644 --- a/src/views-components/resource-properties-form/resource-properties-form.tsx +++ b/src/views-components/resource-properties-form/resource-properties-form.tsx @@ -2,45 +2,63 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; -import { InjectedFormProps } from 'redux-form'; +import React from 'react'; +import { RootState } from 'store/store'; +import { connect } from 'react-redux'; +import { formValueSelector, 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 { ProgressButton } from 'components/progress-button/progress-button'; import { GridClassKey } from '@material-ui/core/Grid'; +const AddButton = withStyles(theme => ({ + root: { marginTop: theme.spacing.unit } +}))(ProgressButton); + +const mapStateToProps = (state: RootState) => { + return { + applySelector: (selector) => selector(state, 'key', 'value', 'keyID', 'valueID') + } +} + +interface ApplySelector { + applySelector: (selector) => any; +} + export interface ResourcePropertiesFormData { + uuid: string; [PROPERTY_KEY_FIELD_NAME]: string; [PROPERTY_KEY_FIELD_ID]: string; [PROPERTY_VALUE_FIELD_NAME]: string; [PROPERTY_VALUE_FIELD_ID]: string; + clearPropertyKeyOnSelect?: boolean; } -export type ResourcePropertiesFormProps = InjectedFormProps & WithStyles; +type ResourcePropertiesFormProps = {uuid: string; clearPropertyKeyOnSelect?: boolean } & InjectedFormProps & WithStyles & ApplySelector; -export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid, classes }: ResourcePropertiesFormProps ) => -
+export const ResourcePropertiesForm = connect(mapStateToProps)(({ handleSubmit, change, submitting, invalid, classes, uuid, clearPropertyKeyOnSelect, applySelector, ...props }: ResourcePropertiesFormProps ) => { + change('uuid', uuid); // Sets the uuid field to the uuid of the resource. + const propertyValue = applySelector(formValueSelector(props.form)); + return - + - - + -
; - -export const Button = withStyles(theme => ({ - root: { marginTop: theme.spacing.unit } -}))(ProgressButton); + } +); \ No newline at end of file