From 9c79f02ca44961feef36b933be7e0ebec06fa427 Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Thu, 10 Dec 2015 16:47:09 -0800
Subject: Disables the ability to send email invites when user creation is
 disabled

---
 web/react/components/invite_member_modal.jsx | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

(limited to 'web/react/components/invite_member_modal.jsx')

diff --git a/web/react/components/invite_member_modal.jsx b/web/react/components/invite_member_modal.jsx
index 649ec7321..56bc00a7e 100644
--- a/web/react/components/invite_member_modal.jsx
+++ b/web/react/components/invite_member_modal.jsx
@@ -33,6 +33,7 @@ export default class InviteMemberModal extends React.Component {
             firstNameErrors: {},
             lastNameErrors: {},
             emailEnabled: global.window.mm_config.SendEmailNotifications === 'true',
+            userCreationEnabled: global.window.mm_config.EnableUserCreation === 'true',
             showConfirmModal: false,
             isSendingEmails: false
         };
@@ -252,7 +253,7 @@ export default class InviteMemberModal extends React.Component {
                                             ref={'first_name' + index}
                                             placeholder='First name'
                                             maxLength='64'
-                                            disabled={!this.state.emailEnabled}
+                                            disabled={!this.state.emailEnabled || !this.state.userCreationEnabled}
                                             spellCheck='false'
                                         />
                                         {firstNameError}
@@ -266,7 +267,7 @@ export default class InviteMemberModal extends React.Component {
                                             ref={'last_name' + index}
                                             placeholder='Last name'
                                             maxLength='64'
-                                            disabled={!this.state.emailEnabled}
+                                            disabled={!this.state.emailEnabled || !this.state.userCreationEnabled}
                                             spellCheck='false'
                                         />
                                         {lastNameError}
@@ -285,7 +286,7 @@ export default class InviteMemberModal extends React.Component {
                             className='form-control'
                             placeholder='email@domain.com'
                             maxLength='64'
-                            disabled={!this.state.emailEnabled}
+                            disabled={!this.state.emailEnabled || !this.state.userCreationEnabled}
                             spellCheck='false'
                         />
                         {emailError}
@@ -303,7 +304,7 @@ export default class InviteMemberModal extends React.Component {
             var content = null;
             var sendButton = null;
 
-            if (this.state.emailEnabled) {
+            if (this.state.emailEnabled && this.state.userCreationEnabled) {
                 content = (
                     <div>
                         {serverError}
@@ -337,7 +338,7 @@ export default class InviteMemberModal extends React.Component {
                         {sendButtonLabel}
                     </button>
                 );
-            } else {
+            } else if (this.state.userCreationEnabled) {
                 var teamInviteLink = null;
                 if (currentUser && TeamStore.getCurrent().type === 'O') {
                     var link = (
@@ -358,10 +359,16 @@ export default class InviteMemberModal extends React.Component {
 
                 content = (
                     <div>
-                        <p>Email is currently disabled for your team, and email invitations cannot be sent. Contact your system administrator to enable email and email invitations.</p>
+                        <p>{'Email is currently disabled for your team, and email invitations cannot be sent. Contact your system administrator to enable email and email invitations.'}</p>
                         {teamInviteLink}
                     </div>
                 );
+            } else {
+                content = (
+                    <div>
+                        <p>{'User creation has been disabled for your team. Please ask your team administrator for details.'}</p>
+                    </div>
+                );
             }
 
             return (
-- 
cgit v1.2.3-1-g7c22

