summaryrefslogtreecommitdiffstats
path: root/webapp/utils/channel_utils.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/utils/channel_utils.jsx')
-rw-r--r--webapp/utils/channel_utils.jsx70
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
*/