});
});
+ 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.
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();
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();
//
// 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,
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 }) => (
form: COLLECTION_CREATE_PROPERTIES_FORM_NAME,
onSubmit: (data, dispatch) => {
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
//
// 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,
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 }) => (
form: COLLECTION_UPDATE_PROPERTIES_FORM_NAME,
onSubmit: (data, dispatch) => {
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
//
// 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,
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 }) => (
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
//
// 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,
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 }) => (
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
export interface ValidationProp {
skipValidation?: boolean;
+ clearPropertyKeyOnSelect?: boolean;
}
export const mapStateToProps = (state: RootState, ownProps: ValidationProp): VocabularyProp & ValidationProp => ({
export const PROPERTY_KEY_FIELD_ID = 'keyID';
export const PropertyKeyField = connectVocabulary(
- ({ vocabulary, skipValidation }: VocabularyProp & ValidationProp) =>
+ ({ vocabulary, skipValidation, clearPropertyKeyOnSelect }: VocabularyProp & ValidationProp) =>
<span data-cy='property-field-key'>
<Field
+ clearPropertyKeyOnSelect
name={PROPERTY_KEY_FIELD_NAME}
component={PropertyKeyInput}
vocabulary={vocabulary}
</span>
);
-const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) =>
+const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp & { clearPropertyKeyOnSelect?: boolean }) =>
<FormName children={data => (
<Autocomplete
{...buildProps(props)}
? `${s.label} (${s.synonyms.join('; ')})`
: s.label
}
+ onFocus={() => {
+ 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
[PROPERTY_KEY_FIELD_ID]: string;
[PROPERTY_VALUE_FIELD_NAME]: string;
[PROPERTY_VALUE_FIELD_ID]: string;
+ clearPropertyKeyOnSelect?: boolean;
}
-export type ResourcePropertiesFormProps = {uuid: string; } & InjectedFormProps<ResourcePropertiesFormData, {uuid: string; }> & WithStyles<GridClassKey>;
+export type ResourcePropertiesFormProps = {uuid: string; clearPropertyKeyOnSelect?: boolean } & InjectedFormProps<ResourcePropertiesFormData, {uuid: string; }> & WithStyles<GridClassKey>;
-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 <form data-cy='resource-properties-form' onSubmit={handleSubmit}>
<Grid container spacing={16} classes={classes}>
<Grid item xs>
- <PropertyKeyField />
+ <PropertyKeyField clearPropertyKeyOnSelect />
</Grid>
<Grid item xs>
<PropertyValueField />