From 4c0099ec3509061ca3f507658689bf3bba77e5ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Mon, 13 Jun 2022 20:41:19 +0200 Subject: [PATCH] 18203: added support for adding multi properties at once MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- cypress/integration/collection.spec.js | 14 ++++++++++++++ .../create-collection-properties-form.tsx | 5 +++-- .../update-collection-properties-form.tsx | 5 +++-- .../create-project-properties-form.tsx | 5 +++-- .../update-project-properties-form.tsx | 5 +++-- .../property-field-common.tsx | 1 + .../property-key-field.tsx | 10 ++++++++-- .../resource-properties-form.tsx | 7 ++++--- 8 files changed, 39 insertions(+), 13 deletions(-) diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js index 0b06e53e..384b789f 100644 --- a/cypress/integration/collection.spec.js +++ b/cypress/integration/collection.spec.js @@ -418,6 +418,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/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
- + -- 2.30.2