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/team_members_dropdown.jsx | 36 ++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

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

diff --git a/webapp/components/team_members_dropdown.jsx b/webapp/components/team_members_dropdown.jsx
index 2b40da9cf..43449635d 100644
--- a/webapp/components/team_members_dropdown.jsx
+++ b/webapp/components/team_members_dropdown.jsx
@@ -19,6 +19,7 @@ export default class TeamMembersDropdown extends React.Component {
         super(props);
 
         this.handleMakeMember = this.handleMakeMember.bind(this);
+        this.handleRemoveFromTeam = this.handleRemoveFromTeam.bind(this);
         this.handleMakeActive = this.handleMakeActive.bind(this);
         this.handleMakeNotActive = this.handleMakeNotActive.bind(this);
         this.handleMakeAdmin = this.handleMakeAdmin.bind(this);
@@ -52,6 +53,19 @@ export default class TeamMembersDropdown extends React.Component {
             );
         }
     }
+    handleRemoveFromTeam() {
+        Client.removeUserFromTeam(
+                '',
+                this.props.user.id,
+                () => {
+                    AsyncClient.getTeamMembers(TeamStore.getCurrentId());
+                    AsyncClient.getProfiles();
+                },
+                (err) => {
+                    this.setState({serverError: err.message});
+                }
+            );
+    }
     handleMakeActive() {
         Client.updateActive(this.props.user.id, true,
             () => {
@@ -171,6 +185,7 @@ export default class TeamMembersDropdown extends React.Component {
             );
         }
 
+        const me = UserStore.getCurrentUser();
         let showMakeMember = teamMember.roles === 'admin' || user.roles === 'system_admin';
         let showMakeAdmin = teamMember.roles === '' && user.roles !== 'system_admin';
         let showMakeActive = false;
@@ -225,6 +240,24 @@ export default class TeamMembersDropdown extends React.Component {
             );
         }
 
+        let removeFromTeam = null;
+        if (this.props.user.id !== me.id) {
+            removeFromTeam = (
+                <li role='presentation'>
+                    <a
+                        role='menuitem'
+                        href='#'
+                        onClick={this.handleRemoveFromTeam}
+                    >
+                        <FormattedMessage
+                            id='team_members_dropdown.leave_team'
+                            defaultMessage='Remove From Team'
+                        />
+                    </a>
+                </li>
+            );
+        }
+
         let makeActive = null;
         if (showMakeActive) {
             // makeActive = (
@@ -260,7 +293,7 @@ export default class TeamMembersDropdown extends React.Component {
             //     </li>
             // );
         }
-        const me = UserStore.getCurrentUser();
+
         let makeDemoteModal = null;
         if (this.props.user.id === me.id) {
             const title = (
@@ -321,6 +354,7 @@ export default class TeamMembersDropdown extends React.Component {
                     className='dropdown-menu member-menu'
                     role='menu'
                 >
+                    {removeFromTeam}
                     {makeAdmin}
                     {makeMember}
                     {makeActive}
-- 
cgit v1.2.3-1-g7c22

