diff options
author | George Goldberg <george@gberg.me> | 2017-01-02 22:35:26 +0000 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-01-02 19:35:26 -0300 |
commit | e3b8511462552dddabe257ee16d74492fdaedb2c (patch) | |
tree | 2e9224295a5209a269dfa802daa313276a42b10e /webapp/utils | |
parent | 267257b68055684f8bff94e4ae78d4b9e9c93b0b (diff) | |
download | chat-e3b8511462552dddabe257ee16d74492fdaedb2c.tar.gz chat-e3b8511462552dddabe257ee16d74492fdaedb2c.tar.bz2 chat-e3b8511462552dddabe257ee16d74492fdaedb2c.zip |
PLT-4990 (WebApp): Separate channel management permissions. (#4865)
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/channel_utils.jsx | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/webapp/utils/channel_utils.jsx b/webapp/utils/channel_utils.jsx index 113d86ea8..50573e077 100644 --- a/webapp/utils/channel_utils.jsx +++ b/webapp/utils/channel_utils.jsx @@ -82,6 +82,76 @@ export function sortChannelsByDisplayName(a, b) { return buildDisplayNameAndTypeComparable(a).localeCompare(buildDisplayNameAndTypeComparable(b), locale, {numeric: true}); } +export function showCreateOption(channelType, isAdmin, isSystemAdmin) { + if (global.window.mm_license.IsLicensed !== 'true') { + return true; + } + + if (channelType === Constants.OPEN_CHANNEL) { + if (global.window.mm_config.RestrictPublicChannelCreation === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { + return false; + } else if (global.window.mm_config.RestrictPublicChannelCreation === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + return false; + } + } else if (channelType === Constants.PRIVATE_CHANNEL) { + if (global.window.mm_config.RestrictPrivateChannelCreation === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { + return false; + } else if (global.window.mm_config.RestrictPrivateChannelCreation === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + return false; + } + } + + return true; +} + +export function showManagementOptions(channel, isAdmin, isSystemAdmin) { + if (global.window.mm_license.IsLicensed !== 'true') { + return true; + } + + if (channel.type === Constants.OPEN_CHANNEL) { + if (global.window.mm_config.RestrictPublicChannelManagement === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { + return false; + } + if (global.window.mm_config.RestrictPublicChannelManagement === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + return false; + } + } else if (channel.type === Constants.PRIVATE_CHANNEL) { + if (global.window.mm_config.RestrictPrivateChannelManagement === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { + return false; + } + if (global.window.mm_config.RestrictPrivateChannelManagement === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + return false; + } + } + + return true; +} + +export function showDeleteOption(channel, isAdmin, isSystemAdmin) { + if (global.window.mm_license.IsLicensed !== 'true') { + return true; + } + + if (channel.type === Constants.OPEN_CHANNEL) { + if (global.window.mm_config.RestrictPublicChannelDeletion === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { + return false; + } + if (global.window.mm_config.RestrictPublicChannelDeletion === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + return false; + } + } else if (channel.type === Constants.PRIVATE_CHANNEL) { + if (global.window.mm_config.RestrictPrivateChannelDeletion === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { + return false; + } + if (global.window.mm_config.RestrictPrivateChannelDeletion === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + return false; + } + } + + return true; +} + /* * not exported helpers */ |