diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-02-08 07:26:10 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-03-14 00:38:25 -0400 |
commit | d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69 (patch) | |
tree | 49a0de30cdc2ac461e72a242ae9a5593fcd6c8b9 /web/react/components/user_profile.jsx | |
parent | 08f0800adef926e8b69ebea70e4995b89f5c3f3c (diff) | |
download | chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.tar.gz chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.tar.bz2 chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.zip |
Convering client to react-router.
Diffstat (limited to 'web/react/components/user_profile.jsx')
-rw-r--r-- | web/react/components/user_profile.jsx | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/web/react/components/user_profile.jsx b/web/react/components/user_profile.jsx index 31b2b9907..e7a286b77 100644 --- a/web/react/components/user_profile.jsx +++ b/web/react/components/user_profile.jsx @@ -26,22 +26,27 @@ export default class UserProfile extends React.Component { } } render() { - var name = Utils.displayUsername(this.props.user.id); - if (this.props.overwriteName) { - name = this.props.overwriteName; - } else if (!name) { - name = '...'; + let name = '...'; + let email = ''; + let profileImg = ''; + if (this.props.user) { + name = Utils.displayUsername(this.props.user.id); + email = this.props.user.email; + profileImg = '/api/v1/users/' + this.props.user.id + '/image?time=' + this.props.user.update_at; } - if (this.props.disablePopover) { - return <div>{name}</div>; + if (this.props.overwriteName) { + name = this.props.overwriteName; } - var profileImg = '/api/v1/users/' + this.props.user.id + '/image?time=' + this.props.user.update_at + '&' + Utils.getSessionIndex(); if (this.props.overwriteImage) { profileImg = this.props.overwriteImage; } + if (this.props.disablePopover) { + return <div>{name}</div>; + } + var dataContent = []; dataContent.push( <img @@ -69,14 +74,14 @@ export default class UserProfile extends React.Component { dataContent.push( <div data-toggle='tooltip' - title={this.props.user.email} + title={email} key='user-popover-email' > <a - href={'mailto:' + this.props.user.email} + href={'mailto:' + email} className='text-nowrap text-lowercase user-popover__email' > - {this.props.user.email} + {email} </a> </div> ); @@ -114,7 +119,7 @@ UserProfile.defaultProps = { disablePopover: false }; UserProfile.propTypes = { - user: React.PropTypes.object.isRequired, + user: React.PropTypes.object, overwriteName: React.PropTypes.string, overwriteImage: React.PropTypes.string, disablePopover: React.PropTypes.bool |