From: Daniel Kutyła Date: Tue, 21 Jun 2022 09:16:57 +0000 (+0200) Subject: Merge branch '18203-Support-setting-multi-properties-at-once' into main X-Git-Tag: 2.5.0~50 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/765f6475a53ac7e635b737642ef375459324a117?hp=c21c6582a12fe3968e3ef3a4786de5dfacce3b18 Merge branch '18203-Support-setting-multi-properties-at-once' into main closes #18203 Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js index 1329191d..fd8e65b2 100644 --- a/cypress/integration/collection.spec.js +++ b/cypress/integration/collection.spec.js @@ -425,6 +425,20 @@ describe('Collection panel tests', function () { }); }); + it('shows collection owner', () => { + 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((testCollection) => { + cy.loginAs(activeUser); + cy.goToPath(`/collections/${testCollection.uuid}`); + cy.wait(5000); + cy.get('[data-cy=collection-info-panel]').contains(`Collection User`); + }); + }); + it('tries to rename a file with illegal names', function () { // Creates the collection using the admin token so we can set up // a bogus manifest text without block signatures. diff --git a/cypress/integration/project.spec.js b/cypress/integration/project.spec.js index 0017e416..7371ed06 100644 --- a/cypress/integration/project.spec.js +++ b/cypress/integration/project.spec.js @@ -28,7 +28,7 @@ describe('Project tests', function() { cy.clearLocalStorage(); }); - it('creates a new project with properties', function() { + it('creates a new project with multiple properties', function() { const projName = `Test project (${Math.floor(999999 * Math.random())})`; cy.loginAs(activeUser); cy.get('[data-cy=side-panel-button]').click(); @@ -51,9 +51,26 @@ describe('Project tests', function() { cy.get('input').type('Magenta'); }); cy.root().submit(); + cy.get('[data-cy=property-field-value]').within(() => { + cy.get('input').type('Pink'); + }); + cy.root().submit(); + cy.get('[data-cy=property-field-value]').within(() => { + cy.get('input').type('Yellow'); + }); + cy.root().submit(); }); // Confirm proper vocabulary labels are displayed on the UI. cy.get('[data-cy=form-dialog]').should('contain', 'Color: Magenta'); + cy.get('[data-cy=form-dialog]').should('contain', 'Color: Pink'); + cy.get('[data-cy=form-dialog]').should('contain', 'Color: Yellow'); + + cy.get('[data-cy=resource-properties-form]').within(() => { + cy.get('[data-cy=property-field-key]').within(() => { + cy.get('input').focus(); + }); + cy.get('[data-cy=property-field-key]').should('not.contain', 'Color'); + }); // Create project and confirm the properties' real values. cy.get('[data-cy=form-submit-btn]').click(); diff --git a/src/views-components/collection-properties/create-collection-properties-form.tsx b/src/views-components/collection-properties/create-collection-properties-form.tsx index 3f19e158..fb18bb1a 100644 --- a/src/views-components/collection-properties/create-collection-properties-form.tsx +++ b/src/views-components/collection-properties/create-collection-properties-form.tsx @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { reduxForm, reset } from 'redux-form'; +import { reduxForm, change } from 'redux-form'; import { withStyles } from '@material-ui/core'; import { COLLECTION_CREATE_PROPERTIES_FORM_NAME, @@ -13,6 +13,7 @@ import { ResourcePropertiesFormData } from 'views-components/resource-properties-form/resource-properties-form'; import { addPropertyToResourceForm } from 'store/resources/resources-actions'; +import { PROPERTY_VALUE_FIELD_NAME } from 'views-components/resource-properties-form/property-value-field'; const Form = withStyles( ({ spacing }) => ( @@ -27,6 +28,6 @@ export const CreateCollectionPropertiesForm = reduxForm { dispatch(addPropertyToResourceForm(data, COLLECTION_CREATE_FORM_NAME)); - dispatch(reset(COLLECTION_CREATE_PROPERTIES_FORM_NAME)); + dispatch(change(COLLECTION_CREATE_PROPERTIES_FORM_NAME, PROPERTY_VALUE_FIELD_NAME, '')); } })(Form); \ No newline at end of file diff --git a/src/views-components/collection-properties/update-collection-properties-form.tsx b/src/views-components/collection-properties/update-collection-properties-form.tsx index 9092c7cc..3ab425f1 100644 --- a/src/views-components/collection-properties/update-collection-properties-form.tsx +++ b/src/views-components/collection-properties/update-collection-properties-form.tsx @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { reduxForm, reset } from 'redux-form'; +import { reduxForm, change } from 'redux-form'; import { withStyles } from '@material-ui/core'; import { COLLECTION_UPDATE_FORM_NAME, @@ -13,6 +13,7 @@ import { ResourcePropertiesFormData } from 'views-components/resource-properties-form/resource-properties-form'; import { addPropertyToResourceForm } from 'store/resources/resources-actions'; +import { PROPERTY_VALUE_FIELD_NAME } from 'views-components/resource-properties-form/property-value-field'; const Form = withStyles( ({ spacing }) => ( @@ -27,6 +28,6 @@ export const UpdateCollectionPropertiesForm = reduxForm { dispatch(addPropertyToResourceForm(data, COLLECTION_UPDATE_FORM_NAME)); - dispatch(reset(COLLECTION_UPDATE_PROPERTIES_FORM_NAME)); + dispatch(change(COLLECTION_UPDATE_PROPERTIES_FORM_NAME, PROPERTY_VALUE_FIELD_NAME, '')); } })(Form); \ No newline at end of file diff --git a/src/views-components/project-properties/create-project-properties-form.tsx b/src/views-components/project-properties/create-project-properties-form.tsx index 8c26523e..5a6d9df6 100644 --- a/src/views-components/project-properties/create-project-properties-form.tsx +++ b/src/views-components/project-properties/create-project-properties-form.tsx @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { reduxForm, reset } from 'redux-form'; +import { reduxForm, change } from 'redux-form'; import { withStyles } from '@material-ui/core'; import { PROJECT_CREATE_PROPERTIES_FORM_NAME, @@ -13,6 +13,7 @@ import { ResourcePropertiesFormData } from 'views-components/resource-properties-form/resource-properties-form'; import { addPropertyToResourceForm } from 'store/resources/resources-actions'; +import { PROPERTY_VALUE_FIELD_NAME } from 'views-components/resource-properties-form/property-value-field'; const Form = withStyles( ({ spacing }) => ( @@ -27,6 +28,6 @@ export const CreateProjectPropertiesForm = reduxForm form: PROJECT_CREATE_PROPERTIES_FORM_NAME, onSubmit: (data, dispatch) => { dispatch(addPropertyToResourceForm(data, PROJECT_CREATE_FORM_NAME)); - dispatch(reset(PROJECT_CREATE_PROPERTIES_FORM_NAME)); + dispatch(change(PROJECT_CREATE_PROPERTIES_FORM_NAME, PROPERTY_VALUE_FIELD_NAME, '')); } })(Form); \ No newline at end of file diff --git a/src/views-components/project-properties/update-project-properties-form.tsx b/src/views-components/project-properties/update-project-properties-form.tsx index 0b5554bc..9bce50ab 100644 --- a/src/views-components/project-properties/update-project-properties-form.tsx +++ b/src/views-components/project-properties/update-project-properties-form.tsx @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { reduxForm, reset } from 'redux-form'; +import { reduxForm, change } from 'redux-form'; import { withStyles } from '@material-ui/core'; import { PROJECT_UPDATE_PROPERTIES_FORM_NAME, @@ -13,6 +13,7 @@ import { ResourcePropertiesFormData } from 'views-components/resource-properties-form/resource-properties-form'; import { addPropertyToResourceForm } from 'store/resources/resources-actions'; +import { PROPERTY_VALUE_FIELD_NAME } from 'views-components/resource-properties-form/property-value-field'; const Form = withStyles( ({ spacing }) => ( @@ -27,6 +28,6 @@ export const UpdateProjectPropertiesForm = reduxForm form: PROJECT_UPDATE_PROPERTIES_FORM_NAME, onSubmit: (data, dispatch) => { dispatch(addPropertyToResourceForm(data, PROJECT_UPDATE_FORM_NAME)); - dispatch(reset(PROJECT_UPDATE_PROPERTIES_FORM_NAME)); + dispatch(change(PROJECT_UPDATE_PROPERTIES_FORM_NAME, PROPERTY_VALUE_FIELD_NAME, '')); } })(Form); \ No newline at end of file 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 c4dc494b..dad17284 100644 --- a/src/views-components/resource-properties-form/property-field-common.tsx +++ b/src/views-components/resource-properties-form/property-field-common.tsx @@ -14,6 +14,7 @@ export interface VocabularyProp { export interface ValidationProp { skipValidation?: boolean; + clearPropertyKeyOnSelect?: boolean; } export const mapStateToProps = (state: RootState, ownProps: ValidationProp): VocabularyProp & ValidationProp => ({ 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 0be4527a..0b08ad6d 100644 --- a/src/views-components/resource-properties-form/property-key-field.tsx +++ b/src/views-components/resource-properties-form/property-key-field.tsx @@ -30,9 +30,10 @@ export const PROPERTY_KEY_FIELD_NAME = 'key'; export const PROPERTY_KEY_FIELD_ID = 'keyID'; export const PropertyKeyField = connectVocabulary( - ({ vocabulary, skipValidation }: VocabularyProp & ValidationProp) => + ({ vocabulary, skipValidation, clearPropertyKeyOnSelect }: VocabularyProp & ValidationProp) => ); -const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) => +const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp & { clearPropertyKeyOnSelect?: boolean }) => ( { + if (props.clearPropertyKeyOnSelect && props.input.value) { + props.meta.dispatch(reset(props.meta.form)); + } + }} onSelect={handleSelect(PROPERTY_KEY_FIELD_ID, data.form, props.input, props.meta)} onBlur={() => { // Case-insensitive search for the key in the vocabulary 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 979d772e..25d0f2bb 100644 --- a/src/views-components/resource-properties-form/resource-properties-form.tsx +++ b/src/views-components/resource-properties-form/resource-properties-form.tsx @@ -16,16 +16,17 @@ export interface ResourcePropertiesFormData { [PROPERTY_KEY_FIELD_ID]: string; [PROPERTY_VALUE_FIELD_NAME]: string; [PROPERTY_VALUE_FIELD_ID]: string; + clearPropertyKeyOnSelect?: boolean; } -export type ResourcePropertiesFormProps = {uuid: string; } & InjectedFormProps & WithStyles; +export type ResourcePropertiesFormProps = {uuid: string; clearPropertyKeyOnSelect?: boolean } & InjectedFormProps & WithStyles; -export const ResourcePropertiesForm = ({ handleSubmit, change, submitting, invalid, classes, uuid }: ResourcePropertiesFormProps ) => { +export const ResourcePropertiesForm = ({ handleSubmit, change, submitting, invalid, classes, uuid, clearPropertyKeyOnSelect }: ResourcePropertiesFormProps ) => { change('uuid', uuid); // Sets the uuid field to the uuid of the resource. return
- +