From 45b22f312d3f57c63f86ffdbbb50c29108099993 Mon Sep 17 00:00:00 2001
From: enahum <nahumhbl@gmail.com>
Date: Tue, 10 May 2016 09:24:52 -0300
Subject: PLT-2674 Private Group should not have Leave option when only one
 member remains (#2888)

---
 webapp/components/navbar.jsx | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

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

diff --git a/webapp/components/navbar.jsx b/webapp/components/navbar.jsx
index 21ca53649..ee199fc03 100644
--- a/webapp/components/navbar.jsx
+++ b/webapp/components/navbar.jsx
@@ -218,20 +218,23 @@ export default class Navbar extends React.Component {
                     </li>
                 );
 
-                leaveChannelOption = (
-                    <li role='presentation'>
-                        <a
-                            role='menuitem'
-                            href='#'
-                            onClick={this.handleLeave}
-                        >
-                            <FormattedMessage
-                                id='navbar.leave'
-                                defaultMessage='Leave Channel'
-                            />
-                        </a>
-                    </li>
-                );
+                const canLeave = channel.type === Constants.PRIVATE_CHANNEL ? this.state.userCount > 1 : true;
+                if (canLeave) {
+                    leaveChannelOption = (
+                        <li role='presentation'>
+                            <a
+                                role='menuitem'
+                                href='#'
+                                onClick={this.handleLeave}
+                            >
+                                <FormattedMessage
+                                    id='navbar.leave'
+                                    defaultMessage='Leave Channel'
+                                />
+                            </a>
+                        </li>
+                    );
+                }
             }
 
             var manageMembersOption;
-- 
cgit v1.2.3-1-g7c22

