[ARVADOS-WORKBENCH2] updated: 2.1.0-183-gd775cffe
Git user
git at public.arvados.org
Wed Jan 27 00:11:51 UTC 2021
Summary of changes:
cypress/integration/collection-panel.spec.js | 33 ++++++++++++++++++++++
.../property-field-common.tsx | 19 +------------
.../property-key-field.tsx | 28 ++++++++++++++++--
.../property-value-field.tsx | 25 ++++++++++++++--
4 files changed, 81 insertions(+), 24 deletions(-)
via d775cffef619dfda7024ed412313ac98d4d9c21d (commit)
via b92625b7244be8415fa5138b025097e70ce41f48 (commit)
from 4159df75086835ceef2ab6c4e9d1d53bdc14f7cb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit d775cffef619dfda7024ed412313ac98d4d9c21d
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Tue Jan 26 21:08:57 2021 -0300
17266: Handles onChange event separate on the property editor.
When changing the property value field, on every event a vocabulary match
is attempted just in case the user submits the form by hitting <enter>.
The bug happened because the vocabulary matching was only relying on the
onBlur event, that doesn't fire in this case.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/views-components/resource-properties-form/property-field-common.tsx b/src/views-components/resource-properties-form/property-field-common.tsx
index 949a1125..2e3f17c3 100644
--- a/src/views-components/resource-properties-form/property-field-common.tsx
+++ b/src/views-components/resource-properties-form/property-field-common.tsx
@@ -3,11 +3,10 @@
// SPDX-License-Identifier: AGPL-3.0
import { connect } from 'react-redux';
-import { change, WrappedFieldMetaProps, WrappedFieldInputProps, WrappedFieldProps, reset } from 'redux-form';
+import { change, WrappedFieldMetaProps, WrappedFieldInputProps, WrappedFieldProps } from 'redux-form';
import { Vocabulary, PropFieldSuggestion } from '~/models/vocabulary';
import { RootState } from '~/store/store';
import { getVocabulary } from '~/store/vocabulary/vocabulary-selectors';
-import { PROPERTY_KEY_FIELD_ID } from './property-key-field';
export interface VocabularyProp {
vocabulary: Vocabulary;
@@ -69,19 +68,3 @@ export const handleSelect = (
dispatch(change(formName, fieldName, item.id));
}
};
-
-export const handleChange = (
- fieldName: string,
- formName: string,
- { onChange }: WrappedFieldInputProps,
- { dispatch }: WrappedFieldMetaProps) =>
- (value: string) => {
- if (fieldName === PROPERTY_KEY_FIELD_ID) {
- // Properties' values are dependant on the keys, if any value is
- // pre-existant, a change on the property key should mean that the
- // previous value is invalid.
- dispatch(reset(formName));
- }
- onChange(value);
- dispatch(change(formName, fieldName, value));
- };
\ No newline at end of file
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 7a95d8e6..de8a1140 100644
--- a/src/views-components/resource-properties-form/property-key-field.tsx
+++ b/src/views-components/resource-properties-form/property-key-field.tsx
@@ -3,11 +3,18 @@
// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
-import { WrappedFieldProps, Field, FormName } from 'redux-form';
+import { WrappedFieldProps, Field, FormName, reset, change, WrappedFieldInputProps, WrappedFieldMetaProps } from 'redux-form';
import { memoize } from 'lodash';
import { Autocomplete } from '~/components/autocomplete/autocomplete';
import { Vocabulary, getTags, getTagKeyID } from '~/models/vocabulary';
-import { handleSelect, handleBlur, connectVocabulary, VocabularyProp, ValidationProp, buildProps, handleChange } from '~/views-components/resource-properties-form/property-field-common';
+import {
+ handleSelect,
+ handleBlur,
+ connectVocabulary,
+ VocabularyProp,
+ ValidationProp,
+ buildProps
+} from '~/views-components/resource-properties-form/property-field-common';
import { TAG_KEY_VALIDATION } from '~/validators/validators';
import { escapeRegExp } from '~/common/regexp.ts';
import { ChangeEvent } from 'react';
@@ -35,7 +42,7 @@ const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & Vocabula
onBlur={handleBlur(PROPERTY_KEY_FIELD_ID, data.form, props.meta, props.input, getTagKeyID(props.input.value, vocabulary))}
onChange={(e: ChangeEvent<HTMLInputElement>) => {
const newValue = e.currentTarget.value;
- handleChange(PROPERTY_KEY_FIELD_ID, data.form, props.input, props.meta)(newValue);
+ handleChange(data.form, props.input, props.meta, newValue);
}}
{...buildProps(props)}
/>
@@ -57,3 +64,18 @@ const getSuggestions = (value: string, vocabulary: Vocabulary) => {
const re = new RegExp(escapeRegExp(value), "i");
return getTags(vocabulary).filter(tag => re.test(tag.label) && tag.label !== value);
};
+
+const handleChange = (
+ formName: string,
+ { onChange }: WrappedFieldInputProps,
+ { dispatch }: WrappedFieldMetaProps,
+ value: string) => {
+ // Properties' values are dependant on the keys, if any value is
+ // pre-existant, a change on the property key should mean that the
+ // previous value is invalid, so we better reset the whole form before
+ // setting the new tag key.
+ dispatch(reset(formName));
+
+ onChange(value);
+ dispatch(change(formName, PROPERTY_KEY_FIELD_NAME, value));
+ };
\ No newline at end of file
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 c106ab43..d0044e18 100644
--- a/src/views-components/resource-properties-form/property-value-field.tsx
+++ b/src/views-components/resource-properties-form/property-value-field.tsx
@@ -3,12 +3,19 @@
// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
-import { WrappedFieldProps, Field, formValues, FormName } from 'redux-form';
+import { WrappedFieldProps, Field, formValues, FormName, WrappedFieldInputProps, WrappedFieldMetaProps, change } from 'redux-form';
import { compose } from 'redux';
import { Autocomplete } from '~/components/autocomplete/autocomplete';
import { Vocabulary, isStrictTag, getTagValues, getTagValueID } from '~/models/vocabulary';
import { PROPERTY_KEY_FIELD_ID, PROPERTY_KEY_FIELD_NAME } from '~/views-components/resource-properties-form/property-key-field';
-import { handleSelect, handleBlur, VocabularyProp, ValidationProp, connectVocabulary, buildProps, handleChange } from '~/views-components/resource-properties-form/property-field-common';
+import {
+ handleSelect,
+ handleBlur,
+ VocabularyProp,
+ ValidationProp,
+ connectVocabulary,
+ buildProps
+} from '~/views-components/resource-properties-form/property-field-common';
import { TAG_VALUE_VALIDATION } from '~/validators/validators';
import { escapeRegExp } from '~/common/regexp.ts';
import { ChangeEvent } from 'react';
@@ -56,7 +63,8 @@ const PropertyValueInput = ({ vocabulary, propertyKeyId, propertyKeyName, ...pro
onBlur={handleBlur(PROPERTY_VALUE_FIELD_ID, data.form, props.meta, props.input, getTagValueID(propertyKeyId, props.input.value, vocabulary))}
onChange={(e: ChangeEvent<HTMLInputElement>) => {
const newValue = e.currentTarget.value;
- handleChange(PROPERTY_VALUE_FIELD_ID, data.form, props.input, props.meta)(newValue);
+ const tagValueID = getTagValueID(propertyKeyId, newValue, vocabulary);
+ handleChange(data.form, tagValueID, props.input, props.meta, newValue);
}}
{...buildProps(props)}
/>
@@ -77,3 +85,14 @@ const getSuggestions = (value: string, tagName: string, vocabulary: Vocabulary)
const re = new RegExp(escapeRegExp(value), "i");
return getTagValues(tagName, vocabulary).filter(v => re.test(v.label) && v.label !== value);
};
+
+const handleChange = (
+ formName: string,
+ tagValueID: string,
+ { onChange }: WrappedFieldInputProps,
+ { dispatch }: WrappedFieldMetaProps,
+ value: string) => {
+ onChange(value);
+ dispatch(change(formName, PROPERTY_VALUE_FIELD_NAME, value));
+ dispatch(change(formName, PROPERTY_VALUE_FIELD_ID, tagValueID));
+ };
\ No newline at end of file
commit b92625b7244be8415fa5138b025097e70ce41f48
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Tue Jan 26 21:06:54 2021 -0300
17266: Exposes the bug with an integration test.
When the user typed a valid property value and hit <enter>, the literal
value's label is saved on the backend instead of its vocabulary ID.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js
index 0669b313..3e241ceb 100644
--- a/cypress/integration/collection-panel.spec.js
+++ b/cypress/integration/collection-panel.spec.js
@@ -28,6 +28,39 @@ describe('Collection panel tests', function() {
cy.clearLocalStorage();
});
+ it('uses the property editor with vocabulary terms', function() {
+ cy.createCollection(adminUser.token, {
+ name: `Test collection ${Math.floor(Math.random() * 999999)}`,
+ owner_uuid: activeUser.user.uuid,
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
+ .as('testCollection').then(function() {
+ cy.loginAs(activeUser);
+ cy.doSearch(`${this.testCollection.uuid}`);
+
+ // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
+ cy.get('[data-cy=collection-properties-form]').within(() => {
+ cy.get('[data-cy=property-field-key]').within(() => {
+ cy.get('input').type('Color');
+ });
+ cy.get('[data-cy=property-field-value]').within(() => {
+ cy.get('input').type('Magenta');
+ });
+ cy.root().submit();
+ });
+ // Confirm proper vocabulary labels are displayed on the UI.
+ cy.get('[data-cy=collection-properties-panel]')
+ .should('contain', 'Color')
+ .and('contain', 'Magenta');
+ // Confirm proper vocabulary IDs were saved on the backend.
+ cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
+ .its('body').as('collection')
+ .then(function() {
+ expect(this.collection.properties).to.deep.equal(
+ {IDTAGCOLORS: 'IDVALCOLORS3'});
+ });
+ });
+ });
+
it('shows collection by URL', function() {
cy.loginAs(activeUser);
[true, false].map(function(isWritable) {
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list