Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
[MM-34838] Remove Ancillary Permissions That Are Purposefully Being R…
Browse files Browse the repository at this point in the history
…emove (#7959) (#7973)

Automatic Merge
  • Loading branch information
mattermost-build committed Apr 22, 2021
1 parent 1db70e6 commit b4d8d25
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -124,9 +125,11 @@ export default class SystemRole extends React.PureComponent<Props, State> {

// 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)) {
Expand Down
11 changes: 11 additions & 0 deletions packages/mattermost-redux/src/client/client4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand Down Expand Up @@ -3710,6 +3714,13 @@ export default class Client4 {
);
}

getAncillaryPermissions = (subsectionPermissions: string[]) => {
return this.doFetch<string[]>(
`${this.getPermissionsRoute()}/ancillary?subsection_permissions=${subsectionPermissions.join(',')}`,
{method: 'get'},
);
}

// Client Helpers

doFetch = async <T>(url: string, options: Options): Promise<T> => {
Expand Down

0 comments on commit b4d8d25

Please sign in to comment.