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-11-19 21:12:56 -05:00
|
|
|
import NavbarDropdown from './navbar_dropdown.jsx';
|
|
|
|
|
import TutorialTip from './tutorial/tutorial_tip.jsx';
|
2015-10-30 11:35:16 -04:00
|
|
|
|
2015-11-19 21:12:56 -05:00
|
|
|
import UserStore from '../stores/user_store.jsx';
|
|
|
|
|
import PreferenceStore from '../stores/preference_store.jsx';
|
2015-10-30 11:35:16 -04:00
|
|
|
|
2015-11-19 21:12:56 -05:00
|
|
|
import * as Utils from '../utils/utils.jsx';
|
|
|
|
|
import Constants from '../utils/constants.jsx';
|
2015-10-30 11:35:16 -04:00
|
|
|
const Preferences = Constants.Preferences;
|
|
|
|
|
const TutorialSteps = Constants.TutorialSteps;
|
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-10-30 11:35:16 -04:00
|
|
|
this.onPreferenceChange = this.onPreferenceChange.bind(this);
|
2015-06-14 23:53:32 -08:00
|
|
|
|
2015-10-30 11:35:16 -04:00
|
|
|
this.state = this.getStateFromStores();
|
|
|
|
|
}
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
PreferenceStore.addChangeListener(this.onPreferenceChange);
|
|
|
|
|
}
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
PreferenceStore.removeChangeListener(this.onPreferenceChange);
|
|
|
|
|
}
|
|
|
|
|
getStateFromStores() {
|
2015-12-15 11:36:14 -05:00
|
|
|
const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999);
|
2015-10-30 11:35:16 -04:00
|
|
|
|
2015-12-15 11:36:14 -05:00
|
|
|
return {showTutorialTip: tutorialStep === TutorialSteps.MENU_POPOVER};
|
2015-10-30 11:35:16 -04:00
|
|
|
}
|
|
|
|
|
onPreferenceChange() {
|
|
|
|
|
this.setState(this.getStateFromStores());
|
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
|
|
|
}
|
2015-10-30 11:35:16 -04:00
|
|
|
createTutorialTip() {
|
|
|
|
|
const screens = [];
|
|
|
|
|
|
|
|
|
|
screens.push(
|
|
|
|
|
<div>
|
2015-11-02 20:57:23 +05:00
|
|
|
<h4>{'Main Menu'}</h4>
|
|
|
|
|
<p>
|
2015-10-30 11:35:16 -04:00
|
|
|
{'The '}<strong>{'Main Menu'}</strong>{' is where you can '}
|
2015-11-02 11:10:32 -05:00
|
|
|
<strong>{'Invite New Members'}</strong>
|
2015-10-30 11:35:16 -04:00
|
|
|
{', access your '}
|
2015-11-02 11:10:32 -05:00
|
|
|
<strong>{'Account Settings'}</strong>
|
2015-11-02 15:10:46 -05:00
|
|
|
{' and set your '}<strong>{'Theme Color'}</strong>{'.'}
|
2015-11-02 20:57:23 +05:00
|
|
|
</p>
|
|
|
|
|
<p>
|
2015-11-02 11:10:32 -05:00
|
|
|
{'Team administrators can also access their '}<strong>{'Team Settings'}</strong>{' from this menu.'}
|
2015-11-02 20:57:23 +05:00
|
|
|
</p>
|
2015-11-03 08:44:28 -08:00
|
|
|
<p>
|
|
|
|
|
{'System administrators will find a '}<strong>{'System Console'}</strong>{' option to administrate the entire system.'}
|
|
|
|
|
</p>
|
2015-10-30 11:35:16 -04:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
onClick={this.toggleDropdown}
|
|
|
|
|
>
|
|
|
|
|
<TutorialTip
|
|
|
|
|
ref='tip'
|
|
|
|
|
placement='right'
|
|
|
|
|
screens={screens}
|
2015-11-02 20:57:23 +05:00
|
|
|
overlayClass='tip-overlay--header'
|
2015-10-30 11:35:16 -04:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
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-10-30 11:35:16 -04:00
|
|
|
let tutorialTip = null;
|
|
|
|
|
if (this.state.showTutorialTip) {
|
|
|
|
|
tutorialTip = this.createTutorialTip();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-14 23:53:32 -08:00
|
|
|
return (
|
2015-08-04 09:40:58 -07:00
|
|
|
<div className='team__header theme'>
|
2015-10-30 11:35:16 -04:00
|
|
|
{tutorialTip}
|
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
|
|
|
|
|
};
|