Don't return empty names as clickable titles (#2809)
* Don't return empty names (Fixes #2786) * add trim in validation
This commit is contained in:
parent
285727e2fd
commit
9f6da3f829
@ -18,6 +18,8 @@ import React, { Component, PropTypes } from 'react';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
|
|
||||||
|
const defaultName = 'UNNAMED';
|
||||||
|
|
||||||
class IdentityName extends Component {
|
class IdentityName extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
address: PropTypes.string,
|
address: PropTypes.string,
|
||||||
@ -38,14 +40,14 @@ class IdentityName extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const addressFallback = shorten ? this.formatHash(address) : address;
|
const addressFallback = shorten ? this.formatHash(address) : address;
|
||||||
const fallback = unknown ? 'UNNAMED' : addressFallback;
|
const fallback = unknown ? defaultName : addressFallback;
|
||||||
const isUuid = hasAccount && account.name === account.uuid;
|
const isUuid = hasAccount && account.name === account.uuid;
|
||||||
const name = hasAccount && !isUuid
|
const name = hasAccount && !isUuid
|
||||||
? account.name.toUpperCase()
|
? account.name.toUpperCase().trim()
|
||||||
: fallback;
|
: fallback;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span>{ name }</span>
|
<span>{ name && name.length ? name : fallback }</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ export function validateCode (code, api) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function validateName (name) {
|
export function validateName (name) {
|
||||||
const nameError = !name || name.length < 2 ? ERRORS.invalidName : null;
|
const nameError = !name || name.trim().length < 2 ? ERRORS.invalidName : null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
|
Loading…
Reference in New Issue
Block a user