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 { 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>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user