summaryrefslogtreecommitdiffstats
path: root/webapp/components/sidebar_header.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-14 08:50:46 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-16 18:02:55 -0400
commit12896bd23eeba79884245c1c29fdc568cf21a7fa (patch)
tree4e7f83d3e2564b9b89d669e9f7905ff11768b11a /webapp/components/sidebar_header.jsx
parent29fe6a3d13c9c7aa490fffebbe5d1b5fdf1e3090 (diff)
downloadchat-12896bd23eeba79884245c1c29fdc568cf21a7fa.tar.gz
chat-12896bd23eeba79884245c1c29fdc568cf21a7fa.tar.bz2
chat-12896bd23eeba79884245c1c29fdc568cf21a7fa.zip
Converting to Webpack. Stage 1.
Diffstat (limited to 'webapp/components/sidebar_header.jsx')
-rw-r--r--webapp/components/sidebar_header.jsx143
1 files changed, 143 insertions, 0 deletions
diff --git a/webapp/components/sidebar_header.jsx b/webapp/components/sidebar_header.jsx
new file mode 100644
index 000000000..3cb2a3e81
--- /dev/null
+++ b/webapp/components/sidebar_header.jsx
@@ -0,0 +1,143 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import $ from 'jquery';
+import NavbarDropdown from './navbar_dropdown.jsx';
+import TutorialTip from './tutorial/tutorial_tip.jsx';
+
+import PreferenceStore from 'stores/preference_store.jsx';
+
+import Constants from 'utils/constants.jsx';
+
+import {FormattedHTMLMessage} from 'react-intl';
+
+const Preferences = Constants.Preferences;
+const TutorialSteps = Constants.TutorialSteps;
+
+import {Tooltip, OverlayTrigger} from 'react-bootstrap';
+
+import React from 'react';
+
+export default class SidebarHeader extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.toggleDropdown = this.toggleDropdown.bind(this);
+ this.onPreferenceChange = this.onPreferenceChange.bind(this);
+
+ this.state = this.getStateFromStores();
+ }
+ componentDidMount() {
+ PreferenceStore.addChangeListener(this.onPreferenceChange);
+ }
+ componentWillUnmount() {
+ PreferenceStore.removeChangeListener(this.onPreferenceChange);
+ }
+ getStateFromStores() {
+ const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, this.props.currentUser.id, 999);
+
+ return {showTutorialTip: tutorialStep === TutorialSteps.MENU_POPOVER};
+ }
+ onPreferenceChange() {
+ this.setState(this.getStateFromStores());
+ }
+ toggleDropdown(e) {
+ e.preventDefault();
+ if (this.refs.dropdown.blockToggle) {
+ this.refs.dropdown.blockToggle = false;
+ return;
+ }
+ $('.team__header').find('.dropdown-toggle').dropdown('toggle');
+ }
+ createTutorialTip() {
+ const screens = [];
+
+ screens.push(
+ <div>
+ <FormattedHTMLMessage
+ id='sidebar_header.tutorial'
+ defaultMessage='<h4>Main Menu</h4>
+ <p>The <strong>Main Menu</strong> is where you can <strong>Invite New Members</strong>, access your <strong>Account Settings</strong> and set your <strong>Theme Color</strong>.</p>
+ <p>Team administrators can also access their <strong>Team Settings</strong> from this menu.</p><p>System administrators will find a <strong>System Console</strong> option to administrate the entire system.</p>'
+ />
+ </div>
+ );
+
+ return (
+ <div
+ onClick={this.toggleDropdown}
+ >
+ <TutorialTip
+ ref='tip'
+ placement='right'
+ screens={screens}
+ overlayClass='tip-overlay--header'
+ />
+ </div>
+ );
+ }
+ render() {
+ var me = this.props.currentUser;
+ var profilePicture = null;
+
+ if (!me) {
+ return null;
+ }
+
+ if (me.last_picture_update) {
+ profilePicture = (
+ <img
+ className='user__picture'
+ src={'/api/v1/users/' + me.id + '/image?time=' + me.update_at}
+ />
+ );
+ }
+
+ let tutorialTip = null;
+ if (this.state.showTutorialTip) {
+ tutorialTip = this.createTutorialTip();
+ }
+
+ return (
+ <div className='team__header theme'>
+ {tutorialTip}
+ <a
+ href='#'
+ onClick={this.toggleDropdown}
+ >
+ {profilePicture}
+ <div className='header__info'>
+ <div className='user__name'>{'@' + me.username}</div>
+ <OverlayTrigger
+ trigger={['hover', 'focus']}
+ delayShow={1000}
+ placement='bottom'
+ overlay={<Tooltip id='team-name__tooltip'>{this.props.teamDisplayName}</Tooltip>}
+ ref='descriptionOverlay'
+ >
+ <div className='team__name'>{this.props.teamDisplayName}</div>
+ </OverlayTrigger>
+ </div>
+ </a>
+ <NavbarDropdown
+ ref='dropdown'
+ teamType={this.props.teamType}
+ teamDisplayName={this.props.teamDisplayName}
+ teamName={this.props.teamName}
+ currentUser={this.props.currentUser}
+ />
+ </div>
+ );
+ }
+}
+
+SidebarHeader.defaultProps = {
+ teamDisplayName: '',
+ teamType: ''
+};
+SidebarHeader.propTypes = {
+ teamDisplayName: React.PropTypes.string,
+ teamName: React.PropTypes.string,
+ teamType: React.PropTypes.string,
+ currentUser: React.PropTypes.object
+};