Skip to content

Commit

Permalink
[lib] Delete the old universalCommunityPermissions set
Browse files Browse the repository at this point in the history
Summary:
Now that I'm ready to land the stack for fixing thread permissions, I can safely remove the old `universalCommunityPermissions` set since we now have a function that takes in a thread type and returns back a blob of universal community permissions accordingly.

Also took this time to quickly remove the unit tests that had previously hard-coded user-surfaced permissions for two reasons:
- we now have a list defined in `thread-permissions`
- we just do not need this unit test because now, since constructing member blobs for communities uses user-surfaced permissions, this unit test doesn't test anything of importance

Depends on D9945

Test Plan: Ran `yarn workspace lib test` and `flow` to make sure I covered all instances of the old `universalCommunityPermissions`

Reviewers: atul, ginsu, ashoat

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D9953
  • Loading branch information
RohanK6 committed Nov 22, 2023
1 parent ddaed89 commit e80647b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 78 deletions.
25 changes: 0 additions & 25 deletions lib/types/thread-permission-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,31 +310,6 @@ export const configurableCommunityPermissions: ConfigurableCommunityPermission =
[userSurfacedPermissions.MANAGE_INVITE_LINKS]: manageInviteLinksPermissions,
});

export const universalCommunityPermissions: $ReadOnlyArray<string> = [
// know_of | descendant_open_know_of
threadPermissions.KNOW_OF,
threadPermissionPropagationPrefixes.DESCENDANT +
threadPermissionFilterPrefixes.OPEN +
threadPermissions.KNOW_OF,

// visible | descendant_open_visible
threadPermissions.VISIBLE,
threadPermissionPropagationPrefixes.DESCENDANT +
threadPermissionFilterPrefixes.OPEN +
threadPermissions.VISIBLE,

// child_open_join_thread | descendant_opentoplevel_join_thread
threadPermissionPropagationPrefixes.CHILD +
threadPermissionFilterPrefixes.OPEN +
threadPermissions.JOIN_THREAD,
threadPermissionPropagationPrefixes.DESCENDANT +
threadPermissionFilterPrefixes.OPEN_TOP_LEVEL +
threadPermissions.JOIN_THREAD,

threadPermissions.CREATE_SIDEBARS,
threadPermissions.LEAVE_THREAD,
];

export type ThreadPermissionInfo =
| { +value: true, +source: string }
| { +value: false, +source: null };
Expand Down
54 changes: 1 addition & 53 deletions lib/types/thread-permission-types.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import _isEqual from 'lodash/fp/isEqual.js';

import {
configurableCommunityPermissions,
universalCommunityPermissions,
userSurfacedPermissions,
threadPermissions,
} from './thread-permission-types.js';
import { userSurfacedPermissions } from './thread-permission-types.js';
import { getRolePermissionBlobs } from '../permissions/thread-permissions.js';
import { threadTypes } from '../types/thread-types-enum.js';
import { values } from '../utils/objects.js';
Expand All @@ -18,26 +13,6 @@ describe('Community Announcement Root', () => {
threadTypes.COMMUNITY_ANNOUNCEMENT_ROOT,
);

it('should find Member permissions from getRolePermissionBlobs and user-surfaced permissions to be equal', () => {
const membersPermissionsConstructed = [
...configurableCommunityPermissions[userSurfacedPermissions.ADD_MEMBERS],
...configurableCommunityPermissions[
userSurfacedPermissions.REACT_TO_MESSAGES
],
...configurableCommunityPermissions[
userSurfacedPermissions.EDIT_MESSAGES
],
...universalCommunityPermissions,
];
const membersPermissionsConstructedBlob = Object.fromEntries(
membersPermissionsConstructed.map(permission => [permission, true]),
);

expect(
_isEqual(membersPermissionBlob, membersPermissionsConstructedBlob),
).toBe(true);
});

it('should find equal permission blobs when toggling user-surfaced permissions', () => {
for (const userSurfacedPermission of values(userSurfacedPermissions)) {
const firstTimeToggledPermissionSet = toggleUserSurfacedPermission(
Expand All @@ -61,33 +36,6 @@ describe('Community Root', () => {
threadTypes.COMMUNITY_ROOT,
);

it('should find Member permissions from getRolePermissionBlobs and user-surfaced permissions to be equal', () => {
const membersPermissionsConstructed = [
...configurableCommunityPermissions[userSurfacedPermissions.ADD_MEMBERS],
...configurableCommunityPermissions[
userSurfacedPermissions.REACT_TO_MESSAGES
],
...configurableCommunityPermissions[
userSurfacedPermissions.EDIT_MESSAGES
],
...configurableCommunityPermissions[
userSurfacedPermissions.CREATE_AND_EDIT_CHANNELS
],
...configurableCommunityPermissions[
userSurfacedPermissions.EDIT_CALENDAR
],
threadPermissions.VOICED,
...universalCommunityPermissions,
];
const membersPermissionsConstructedBlob = Object.fromEntries(
membersPermissionsConstructed.map(permission => [permission, true]),
);

expect(
_isEqual(membersPermissionBlob, membersPermissionsConstructedBlob),
).toBe(true);
});

it('should find equal permission blobs when toggling user-surfaced permissions', () => {
for (const userSurfacedPermission of values(userSurfacedPermissions)) {
const firstTimeToggledPermissionSet = toggleUserSurfacedPermission(
Expand Down

0 comments on commit e80647b

Please sign in to comment.