// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import * as Utils from '../utils/utils.jsx'; import {FormattedMessage} from 'mm-intl'; var Popover = ReactBootstrap.Popover; var OverlayTrigger = ReactBootstrap.OverlayTrigger; var id = 0; function nextId() { id = id + 1; return id; } export default class UserProfile extends React.Component { constructor(props) { super(props); this.uniqueId = nextId(); } componentDidMount() { if (!this.props.disablePopover) { $('body').tooltip({selector: '[data-toggle=tooltip]', trigger: 'hover click'}); } } render() { var name = Utils.displayUsername(this.props.user.id); if (this.props.overwriteName) { name = this.props.overwriteName; } else if (!name) { name = '...'; } if (this.props.disablePopover) { return
{name}
; } 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; } var dataContent = []; dataContent.push( ); if (!global.window.mm_config.ShowEmailAddress === 'true') { dataContent.push(
); } else { dataContent.push(
{this.props.user.email}
); } return ( {dataContent} } >
{name}
); } } UserProfile.defaultProps = { user: {}, overwriteName: '', overwriteImage: '', disablePopover: false }; UserProfile.propTypes = { user: React.PropTypes.object.isRequired, overwriteName: React.PropTypes.string, overwriteImage: React.PropTypes.string, disablePopover: React.PropTypes.bool };