Permalink
Browse files

Merge pull request #252 from bookbrainz/name-deduplication-fix

fix(deduplication): Don't initially run name deduplication on entity edit
  • Loading branch information...
MonkeyDo committed Feb 12, 2019
2 parents 18301ac + 683bf10 commit 804aed5847a31094bae8cab860170105935b4200
Showing with 11 additions and 4 deletions.
  1. +3 −1 src/client/entity-editor/name-section/name-section.js
  2. +8 −3 src/server/helpers/entityRouteUtils.js
@@ -88,7 +88,7 @@ class NameSection extends React.Component {
When Component is first loaded, manually trigger "handleNameChange" mechanism.
*/
componentDidMount() {
if (!_.isNil(this.nameInputRef)) {
if (this.props.action !== 'edit' && !_.isNil(this.nameInputRef)) {
this.handleNameChange({target: {value: this.nameInputRef.value}});
}
}
@@ -241,6 +241,7 @@ class NameSection extends React.Component {
}
NameSection.displayName = 'NameSection';
NameSection.propTypes = {
action: PropTypes.string,
disambiguationDefaultValue: PropTypes.string,
disambiguationVisible: PropTypes.bool.isRequired,
entityType: entityTypeProperty.isRequired, // eslint-disable-line react/no-typos, max-len
@@ -258,6 +259,7 @@ NameSection.propTypes = {
sortNameValue: PropTypes.string.isRequired
};
NameSection.defaultProps = {
action: 'create',
disambiguationDefaultValue: null,
exactMatches: null,
languageValue: null,
@@ -24,6 +24,7 @@ import * as entityRoutes from '../routes/entity/entity';
import * as error from './error';
import * as propHelpers from '../../client/helpers/props';
import * as utils from './utils';

import EntityEditor from '../../client/entity-editor/entity-editor';
import Layout from '../../client/containers/layout';
import {Provider} from 'react-redux';
@@ -34,7 +35,6 @@ import {createStore} from 'redux';
import express from 'express';
import {generateProps} from './props';


const {createRootReducer, getEntitySection, getValidator} = entityEditorHelpers;

type EntityAction = 'create' | 'edit';
@@ -60,7 +60,8 @@ export function generateEntityProps(
req: express.request, res: express.response,
additionalProps: Object,
initialStateCallback: (entity: ?Object) => Object =
(entity) => new Object()): Object {
(entity) => new Object()
): Object {
const entityName = _.capitalize(entityType);
const {entity} = res.locals;
const isEdit = Boolean(entity);
@@ -76,7 +77,10 @@ export function generateEntityProps(
`/${entityType}/${entity.bbid}/edit/handler` :
`/${entityType}/create/handler`;

const action: EntityAction = isEdit ? 'edit' : 'create';

const props = Object.assign({
action,
entityType,
heading: isEdit ?
`Edit ${entityName}` :
@@ -103,7 +107,8 @@ export function generateEntityProps(
*/
export function entityEditorMarkup(
props: { initialState: Object,
entityType: string }) {
entityType: string }
) {
const {initialState, ...rest} = props;
const rootReducer = createRootReducer(props.entityType);
const store = createStore(rootReducer, Immutable.fromJS(initialState));

0 comments on commit 804aed5

Please sign in to comment.