diff --git a/lib/types/thread-permission-types.js b/lib/types/thread-permission-types.js --- a/lib/types/thread-permission-types.js +++ b/lib/types/thread-permission-types.js @@ -84,6 +84,178 @@ export type ThreadPermissionFilterPrefix = $Values< typeof threadPermissionFilterPrefixes, >; + +type ConfigurableCommunityPermission = { + // Type the permissions as `string`, as opposed to `ThreadPermission`, + // because we open up the permissions to include an optional prefix + // (i.e. `descendant_`) to propagate certain permissions down the community. + +permissions: $ReadOnlyArray, + +title: string, + +description: string, +}; +export const configurableCommunityPermissions: $ReadOnlyArray = + [ + { + permissions: [ + threadPermissions.EDIT_ENTRIES, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.EDIT_ENTRIES, + ], + title: 'Edit calendar', + description: 'Allows members to edit the community calendar', + }, + { + permissions: [ + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.KNOW_OF, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.VISIBLE, + ], + title: 'See secret channels', + description: 'Allows members to see all secret channels', + }, + { + permissions: [threadPermissions.VOICED], + title: 'Speak in announcement channels', + description: 'Allows members to speak in announcement channels', + }, + { + permissions: [ + threadPermissions.EDIT_THREAD_NAME, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.EDIT_THREAD_NAME, + + threadPermissions.EDIT_THREAD_DESCRIPTION, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.EDIT_THREAD_DESCRIPTION, + + threadPermissions.EDIT_THREAD_COLOR, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.EDIT_THREAD_COLOR, + + threadPermissions.CREATE_SUBCHANNELS, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissionFilterPrefixes.TOP_LEVEL + + threadPermissions.CREATE_SUBCHANNELS, + + threadPermissions.EDIT_THREAD_AVATAR, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.EDIT_THREAD_AVATAR, + ], + title: 'Create and edit channels', + description: 'Allows members to create new and edit existing channels', + }, + { + permissions: [ + threadPermissions.DELETE_THREAD, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.DELETE_THREAD, + ], + title: 'Delete channels', + description: 'Allows members to delete channels', + }, + { + permissions: [ + threadPermissions.ADD_MEMBERS, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.ADD_MEMBERS, + ], + title: 'Add members', + description: 'Allows members to add other members to channels', + }, + { + permissions: [ + threadPermissions.REMOVE_MEMBERS, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.REMOVE_MEMBERS, + ], + title: 'Remove members', + description: 'Allows members to remove other members from channels', + }, + { + permissions: [ + threadPermissions.CHANGE_ROLE, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.CHANGE_ROLE, + ], + title: 'Change roles', + description: 'Allows members to change the roles of other members', + }, + { + permissions: [ + threadPermissions.EDIT_PERMISSIONS, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.EDIT_PERMISSIONS, + ], + title: 'Edit permissions', + description: 'Allows members to edit visibility permissions of channels', + }, + { + permissions: [ + threadPermissions.MANAGE_PINS, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.MANAGE_PINS, + ], + title: 'Manage pins', + description: 'Allows members to pin or unpin messages in channels', + }, + { + permissions: [ + threadPermissions.REACT_TO_MESSAGE, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.MANAGE_PINS, + ], + title: 'React to messages', + description: 'Allows members to add reactions to messages', + }, + { + permissions: [ + threadPermissions.EDIT_MESSAGE, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.EDIT_ENTRIES, + ], + title: 'Edit messages', + description: 'Allows members to edit their sent messages', + }, + { + permissions: [ + threadPermissions.MANAGE_INVITE_LINKS, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissions.MANAGE_INVITE_LINKS, + ], + title: 'Manage invite links', + description: 'Allows members to handle invite links for the community', + }, + ]; +export const guarenteedCommunityPermissions: $ReadOnlyArray = [ + // know_of | descendant_open_know_of + threadPermissions.KNOW_OF, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissionFilterPrefixes.OPEN + + threadPermissions.KNOW_OF, + + // voiced + threadPermissionPropagationPrefixes.DESCENDANT + threadPermissions.VOICED, + + // visible | descendant_open_visible + threadPermissions.VISIBLE, + threadPermissionPropagationPrefixes.DESCENDANT + + threadPermissionFilterPrefixes.OPEN + + threadPermissions.VISIBLE, + + // join_thread | child_open_join_thread | descendant_opentoplevel_join_thread + threadPermissions.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 };