Skip to content

Commit

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

* Get Ancillary Permissions in FrontEnd

* fix typo

* fix linting

* Update packages/mattermost-redux/src/client/client4.ts

Co-authored-by: Mattermod <[email protected]>
  • Loading branch information
hahmadia and mattermod committed Apr 21, 2021
1 parent 37ead00 commit 21991f2
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 @@ -3702,6 +3706,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 21991f2

Please sign in to comment.