diff --git a/web/roles/role-actions-menu.react.js b/web/roles/role-actions-menu.react.js
index 7b7d17f8f..ddca38da9 100644
--- a/web/roles/role-actions-menu.react.js
+++ b/web/roles/role-actions-menu.react.js
@@ -1,117 +1,120 @@
// @flow
import invariant from 'invariant';
import * as React from 'react';
import { useModalContext } from 'lib/components/modal-provider.react.js';
import SWMansionIcon from 'lib/components/swmansion-icon.react.js';
-import { useRoleUserSurfacedPermissions } from 'lib/shared/thread-utils.js';
+import {
+ roleIsDefaultRole,
+ useRoleUserSurfacedPermissions,
+} from 'lib/shared/thread-utils.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.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';
import css from './role-actions-menu.css';
import MenuItem from '../components/menu-item.react.js';
import Menu from '../components/menu.react.js';
const menuIcon = ;
type RoleActionsMenuProps = {
+threadInfo: ThreadInfo,
+roleName: string,
};
function RoleActionsMenu(props: RoleActionsMenuProps): React.Node {
const { threadInfo, roleName } = props;
const { pushModal } = useModalContext();
- const defaultRoleID = Object.keys(threadInfo.roles).find(
- roleID => threadInfo.roles[roleID].isDefault,
+ const defaultRoleID = Object.keys(threadInfo.roles).find(roleID =>
+ roleIsDefaultRole(threadInfo.roles[roleID]),
);
invariant(defaultRoleID, 'default role should exist');
const existingRoleID = Object.keys(threadInfo.roles).find(
roleID => threadInfo.roles[roleID].name === roleName,
);
invariant(existingRoleID, 'existing role should exist');
const roleOptions = useRoleDeletableAndEditableStatus(
roleName,
defaultRoleID,
existingRoleID,
);
const roleNamesToUserSurfacedPermissions =
useRoleUserSurfacedPermissions(threadInfo);
const openEditRoleModal = React.useCallback(
() =>
pushModal(
,
),
[
existingRoleID,
pushModal,
roleName,
roleNamesToUserSurfacedPermissions,
threadInfo,
],
);
const openDeleteRoleModal = React.useCallback(() => {
pushModal(
,
);
}, [existingRoleID, pushModal, threadInfo, defaultRoleID]);
const menuItems = React.useMemo(() => {
const availableOptions = [];
const { isDeletable, isEditable } = roleOptions;
if (isEditable) {
availableOptions.push(
,
);
}
if (isDeletable) {
availableOptions.push(
,
);
}
return availableOptions;
}, [roleOptions, openDeleteRoleModal, openEditRoleModal]);
return (
);
}
export default RoleActionsMenu;