// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. var AdminSidebarHeader = require('./admin_sidebar_header.jsx'); var SelectTeamModal = require('./select_team_modal.jsx'); 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 }; } handleClick(name, teamId, e) { e.preventDefault(); this.props.selectTab(name, teamId); history.pushState({name: name, teamId: teamId}, null, `/admin_console/${name}/${teamId || ''}`); } isSelected(name, teamId) { if (this.props.selected === name) { if (name === 'team_users') { if (this.props.selectedTeam != null && this.props.selectedTeam === teamId) { return 'active'; } } else { return 'active'; } } return ''; } removeTeam(teamId, e) { e.preventDefault(); 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); } } } componentDidMount() { } showTeamSelect(e) { e.preventDefault(); this.setState({showSelectModal: true}); } teamSelectedModal(teamId) { this.props.selectedTeams[teamId] = 'true'; this.setState({showSelectModal: false}); this.props.addSelectedTeam(teamId); this.forceUpdate(); } teamSelectedModalDismissed() { this.setState({showSelectModal: false}); } render() { var count = '*'; var teams = 'Loading'; 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(
); } } } } return ( ); } } 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 };