Fix UX on inputchange for database name

This commit is contained in:
cyril lopez 2017-08-21 15:22:12 +02:00
parent 09f1563275
commit 66a1f3a6ba

View File

@ -28,7 +28,7 @@
*/ */
import React from 'react'; import React from 'react';
import { isEmpty, includes, mapKeys, reject, map, isObject, union, findIndex, uniqBy } from 'lodash'; import { isEmpty, includes, mapKeys, reject, map, isObject, union, findIndex, uniqBy, remove } from 'lodash';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import WithInput from 'components/WithInput'; import WithInput from 'components/WithInput';
@ -50,6 +50,8 @@ class InputText extends React.Component { // eslint-disable-line react/prefer-st
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (this.props.errors !== nextProps.errors) { if (this.props.errors !== nextProps.errors) {
const errors = uniqBy(union(this.state.errors, nextProps.errors), 'id'); const errors = uniqBy(union(this.state.errors, nextProps.errors), 'id');
if (isEmpty(nextProps.errors)) remove(errors, (error) => error.id === 'settings-manager.request.error.database.exist');
this.setState({ errors }); this.setState({ errors });
} }
} }
@ -152,7 +154,7 @@ class InputText extends React.Component { // eslint-disable-line react/prefer-st
const label = this.props.name ? <label htmlFor={this.props.name}><FormattedMessage id={`settings-manager.${this.props.name}`} /></label> : ''; const label = this.props.name ? <label htmlFor={this.props.name}><FormattedMessage id={`settings-manager.${this.props.name}`} /></label> : '';
const spacer = !this.props.name ? {marginTop: '2.4rem'} : {marginTop: ''}; const spacer = !this.props.name ? {marginTop: '2.4rem'} : {marginTop: ''};
const input = placeholder ? this.renderFormattedInput(handleBlur, inputValue, placeholder) const input = placeholder ? this.renderFormattedInput(handleBlur, inputValue, placeholder)
: <input : <input
name={this.props.target} name={this.props.target}