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:
Jaco Greeff 2016-10-25 11:43:05 +02:00 committed by GitHub
parent 285727e2fd
commit 9f6da3f829
2 changed files with 6 additions and 4 deletions

View File

@ -18,6 +18,8 @@ import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
const defaultName = 'UNNAMED';
class IdentityName extends Component {
static propTypes = {
address: PropTypes.string,
@ -38,14 +40,14 @@ class IdentityName extends Component {
}
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 name = hasAccount && !isUuid
? account.name.toUpperCase()
? account.name.toUpperCase().trim()
: fallback;
return (
<span>{ name }</span>
<span>{ name && name.length ? name : fallback }</span>
);
}

View File

@ -81,7 +81,7 @@ export function validateCode (code, api) {
}
export function validateName (name) {
const nameError = !name || name.length < 2 ? ERRORS.invalidName : null;
const nameError = !name || name.trim().length < 2 ? ERRORS.invalidName : null;
return {
name,