Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3243776
D8624.id29343.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D8624.id29343.diff
View Options
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<?RoleCreationErrorVariant>();
+ const createButtonText = action === 'create_role' ? 'Create' : 'Save';
+
const onChangeRoleName = React.useCallback(
(event: SyntheticEvent<HTMLInputElement>) => {
setRoleCreationFailed(null);
@@ -241,8 +243,8 @@
);
}
- return 'Save';
- }, [createRolesLoadingStatus]);
+ return createButtonText;
+ }, [createRolesLoadingStatus, createButtonText]);
return (
<Modal name="Create Role" onClose={onCloseModal} size="large">
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(
+ <CreateRolesModal
+ threadInfo={threadInfo}
+ action="edit_role"
+ existingRoleID={existingRoleID}
+ roleName={roleName}
+ rolePermissions={roleNamesToUserSurfacedPermissions[roleName]}
+ />,
+ ),
+ [
+ existingRoleID,
+ pushModal,
+ roleName,
+ roleNamesToUserSurfacedPermissions,
+ threadInfo,
+ ],
+ );
const openDeleteRoleModal = React.useCallback(() => {}, []);
const menuItems = React.useMemo(() => {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 9:13 AM (17 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2493946
Default Alt Text
D8624.id29343.diff (2 KB)
Attached To
Mode
D8624: [web] Push the create role modal with prepopulated fields when Edit Role is clicked
Attached
Detach File
Event Timeline
Log In to Comment