diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-07-06 08:23:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-06 08:23:24 -0400 |
commit | 5f7cb8cfbf879aa0b0d43a7b7068688368fda9fc (patch) | |
tree | 555f578f1346d0b18448176ce1dc2a4771f16c6a /webapp/components/new_channel_modal.jsx | |
parent | 19d452c74efb96f718079d5a268ca51a8983c4bd (diff) | |
download | chat-5f7cb8cfbf879aa0b0d43a7b7068688368fda9fc.tar.gz chat-5f7cb8cfbf879aa0b0d43a7b7068688368fda9fc.tar.bz2 chat-5f7cb8cfbf879aa0b0d43a7b7068688368fda9fc.zip |
PLT-3346/PLT-3342/PLT-3360 EE: Add the ability to restrict channel management permissions (#3453)
* EE: Add the ability to restrict channel management permissions
* Always allow last user in a channel to delete that channel
Diffstat (limited to 'webapp/components/new_channel_modal.jsx')
-rw-r--r-- | webapp/components/new_channel_modal.jsx | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/webapp/components/new_channel_modal.jsx b/webapp/components/new_channel_modal.jsx index 9fd76395c..23eee625d 100644 --- a/webapp/components/new_channel_modal.jsx +++ b/webapp/components/new_channel_modal.jsx @@ -3,8 +3,12 @@ import $ from 'jquery'; import ReactDOM from 'react-dom'; + import * as Utils from 'utils/utils.jsx'; import Constants from 'utils/constants.jsx'; + +import UserStore from 'stores/user_store.jsx'; +import TeamStore from 'stores/team_store.jsx'; import PreferenceStore from 'stores/preference_store.jsx'; import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'react-intl'; @@ -113,6 +117,47 @@ class NewChannelModal extends React.Component { serverError = <div className='form-group has-error'><p className='input__help error'>{this.props.serverError}</p></div>; } + let createPublicChannelLink = ( + <a + href='#' + onClick={this.props.onTypeSwitched} + > + <FormattedMessage + id='channel_modal.publicChannel1' + defaultMessage='Create a public channel' + /> + </a> + ); + + let createPrivateChannelLink = ( + <a + href='#' + onClick={this.props.onTypeSwitched} + > + <FormattedMessage + id='channel_modal.privateGroup2' + defaultMessage='Create a private group' + /> + </a> + ); + + const isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); + const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); + + if (global.window.mm_license.IsLicensed === 'true') { + if (global.window.mm_config.RestrictPublicChannelManagement === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { + createPublicChannelLink = null; + } else if (global.window.mm_config.RestrictPublicChannelManagement === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + createPublicChannelLink = null; + } + + if (global.window.mm_config.RestrictPrivateChannelManagement === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { + createPrivateChannelLink = null; + } else if (global.window.mm_config.RestrictPrivateChannelManagement === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + createPrivateChannelLink = null; + } + } + var channelTerm = ''; var channelSwitchText = ''; switch (this.props.channelType) { @@ -129,15 +174,7 @@ class NewChannelModal extends React.Component { id='channel_modal.privateGroup1' defaultMessage='Create a new private group with restricted membership. ' /> - <a - href='#' - onClick={this.props.onTypeSwitched} - > - <FormattedMessage - id='channel_modal.publicChannel1' - defaultMessage='Create a public channel' - /> - </a> + {createPublicChannelLink} </div> ); break; @@ -154,15 +191,7 @@ class NewChannelModal extends React.Component { id='channel_modal.publicChannel2' defaultMessage='Create a new public channel anyone can join. ' /> - <a - href='#' - onClick={this.props.onTypeSwitched} - > - <FormattedMessage - id='channel_modal.privateGroup2' - defaultMessage='Create a private group' - /> - </a> + {createPrivateChannelLink} </div> ); break; |