From fd6856b674cc24deb708f2cd36c247662ee10bc7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 9 Aug 2017 09:34:09 -0400 Subject: PLT-7206: Remove the "Delete Channel" option for private channels if you're the last channel member and policy setting restricts channel deletion (#7050) * PLT-7206: UI changes. Removed last user in channel loophole, refactored code to clean it up, added differentiated support for public and private channels, added unit tests. Still need to implement server-side checks * PLT-7206: All helper methods in channel_utils.jsx now accept the same three boolean variables in the same order and use the same boolean logic to check their values. * PLT-7206: Added unit tests for showManagementOptions(...) * PLT-7206: Fixed test case descriptions * Added unit tests for showCreateOption(...) * PLT-7206: Added unit tests for canManageMembers(...) * PLT-7206: Removed last person in channel loophole from server-side code * PLT-7206: Reverted config.json * PLT-7206: Fixed double negatives in unit test names * PLT-7206: PR feedback - Removed confusing comment and unused variable --- webapp/utils/channel_intro_messages.jsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'webapp/utils/channel_intro_messages.jsx') diff --git a/webapp/utils/channel_intro_messages.jsx b/webapp/utils/channel_intro_messages.jsx index baf6c4fb1..f85b0cf87 100644 --- a/webapp/utils/channel_intro_messages.jsx +++ b/webapp/utils/channel_intro_messages.jsx @@ -160,12 +160,12 @@ export function createOffTopicIntroMessage(channel, centeredIntro) { /> ); - const isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); - const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); const isChannelAdmin = ChannelStore.isChannelAdminForCurrentChannel(); + const isTeamAdmin = TeamStore.isTeamAdminForCurrentTeam(); + const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); let setHeaderButton = createSetHeaderButton(channel); - if (!showManagementOptions(channel, isAdmin, isSystemAdmin, isChannelAdmin)) { + if (!showManagementOptions(channel, isChannelAdmin, isTeamAdmin, isSystemAdmin)) { setHeaderButton = null; } @@ -199,20 +199,20 @@ export function createDefaultIntroMessage(channel, centeredIntro) { ); - const isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); - const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); const isChannelAdmin = ChannelStore.isChannelAdminForCurrentChannel(); + const isTeamAdmin = TeamStore.isTeamAdminForCurrentTeam(); + const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); if (global.window.mm_license.IsLicensed === 'true') { if (global.window.mm_config.RestrictTeamInvite === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { inviteModalLink = null; - } else if (global.window.mm_config.RestrictTeamInvite === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { + } else if (global.window.mm_config.RestrictTeamInvite === Constants.PERMISSIONS_TEAM_ADMIN && !(isTeamAdmin || isSystemAdmin)) { inviteModalLink = null; } } let setHeaderButton = createSetHeaderButton(channel); - if (!showManagementOptions(channel, isAdmin, isSystemAdmin, isChannelAdmin)) { + if (!showManagementOptions(channel, isChannelAdmin, isTeamAdmin, isSystemAdmin)) { setHeaderButton = null; } @@ -321,12 +321,12 @@ export function createStandardIntroMessage(channel, centeredIntro) { ); } - const isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); - const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); const isChannelAdmin = ChannelStore.isChannelAdminForCurrentChannel(); + const isTeamAdmin = TeamStore.isTeamAdminForCurrentTeam(); + const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); let setHeaderButton = createSetHeaderButton(channel); - if (!showManagementOptions(channel, isAdmin, isSystemAdmin, isChannelAdmin)) { + if (!showManagementOptions(channel, isChannelAdmin, isTeamAdmin, isSystemAdmin)) { setHeaderButton = null; } -- cgit v1.2.3-1-g7c22