From 21991f233821fd361f02fc2b2fac5cff1e613b84 Mon Sep 17 00:00:00 2001 From: Hossein Date: Wed, 21 Apr 2021 11:36:02 -0400 Subject: [PATCH] [MM-34838] Remove Ancillary Permissions That Are Purposefully Being Remove (#7959) * Get Ancillary Permissions in FrontEnd * fix typo * fix linting * Update packages/mattermost-redux/src/client/client4.ts Co-authored-by: Mattermod --- .../system_roles/system_role/system_role.tsx | 5 ++++- packages/mattermost-redux/src/client/client4.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/admin_console/system_roles/system_role/system_role.tsx b/components/admin_console/system_roles/system_role/system_role.tsx index 9a4629833d59..1d6a9945e256 100644 --- a/components/admin_console/system_roles/system_role/system_role.tsx +++ b/components/admin_console/system_roles/system_role/system_role.tsx @@ -6,6 +6,7 @@ import {FormattedMessage} from 'react-intl'; import {uniq, difference} from 'lodash'; import {Role} from 'mattermost-redux/types/roles'; +import {Client4} from 'mattermost-redux/client'; import {UserProfile} from 'mattermost-redux/types/users'; import {Dictionary} from 'mattermost-redux/types/utilities'; @@ -124,9 +125,11 @@ export default class SystemRole extends React.PureComponent { // Do not update permissions if sysadmin or if roles have not been updated (to prevent overrwiting roles with no permissions) if (role.name !== Constants.PERMISSIONS_SYSTEM_ADMIN && Object.keys(permissionsToUpdate).length > 0) { + const rolePermissionsWithAncillaryPermssions = await Client4.getAncillaryPermissions(updatedRolePermissions); + const newRole: Role = { ...role, - permissions: updatedRolePermissions, + permissions: rolePermissionsWithAncillaryPermssions, }; const result = await editRole(newRole); if (isError(result)) { diff --git a/packages/mattermost-redux/src/client/client4.ts b/packages/mattermost-redux/src/client/client4.ts index e819e61323f7..4c6d468e6af7 100644 --- a/packages/mattermost-redux/src/client/client4.ts +++ b/packages/mattermost-redux/src/client/client4.ts @@ -422,6 +422,10 @@ export default class Client4 { return `${this.getBaseRoute()}/cloud`; } + getPermissionsRoute() { + return `${this.getBaseRoute()}/permissions`; + } + getUserThreadsRoute(userID: string, teamID: string): string { return `${this.getUserRoute(userID)}/teams/${teamID}/threads`; } @@ -3702,6 +3706,13 @@ export default class Client4 { ); } + getAncillaryPermissions = (subsectionPermissions: string[]) => { + return this.doFetch( + `${this.getPermissionsRoute()}/ancillary?subsection_permissions=${subsectionPermissions.join(',')}`, + {method: 'get'}, + ); + } + // Client Helpers doFetch = async (url: string, options: Options): Promise => {