Extract PROPERTY_KEY_FIELD_NAME to keep consistency between fields
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 27 Nov 2018 22:12:38 +0000 (23:12 +0100)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 27 Nov 2018 22:12:38 +0000 (23:12 +0100)
Feature #14393

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/views-components/resource-properties-form/property-key-field.tsx
src/views-components/resource-properties-form/property-value-field.tsx

index fdd89d09321d3b0d472ad99753184751da17cf7c..c5e13985090e465bdb69abaa70c86476369f5ee4 100644 (file)
@@ -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) =>
         <Field
-            name='key'
+            name={PROPERTY_KEY_FIELD_NAME}
             component={PropertyKeyInput}
             vocabulary={vocabulary}
             validate={getValidation(vocabulary)} />);
@@ -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) =>
index 8574e609b565ffc6fd014a18ea6be44bbdad026c..e73c66beb62a17ae1f2c6ecc9301a9290d82d839 100644 (file)
@@ -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) =>
         <Field