// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import TeamMembersModal from './team_members_modal.jsx'; import ToggleModalButton from './toggle_modal_button.jsx'; import UserSettingsModal from './user_settings/user_settings_modal.jsx'; import AboutBuildModal from './about_build_modal.jsx'; import UserStore from 'stores/user_store.jsx'; import TeamStore from 'stores/team_store.jsx'; import PreferenceStore from 'stores/preference_store.jsx'; import * as GlobalActions from 'action_creators/global_actions.jsx'; import * as Utils from 'utils/utils.jsx'; import Constants from 'utils/constants.jsx'; const Preferences = Constants.Preferences; const TutorialSteps = Constants.TutorialSteps; import {FormattedMessage} from 'react-intl'; import {Link} from 'react-router'; import {createMenuTip} from 'components/tutorial/tutorial_tip.jsx'; import React from 'react'; import PureRenderMixin from 'react-addons-pure-render-mixin'; export default class SidebarRightMenu extends React.Component { constructor(props) { super(props); this.onPreferenceChange = this.onPreferenceChange.bind(this); this.handleAboutModal = this.handleAboutModal.bind(this); this.aboutModalDismissed = this.aboutModalDismissed.bind(this); const state = this.getStateFromStores(); state.showUserSettingsModal = false; state.showAboutModal = false; this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this); this.state = state; } handleAboutModal() { this.setState({showAboutModal: true}); } aboutModalDismissed() { this.setState({showAboutModal: false}); } componentDidMount() { PreferenceStore.addChangeListener(this.onPreferenceChange); } componentWillUnmount() { PreferenceStore.removeChangeListener(this.onPreferenceChange); } getStateFromStores() { const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999); return {showTutorialTip: tutorialStep === TutorialSteps.MENU_POPOVER && Utils.isMobile()}; } onPreferenceChange() { this.setState(this.getStateFromStores()); } render() { var teamLink = ''; var inviteLink = ''; var teamSettingsLink = ''; var manageLink = ''; var consoleLink = ''; var currentUser = UserStore.getCurrentUser(); var isAdmin = false; var isSystemAdmin = false; if (currentUser != null) { isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); inviteLink = (