diff --git a/web/roles/create-roles-modal.react.js b/web/roles/create-roles-modal.react.js --- a/web/roles/create-roles-modal.react.js +++ b/web/roles/create-roles-modal.react.js @@ -69,6 +69,8 @@ const [roleCreationFailed, setRoleCreationFailed] = React.useState(); + const createButtonText = action === 'create_role' ? 'Create' : 'Save'; + const onChangeRoleName = React.useCallback( (event: SyntheticEvent) => { setRoleCreationFailed(null); @@ -241,8 +243,8 @@ ); } - return 'Save'; - }, [createRolesLoadingStatus]); + return createButtonText; + }, [createRolesLoadingStatus, createButtonText]); return ( 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 @@ -3,10 +3,13 @@ import invariant from 'invariant'; import * as React from 'react'; +import { useModalContext } from 'lib/components/modal-provider.react.js'; import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; +import { useRoleUserSurfacedPermissions } from 'lib/shared/thread-utils.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useRoleDeletableAndEditableStatus } from 'lib/utils/role-utils.js'; +import CreateRolesModal from './create-roles-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'; @@ -20,6 +23,7 @@ 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, @@ -37,8 +41,28 @@ existingRoleID, ); - // TODO: Implement in following diffs - const openEditRoleModal = React.useCallback(() => {}, []); + const roleNamesToUserSurfacedPermissions = + useRoleUserSurfacedPermissions(threadInfo); + + const openEditRoleModal = React.useCallback( + () => + pushModal( + , + ), + [ + existingRoleID, + pushModal, + roleName, + roleNamesToUserSurfacedPermissions, + threadInfo, + ], + ); const openDeleteRoleModal = React.useCallback(() => {}, []); const menuItems = React.useMemo(() => {