diff --git a/lib/utils/role-utils.js b/lib/utils/role-utils.js --- a/lib/utils/role-utils.js +++ b/lib/utils/role-utils.js @@ -38,26 +38,6 @@ return message; } -type RoleDeletableAndEditableStatus = { - +isDeletable: boolean, - +isEditable: boolean, -}; -function useRoleDeletableAndEditableStatus( - roleName: string, - defaultRoleID: string, - existingRoleID: string, -): RoleDeletableAndEditableStatus { - return React.useMemo(() => { - const canDelete = roleName !== 'Admins' && defaultRoleID !== existingRoleID; - const canEdit = roleName !== 'Admins'; - - return { - isDeletable: canDelete, - isEditable: canEdit, - }; - }, [roleName, defaultRoleID, existingRoleID]); -} - function useRolesFromCommunityThreadInfo( threadInfo: ThreadInfo, memberInfos: $ReadOnlyArray, @@ -154,7 +134,6 @@ export { constructRoleDeletionMessagePrompt, - useRoleDeletableAndEditableStatus, useRolesFromCommunityThreadInfo, toggleUserSurfacedPermission, useMembersGroupedByRole, diff --git a/web/roles/role-actions-menu.react.js b/web/roles/role-actions-menu.react.js --- a/web/roles/role-actions-menu.react.js +++ b/web/roles/role-actions-menu.react.js @@ -6,6 +6,7 @@ import { useModalContext } from 'lib/components/modal-provider.react.js'; import SWMansionIcon from 'lib/components/swmansion-icon.react.js'; import { + roleIsAdminRole, roleIsDefaultRole, useRoleUserSurfacedPermissions, } from 'lib/shared/thread-utils.js'; @@ -14,7 +15,6 @@ ThreadInfo, } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { values } from 'lib/utils/objects.js'; -import { useRoleDeletableAndEditableStatus } from 'lib/utils/role-utils.js'; import CreateRolesModal from './create-roles-modal.react.js'; import DeleteRoleModal from './delete-role-modal.react.js'; @@ -43,12 +43,6 @@ ); invariant(existingRole, 'existing role should exist'); - const roleOptions = useRoleDeletableAndEditableStatus( - roleName, - defaultRoleID, - existingRole.id, - ); - const roleNamesToUserSurfacedPermissions = useRoleUserSurfacedPermissions(threadInfo); @@ -83,9 +77,8 @@ const menuItems = React.useMemo(() => { const availableOptions = []; - const { isDeletable, isEditable } = roleOptions; - if (isEditable) { + if (!roleIsAdminRole(existingRole)) { availableOptions.push(