2015-10-08 12:27:09 -04:00
|
|
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
2015-06-14 23:53:32 -08:00
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
2015-08-31 09:35:31 -07:00
|
|
|
var NavbarDropdown = require('./navbar_dropdown.jsx');
|
2015-06-14 23:53:32 -08:00
|
|
|
var UserStore = require('../stores/user_store.jsx');
|
2015-10-20 15:02:15 -07:00
|
|
|
const Utils = require('../utils/utils.jsx');
|
2015-06-14 23:53:32 -08:00
|
|
|
|
2015-10-29 00:02:17 +05:00
|
|
|
const Tooltip = ReactBootstrap.Tooltip;
|
|
|
|
|
const OverlayTrigger = ReactBootstrap.OverlayTrigger;
|
|
|
|
|
|
2015-08-31 09:35:31 -07:00
|
|
|
export default class SidebarHeader extends React.Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
2015-07-23 14:59:43 +05:00
|
|
|
|
2015-08-31 09:35:31 -07:00
|
|
|
this.toggleDropdown = this.toggleDropdown.bind(this);
|
2015-06-14 23:53:32 -08:00
|
|
|
|
2015-08-31 09:35:31 -07:00
|
|
|
this.state = {};
|
2015-06-14 23:53:32 -08:00
|
|
|
}
|
2015-09-17 22:00:33 -07:00
|
|
|
toggleDropdown(e) {
|
|
|
|
|
e.preventDefault();
|
2015-07-30 10:54:41 -04:00
|
|
|
if (this.refs.dropdown.blockToggle) {
|
|
|
|
|
this.refs.dropdown.blockToggle = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$('.team__header').find('.dropdown-toggle').dropdown('toggle');
|
2015-08-31 09:35:31 -07:00
|
|
|
}
|
|
|
|
|
render() {
|
2015-07-08 12:51:43 -07:00
|
|
|
var me = UserStore.getCurrentUser();
|
2015-08-04 09:40:58 -07:00
|
|
|
var profilePicture = null;
|
2015-07-08 12:51:43 -07:00
|
|
|
|
2015-07-15 09:03:28 -07:00
|
|
|
if (!me) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2015-06-14 23:53:32 -08:00
|
|
|
|
2015-08-04 09:40:58 -07:00
|
|
|
if (me.last_picture_update) {
|
2015-09-03 10:49:36 -04:00
|
|
|
profilePicture = (
|
|
|
|
|
<img
|
|
|
|
|
className='user__picture'
|
2015-10-20 14:49:42 -07:00
|
|
|
src={'/api/v1/users/' + me.id + '/image?time=' + me.update_at + '&' + Utils.getSessionIndex()}
|
2015-09-03 10:49:36 -04:00
|
|
|
/>
|
|
|
|
|
);
|
2015-08-04 09:40:58 -07:00
|
|
|
}
|
|
|
|
|
|
2015-06-14 23:53:32 -08:00
|
|
|
return (
|
2015-08-04 09:40:58 -07:00
|
|
|
<div className='team__header theme'>
|
2015-08-31 09:35:31 -07:00
|
|
|
<a
|
|
|
|
|
href='#'
|
|
|
|
|
onClick={this.toggleDropdown}
|
|
|
|
|
>
|
2015-08-04 09:40:58 -07:00
|
|
|
{profilePicture}
|
|
|
|
|
<div className='header__info'>
|
|
|
|
|
<div className='user__name'>{'@' + me.username}</div>
|
2015-10-29 00:02:17 +05:00
|
|
|
<OverlayTrigger
|
|
|
|
|
trigger={['hover', 'focus']}
|
|
|
|
|
delayShow={1000}
|
|
|
|
|
placement='bottom'
|
|
|
|
|
overlay={<Tooltip id='team-name__tooltip'>{this.props.teamDisplayName}</Tooltip>}
|
|
|
|
|
ref='descriptionOverlay'
|
|
|
|
|
>
|
2015-08-31 09:35:31 -07:00
|
|
|
<div className='team__name'>{this.props.teamDisplayName}</div>
|
2015-10-29 00:02:17 +05:00
|
|
|
</OverlayTrigger>
|
2015-07-08 11:50:10 -04:00
|
|
|
</div>
|
|
|
|
|
</a>
|
2015-08-31 09:35:31 -07:00
|
|
|
<NavbarDropdown
|
|
|
|
|
ref='dropdown'
|
|
|
|
|
teamType={this.props.teamType}
|
2015-10-01 17:52:47 -07:00
|
|
|
teamDisplayName={this.props.teamDisplayName}
|
|
|
|
|
teamName={this.props.teamName}
|
2015-08-31 09:35:31 -07:00
|
|
|
/>
|
2015-06-14 23:53:32 -08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-08-31 09:35:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SidebarHeader.defaultProps = {
|
2015-10-16 09:10:54 -07:00
|
|
|
teamDisplayName: global.window.mm_config.SiteName,
|
2015-08-31 09:35:31 -07:00
|
|
|
teamType: ''
|
|
|
|
|
};
|
|
|
|
|
SidebarHeader.propTypes = {
|
|
|
|
|
teamDisplayName: React.PropTypes.string,
|
2015-10-01 17:52:47 -07:00
|
|
|
teamName: React.PropTypes.string,
|
2015-08-31 09:35:31 -07:00
|
|
|
teamType: React.PropTypes.string
|
|
|
|
|
};
|