From b97b3ae6179bc15ec23e0697b08cdcbdf53e4ffc Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 29 Jun 2016 14:16:17 -0400 Subject: EE: Add the ability to restrict the user roles that can send team invites (#3442) --- webapp/components/admin_console/admin_sidebar.jsx | 14 +++++ .../admin_console/localization_settings.jsx | 13 +--- .../components/admin_console/policy_settings.jsx | 73 ++++++++++++++++++++++ webapp/components/navbar_dropdown.jsx | 10 +++ webapp/components/sidebar_right_menu.jsx | 10 +++ .../components/tutorial/tutorial_intro_screens.jsx | 67 +++++++++++--------- webapp/i18n/en.json | 8 ++- webapp/routes/route_admin_console.jsx | 5 ++ webapp/utils/channel_intro_messages.jsx | 15 ++++- webapp/utils/constants.jsx | 5 +- 10 files changed, 177 insertions(+), 43 deletions(-) create mode 100644 webapp/components/admin_console/policy_settings.jsx (limited to 'webapp') diff --git a/webapp/components/admin_console/admin_sidebar.jsx b/webapp/components/admin_console/admin_sidebar.jsx index cb98c8ab1..b045ec5f4 100644 --- a/webapp/components/admin_console/admin_sidebar.jsx +++ b/webapp/components/admin_console/admin_sidebar.jsx @@ -180,6 +180,7 @@ export default class AdminSidebar extends React.Component { let license = null; let audits = null; + let policy = null; if (window.mm_config.BuildEnterpriseReady === 'true') { if (window.mm_license.IsLicensed === 'true') { @@ -210,6 +211,18 @@ export default class AdminSidebar extends React.Component { /> ); } + + policy = ( + + } + /> + ); } license = ( @@ -328,6 +341,7 @@ export default class AdminSidebar extends React.Component { /> } /> + {policy} ); @@ -58,14 +58,7 @@ export default class LocalizationSettings extends AdminSettings { renderSettings() { return ( - - } - > + + + + ); + } + + renderSettings() { + return ( + + + } + value={this.state.restrictTeamInvite} + onChange={this.handleChange} + helpText={ + + } + /> + + ); + } +} diff --git a/webapp/components/navbar_dropdown.jsx b/webapp/components/navbar_dropdown.jsx index 9d6d7fb22..c3b646e52 100644 --- a/webapp/components/navbar_dropdown.jsx +++ b/webapp/components/navbar_dropdown.jsx @@ -119,6 +119,16 @@ export default class NavbarDropdown extends React.Component { ); } + + if (global.window.mm_license.IsLicensed === 'true') { + if (global.window.mm_config.RestrictTeamInvite === Constants.TEAM_INVITE_SYSTEM_ADMIN && !isSystemAdmin) { + teamLink = null; + inviteLink = null; + } else if (global.window.mm_config.RestrictTeamInvite === Constants.TEAM_INVITE_TEAM_ADMIN && !isAdmin) { + teamLink = null; + inviteLink = null; + } + } } if (isAdmin) { diff --git a/webapp/components/sidebar_right_menu.jsx b/webapp/components/sidebar_right_menu.jsx index 622b80337..8cb8733d7 100644 --- a/webapp/components/sidebar_right_menu.jsx +++ b/webapp/components/sidebar_right_menu.jsx @@ -184,6 +184,16 @@ export default class SidebarRightMenu extends React.Component { ); } + + if (global.window.mm_license.IsLicensed === 'true') { + if (global.window.mm_config.RestrictTeamInvite === Constants.TEAM_INVITE_SYSTEM_ADMIN && !isSystemAdmin) { + teamLink = null; + inviteLink = null; + } else if (global.window.mm_config.RestrictTeamInvite === Constants.TEAM_INVITE_TEAM_ADMIN && !isAdmin) { + teamLink = null; + inviteLink = null; + } + } } if (isAdmin) { diff --git a/webapp/components/tutorial/tutorial_intro_screens.jsx b/webapp/components/tutorial/tutorial_intro_screens.jsx index 3928b7f20..b0d831d96 100644 --- a/webapp/components/tutorial/tutorial_intro_screens.jsx +++ b/webapp/components/tutorial/tutorial_intro_screens.jsx @@ -106,32 +106,45 @@ export default class TutorialIntroScreens extends React.Component { createScreenThree() { const team = TeamStore.getCurrent(); let inviteModalLink; + let inviteText; - if (team.type === Constants.INVITE_TEAM) { - inviteModalLink = ( - - - - ); - } else { - inviteModalLink = ( - + if (global.window.mm_license.IsLicensed !== 'true' || global.window.mm_config.RestrictTeamInvite === Constants.TEAM_INVITE_ALL) { + if (team.type === Constants.INVITE_TEAM) { + inviteModalLink = ( + + + + ); + } else { + inviteModalLink = ( + + + + ); + } + + inviteText = ( +

+ {inviteModalLink} - +

); } @@ -170,13 +183,7 @@ export default class TutorialIntroScreens extends React.Component { defaultMessage='You’re all set' /> -

- {inviteModalLink} - -

+ {inviteText} {supportInfo}
Selecting \"Team and System Admins\" hides the email invitation and team invite link in the Main Menu from users who are not Team or System Admins. Note: If \"Get Team Invite Link\" is used to share a link, it will need to be regenerated after the desired users joined the team.

Selecting \"System Admins\" hides the email invitation and team invite link in the Main Menu from users who are not System Admins. Note: If \"Get Team Invite Link\" is used to share a link, it will need to be regenerated after the desired users joined the team.", "admin.general.privacy": "Privacy", - "admin.general.title": "General Settings", "admin.general.usersAndTeams": "Users and Teams", "admin.gitab.clientSecretDescription": "Obtain this value via the instructions above for logging into GitLab.", "admin.gitlab.EnableHtmlDesc": "
  1. Log in to your GitLab account and go to Profile Settings -> Applications.
  2. Enter Redirect URIs \"/login/gitlab/complete\" (example: http://localhost:8065/login/gitlab/complete) and \"/signup/gitlab/complete\".
  3. Then use \"Secret\" and \"Id\" fields from GitLab to complete the options below.
  4. Complete the Endpoint URLs below.
", @@ -488,6 +493,7 @@ "admin.sidebar.logs": "Logs", "admin.sidebar.notifications": "Notifications", "admin.sidebar.other": "OTHER", + "admin.sidebar.policy": "Policy", "admin.sidebar.privacy": "Privacy", "admin.sidebar.publicLinks": "Public Links", "admin.sidebar.push": "Mobile Push", diff --git a/webapp/routes/route_admin_console.jsx b/webapp/routes/route_admin_console.jsx index cd1144ae6..b088b430b 100644 --- a/webapp/routes/route_admin_console.jsx +++ b/webapp/routes/route_admin_console.jsx @@ -10,6 +10,7 @@ import ConfigurationSettings from 'components/admin_console/configuration_settin import LocalizationSettings from 'components/admin_console/localization_settings.jsx'; import UsersAndTeamsSettings from 'components/admin_console/users_and_teams_settings.jsx'; import PrivacySettings from 'components/admin_console/privacy_settings.jsx'; +import PolicySettings from 'components/admin_console/policy_settings.jsx'; import LogSettings from 'components/admin_console/log_settings.jsx'; import EmailAuthenticationSettings from 'components/admin_console/email_authentication_settings.jsx'; import GitLabSettings from 'components/admin_console/gitlab_settings.jsx'; @@ -62,6 +63,10 @@ export default ( path='privacy' component={PrivacySettings} /> + ); + const isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); + const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); + + if (global.window.mm_license.IsLicensed === 'true') { + if (global.window.mm_config.RestrictTeamInvite === Constants.TEAM_INVITE_SYSTEM_ADMIN && !isSystemAdmin) { + inviteModalLink = null; + } else if (global.window.mm_config.RestrictTeamInvite === Constants.TEAM_INVITE_TEAM_ADMIN && !isAdmin) { + inviteModalLink = null; + } + } + return (