// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import $ from 'jquery'; import AdminSidebarHeader from './admin_sidebar_header.jsx'; import SelectTeamModal from './select_team_modal.jsx'; import * as Utils from 'utils/utils.jsx'; import {FormattedMessage} from 'react-intl'; import {Tooltip, OverlayTrigger} from 'react-bootstrap'; import React from 'react'; export default class AdminSidebar extends React.Component { constructor(props) { super(props); this.isSelected = this.isSelected.bind(this); this.handleClick = this.handleClick.bind(this); this.removeTeam = this.removeTeam.bind(this); this.showTeamSelect = this.showTeamSelect.bind(this); this.teamSelectedModal = this.teamSelectedModal.bind(this); this.teamSelectedModalDismissed = this.teamSelectedModalDismissed.bind(this); this.state = { showSelectModal: false }; } componentDidUpdate() { if (!Utils.isMobile()) { $('.sidebar--left .nav-pills__container').perfectScrollbar(); } } handleClick(name, teamId, e) { e.preventDefault(); this.props.selectTab(name, teamId); } isSelected(name, teamId) { if (this.props.selected === name) { if (name === 'team_users' || name === 'team_analytics') { if (this.props.selectedTeam != null && this.props.selectedTeam === teamId) { return 'active'; } } else { return 'active'; } } return ''; } removeTeam(teamId, e) { e.preventDefault(); e.stopPropagation(); Reflect.deleteProperty(this.props.selectedTeams, teamId); this.props.removeSelectedTeam(teamId); if (this.props.selected === 'team_users') { if (this.props.selectedTeam != null && this.props.selectedTeam === teamId) { this.props.selectTab('service_settings', null); } } } showTeamSelect(e) { e.preventDefault(); this.setState({showSelectModal: true}); } teamSelectedModal(teamId) { this.setState({showSelectModal: false}); this.props.addSelectedTeam(teamId); this.forceUpdate(); } teamSelectedModalDismissed() { this.setState({showSelectModal: false}); } render() { var count = '*'; var teams = ( ); const removeTooltip = ( ); const addTeamTooltip = ( ); if (this.props.teams != null) { count = '' + Object.keys(this.props.teams).length; teams = []; for (var key in this.props.selectedTeams) { if (this.props.selectedTeams.hasOwnProperty(key)) { var team = this.props.teams[key]; if (team != null) { teams.push( ); } } } } let ldapSettings; let complianceSettings; let licenseSettings; if (global.window.mm_config.BuildEnterpriseReady === 'true') { if (global.window.mm_license.IsLicensed === 'true') { if (global.window.mm_license.LDAP === 'true') { ldapSettings = (
  • ); } if (global.window.mm_license.Compliance === 'true') { complianceSettings = (
  • ); } } licenseSettings = (
  • ); } let audits; if (global.window.mm_license.IsLicensed === 'true') { audits = (
  • ); } return (
      • {teams}
        {licenseSettings} {audits}
    ); } } AdminSidebar.propTypes = { teams: React.PropTypes.object, selectedTeams: React.PropTypes.object, removeSelectedTeam: React.PropTypes.func, addSelectedTeam: React.PropTypes.func, selected: React.PropTypes.string, selectedTeam: React.PropTypes.string, selectTab: React.PropTypes.func };