From 850f82dacf3797236f8242cc50dddd250b904d2d Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Tue, 27 Nov 2018 23:12:38 +0100 Subject: [PATCH] Extract PROPERTY_KEY_FIELD_NAME to keep consistency between fields Feature #14393 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- .../resource-properties-form/property-key-field.tsx | 6 ++++-- .../resource-properties-form/property-value-field.tsx | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/views-components/resource-properties-form/property-key-field.tsx b/src/views-components/resource-properties-form/property-key-field.tsx index fdd89d09..c5e13985 100644 --- a/src/views-components/resource-properties-form/property-key-field.tsx +++ b/src/views-components/resource-properties-form/property-key-field.tsx @@ -20,10 +20,12 @@ const mapStateToProps = (state: RootState): VocabularyProp => ({ vocabulary: getVocabulary(state.properties), }); +export const PROPERTY_KEY_FIELD_NAME = 'key'; + export const PropertyKeyField = connect(mapStateToProps)( ({ vocabulary }: VocabularyProp) => ); @@ -53,7 +55,7 @@ const matchTags = (vocabulary: Vocabulary) => ? undefined : 'Incorrect key'; -const getSuggestions = (value: string, vocabulary: Vocabulary) => +const getSuggestions = (value: string, vocabulary: Vocabulary) => getTagsList(vocabulary).filter(tag => tag.includes(value) && tag !== value); const getTagsList = ({ tags }: Vocabulary) => diff --git a/src/views-components/resource-properties-form/property-value-field.tsx b/src/views-components/resource-properties-form/property-value-field.tsx index 8574e609..e73c66be 100644 --- a/src/views-components/resource-properties-form/property-value-field.tsx +++ b/src/views-components/resource-properties-form/property-value-field.tsx @@ -12,6 +12,7 @@ import { getVocabulary } from '~/store/vocabulary/vocabulary-selctors'; import { Autocomplete } from '~/components/autocomplete/autocomplete'; import { Vocabulary } from '~/models/vocabulary'; import { require } from '~/validators/require'; +import { PROPERTY_KEY_FIELD_NAME } from '~/views-components/resource-properties-form/property-key-field'; interface VocabularyProp { vocabulary: Vocabulary; @@ -29,7 +30,7 @@ const mapStateToProps = (state: RootState): VocabularyProp => ({ export const PropertyValueField = compose( connect(mapStateToProps), - formValues({ propertyKey: 'key' }) + formValues({ propertyKey: PROPERTY_KEY_FIELD_NAME }) )( (props: PropertyValueFieldProps) =>