PLT-4990 (WebApp): Separate channel management permissions. (#4865)
Этот коммит содержится в:
коммит произвёл
enahum
родитель
267257b680
Коммит
e3b8511462
@@ -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
|
||||
*/
|
||||
|
||||
Ссылка в новой задаче
Block a user