From d5f243dad694d6746ec2b6560a81212a78d8c975 Mon Sep 17 00:00:00 2001
From: Corey Hulen <corey@hulen.com>
Date: Wed, 6 Jul 2016 13:40:59 -0800
Subject: PLT-2863 adding remove user from team (#3429)

* PLT-2863 adding remove user from team

* PLT-2863 adding the client side UI

* Fixing trailing space

* Fixing reported issues

* Adding documentatino

* Switching to final javascript driver
---
 webapp/components/leave_team_modal.jsx | 115 +++++++++++++++++++++++++++++++++
 1 file changed, 115 insertions(+)
 create mode 100644 webapp/components/leave_team_modal.jsx

(limited to 'webapp/components/leave_team_modal.jsx')

diff --git a/webapp/components/leave_team_modal.jsx b/webapp/components/leave_team_modal.jsx
new file mode 100644
index 000000000..7263f23d4
--- /dev/null
+++ b/webapp/components/leave_team_modal.jsx
@@ -0,0 +1,115 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import Constants from 'utils/constants.jsx';
+const ActionTypes = Constants.ActionTypes;
+import * as GlobalActions from 'actions/global_actions.jsx';
+import ModalStore from 'stores/modal_store.jsx';
+import UserStore from 'stores/user_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() {
+        GlobalActions.emitLeaveTeam();
+
+        this.setState({
+            show: false
+        });
+    }
+
+    handleHide() {
+        this.setState({
+            show: false
+        });
+    }
+
+    render() {
+        var currentUser = UserStore.getCurrentUser();
+
+        if (currentUser != null) {
+            return (
+                <Modal
+                    className='modal-confirm'
+                    show={this.state.show}
+                    onHide={this.handleHide}
+                >
+                    <Modal.Header closeButton={false}>
+                        <Modal.Title>
+                            <FormattedMessage
+                                id='leave_team_modal.title'
+                                defaultMessage='Leave the team?'
+                            />
+                        </Modal.Title>
+                    </Modal.Header>
+                    <Modal.Body>
+                        <FormattedMessage
+                            id='leave_team_modal.desc'
+                            defaultMessage='You will be removed from all public channels and private groups.  If the team is private you will not be able to rejoin the team.  Are you sure?'
+                        />
+                    </Modal.Body>
+                    <Modal.Footer>
+                        <button
+                            type='button'
+                            className='btn btn-default'
+                            onClick={this.handleHide}
+                        >
+                            <FormattedMessage
+                                id='leave_team_modal.no'
+                                defaultMessage='No'
+                            />
+                        </button>
+                        <button
+                            type='button'
+                            className='btn btn-danger'
+                            onClick={this.handleSubmit}
+                        >
+                            <FormattedMessage
+                                id='leave_team_modal.yes'
+                                defaultMessage='Yes'
+                            />
+                        </button>
+                    </Modal.Footer>
+                </Modal>
+            );
+        }
+
+        return null;
+    }
+}
+
+LeaveTeamModal.propTypes = {
+    intl: intlShape.isRequired
+};
+
+export default injectIntl(LeaveTeamModal);
-- 
cgit v1.2.3-1-g7c22

