From: Lucas Di Pentima Date: Mon, 18 Nov 2019 12:46:01 +0000 (-0300) Subject: 15069: Adds optional validation disabling to property fields components. X-Git-Tag: 2.0.0~28^2~9 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/9de00081201406e11ed0ad1ba16af7ae732f402a 15069: Adds optional validation disabling to property fields components. Also, use these components with validation disabled on the advanced search UI. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/src/views-components/form-fields/search-bar-form-fields.tsx b/src/views-components/form-fields/search-bar-form-fields.tsx index 8de48ea7..4c8da3ae 100644 --- a/src/views-components/form-fields/search-bar-form-fields.tsx +++ b/src/views-components/form-fields/search-bar-form-fields.tsx @@ -3,7 +3,7 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from "react"; -import { Field, WrappedFieldProps, FieldArray, formValues } from 'redux-form'; +import { Field, WrappedFieldProps, FieldArray } from 'redux-form'; import { TextField, DateTextField } from "~/components/text-field/text-field"; import { CheckboxField } from '~/components/checkbox-field/checkbox-field'; import { NativeSelectField } from '~/components/select-field/select-field'; @@ -13,10 +13,8 @@ import { SEARCH_BAR_ADVANCE_FORM_PICKER_ID } from '~/store/search-bar/search-bar import { SearchBarAdvancedPropertiesView } from '~/views-components/search-bar/search-bar-advanced-properties-view'; import { TreeItem } from "~/components/tree/tree"; import { ProjectsTreePickerItem } from "~/views-components/projects-tree-picker/generic-projects-tree-picker"; -import { PropertyKeyInput } from '~/views-components/resource-properties-form/property-key-field'; -import { PropertyValueInput, PropertyValueFieldProps } from '~/views-components/resource-properties-form/property-value-field'; -import { VocabularyProp, connectVocabulary } from '~/views-components/resource-properties-form/property-field-common'; -import { compose } from 'redux'; +import { PropertyKeyField, } from '~/views-components/resource-properties-form/property-key-field'; +import { PropertyValueField } from '~/views-components/resource-properties-form/property-value-field'; import { connect } from "react-redux"; import { RootState } from "~/store/store"; @@ -88,22 +86,11 @@ export const SearchBarPropertiesField = () => name="properties" component={SearchBarAdvancedPropertiesView} />; -export const SearchBarKeyField = connectVocabulary( - ({ vocabulary }: VocabularyProp) => - ); +export const SearchBarKeyField = () => + ; -export const SearchBarValueField = compose( - connectVocabulary, - formValues({ propertyKey: 'key' }) -)( - (props: PropertyValueFieldProps) => - ); +export const SearchBarValueField = () => + ; export const SearchBarSaveSearchField = () => + ({ vocabulary, skipValidation }: VocabularyProp & PropertyKeyFieldProps) => + validate={skipValidation ? undefined : getValidation(vocabulary)} /> ); -export const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) => +const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) => ( ( connectVocabulary, - formValues({ propertyKey: PROPERTY_KEY_FIELD_ID }) -)( - (props: PropertyValueFieldProps) => + formValues({ propertyKey: PROPERTY_KEY_FIELD_ID }), +); + +export const PropertyValueField = connectVocabularyAndPropertyKey( + ({skipValidation, ...props}: PropertyValueFieldProps & ValidationProp) => ); -export const PropertyValueInput = ({ vocabulary, propertyKey, ...props }: WrappedFieldProps & PropertyValueFieldProps) => +const PropertyValueInput = ({ vocabulary, propertyKey, ...props }: WrappedFieldProps & PropertyValueFieldProps) => (