// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import {ActionTypes, WebrtcActionTypes} from 'utils/constants.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; import ModalStore from 'stores/modal_store.jsx'; import UserStore from 'stores/user_store.jsx'; import WebrtcStore from 'stores/webrtc_store.jsx'; import {intlShape, injectIntl, FormattedMessage} from 'react-intl'; import {Modal} from 'react-bootstrap'; import React from 'react'; class LeaveTeamModal extends React.Component { constructor(props) { super(props); this.handleToggle = this.handleToggle.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.handleHide = this.handleHide.bind(this); this.state = { show: false }; } componentDidMount() { ModalStore.addModalListener(ActionTypes.TOGGLE_LEAVE_TEAM_MODAL, this.handleToggle); } componentWillUnmount() { ModalStore.removeModalListener(ActionTypes.TOGGLE_LEAVE_TEAM_MODAL, this.handleToggle); } handleToggle(value) { this.setState({ show: value }); } handleSubmit(e) { this.setState({ show: false }); if (WebrtcStore.isBusy()) { WebrtcStore.emitChanged({action: WebrtcActionTypes.IN_PROGRESS}); e.preventDefault(); return; } GlobalActions.emitLeaveTeam(); } handleHide() { this.setState({ show: false }); } render() { var currentUser = UserStore.getCurrentUser(); if (currentUser != null) { return ( ); } return null; } } LeaveTeamModal.propTypes = { intl: intlShape.isRequired }; export default injectIntl(LeaveTeamModal);