summaryrefslogtreecommitdiffstats
path: root/webapp/utils
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-02-24 01:15:10 +0000
committerChristopher Speller <crspeller@gmail.com>2017-02-23 20:15:10 -0500
commit8509c2f0b0893f8a7936a1943cc924db09bb62f4 (patch)
tree9b52c232fbc96fadaec26f0694ffc7e764651757 /webapp/utils
parentbc9f3dfa240b2a197859de006baf2eceaafe0fcf (diff)
downloadchat-8509c2f0b0893f8a7936a1943cc924db09bb62f4.tar.gz
chat-8509c2f0b0893f8a7936a1943cc924db09bb62f4.tar.bz2
chat-8509c2f0b0893f8a7936a1943cc924db09bb62f4.zip
PLT-5080 (WebApp): Channel Admin permission level. (#5047)
* PLT-5080 (WebApp): Channel Admin permission level. For channel management and channel deletion. * Fix some incorrect showing/hiding of options. * Remove incorrect client calls that was overwriting my channel members.
Diffstat (limited to 'webapp/utils')
-rw-r--r--webapp/utils/channel_utils.jsx16
-rw-r--r--webapp/utils/constants.jsx1
2 files changed, 15 insertions, 2 deletions
diff --git a/webapp/utils/channel_utils.jsx b/webapp/utils/channel_utils.jsx
index 67dcfac67..22c428cb8 100644
--- a/webapp/utils/channel_utils.jsx
+++ b/webapp/utils/channel_utils.jsx
@@ -126,7 +126,7 @@ export function showCreateOption(channelType, isAdmin, isSystemAdmin) {
return true;
}
-export function showManagementOptions(channel, isAdmin, isSystemAdmin) {
+export function showManagementOptions(channel, isAdmin, isSystemAdmin, isChannelAdmin) {
if (global.window.mm_license.IsLicensed !== 'true') {
return true;
}
@@ -138,6 +138,9 @@ export function showManagementOptions(channel, isAdmin, isSystemAdmin) {
if (global.window.mm_config.RestrictPublicChannelManagement === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) {
return false;
}
+ if (global.window.mm_config.RestrictPublicChannelManagement === Constants.PERMISSIONS_CHANNEL_ADMIN && !isChannelAdmin && !isAdmin) {
+ return false;
+ }
} else if (channel.type === Constants.PRIVATE_CHANNEL) {
if (global.window.mm_config.RestrictPrivateChannelManagement === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) {
return false;
@@ -145,12 +148,15 @@ export function showManagementOptions(channel, isAdmin, isSystemAdmin) {
if (global.window.mm_config.RestrictPrivateChannelManagement === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) {
return false;
}
+ if (global.window.mm_config.RestrictPrivateChannelManagement === Constants.PERMISSIONS_CHANNEL_ADMIN && !isChannelAdmin && !isAdmin) {
+ return false;
+ }
}
return true;
}
-export function showDeleteOption(channel, isAdmin, isSystemAdmin) {
+export function showDeleteOption(channel, isAdmin, isSystemAdmin, isChannelAdmin) {
if (global.window.mm_license.IsLicensed !== 'true') {
return true;
}
@@ -162,6 +168,9 @@ export function showDeleteOption(channel, isAdmin, isSystemAdmin) {
if (global.window.mm_config.RestrictPublicChannelDeletion === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) {
return false;
}
+ if (global.window.mm_config.RestrictPublicChannelDeletion === Constants.PERMISSIONS_CHANNEL_ADMIN && !isChannelAdmin && !isAdmin) {
+ return false;
+ }
} else if (channel.type === Constants.PRIVATE_CHANNEL) {
if (global.window.mm_config.RestrictPrivateChannelDeletion === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) {
return false;
@@ -169,6 +178,9 @@ export function showDeleteOption(channel, isAdmin, isSystemAdmin) {
if (global.window.mm_config.RestrictPrivateChannelDeletion === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) {
return false;
}
+ if (global.window.mm_config.RestrictPrivateChannelDeletion === Constants.PERMISSIONS_CHANNEL_ADMIN && !isChannelAdmin && !isAdmin) {
+ return false;
+ }
}
return true;
diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index 6ad4a9e92..ff26a0c7f 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -877,6 +877,7 @@ export const Constants = {
LICENSE_EXPIRY_NOTIFICATION: 1000 * 60 * 60 * 24 * 15, // 15 days
LICENSE_GRACE_PERIOD: 1000 * 60 * 60 * 24 * 15, // 15 days
PERMISSIONS_ALL: 'all',
+ PERMISSIONS_CHANNEL_ADMIN: 'channel_admin',
PERMISSIONS_TEAM_ADMIN: 'team_admin',
PERMISSIONS_SYSTEM_ADMIN: 'system_admin',
PERMISSIONS_DELETE_POST_ALL: 'all',