Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3370371
D8135.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D8135.diff
View Options
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -1517,7 +1517,7 @@
memberInfo: RelativeMemberInfo,
threadInfo: ThreadInfo,
canEdit: ?boolean = true,
-): $ReadOnlyArray<'remove_user' | 'remove_admin' | 'make_admin'> {
+): $ReadOnlyArray<'change_role' | 'remove_user'> {
const role = memberInfo.role;
if (!canEdit || !role) {
return [];
@@ -1533,6 +1533,11 @@
);
const result = [];
+
+ if (canChangeRoles && memberInfo.username && threadHasAdminRole(threadInfo)) {
+ result.push('change_role');
+ }
+
if (
canRemoveMembers &&
!memberInfo.isViewer &&
@@ -1541,12 +1546,6 @@
result.push('remove_user');
}
- if (canChangeRoles && memberInfo.username && threadHasAdminRole(threadInfo)) {
- result.push(
- memberIsAdmin(memberInfo, threadInfo) ? 'remove_admin' : 'make_admin',
- );
- }
-
return result;
}
diff --git a/web/modals/threads/members/member.react.js b/web/modals/threads/members/member.react.js
--- a/web/modals/threads/members/member.react.js
+++ b/web/modals/threads/members/member.react.js
@@ -3,15 +3,10 @@
import classNames from 'classnames';
import * as React from 'react';
-import {
- removeUsersFromThread,
- changeThreadMemberRoles,
-} from 'lib/actions/thread-actions.js';
+import { removeUsersFromThread } from 'lib/actions/thread-actions.js';
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import {
- memberIsAdmin,
removeMemberFromThread,
- switchMemberAdminRoleInThread,
getAvailableThreadMemberActions,
} from 'lib/shared/thread-utils.js';
import { stringForUser } from 'lib/shared/user-utils.js';
@@ -69,47 +64,18 @@
[boundRemoveUsersFromThread, dispatchActionPromise, memberInfo, threadInfo],
);
- const isCurrentlyAdmin = memberIsAdmin(memberInfo, threadInfo);
- const boundChangeThreadMemberRoles = useServerCall(changeThreadMemberRoles);
-
- const onMemberAdminRoleToggled = React.useCallback(
- () =>
- switchMemberAdminRoleInThread(
- threadInfo,
- memberInfo,
- isCurrentlyAdmin,
- dispatchActionPromise,
- boundChangeThreadMemberRoles,
- ),
- [
- boundChangeThreadMemberRoles,
- dispatchActionPromise,
- isCurrentlyAdmin,
- memberInfo,
- threadInfo,
- ],
- );
+ const onClickChangeRole = React.useCallback(() => {}, []);
const menuItems = React.useMemo(
() =>
getAvailableThreadMemberActions(memberInfo, threadInfo).map(action => {
- if (action === 'remove_admin') {
- return (
- <MenuItem
- key="remove_admin"
- text="Remove admin"
- icon="cross-circle"
- onClick={onMemberAdminRoleToggled}
- />
- );
- }
- if (action === 'make_admin') {
+ if (action === 'change_role') {
return (
<MenuItem
- key="make_admin"
- text="Make admin"
+ key="change_role"
+ text="Change Role"
icon="plus-circle"
- onClick={onMemberAdminRoleToggled}
+ onClick={onClickChangeRole}
/>
);
}
@@ -117,7 +83,7 @@
return (
<MenuItem
key="remove_user"
- text="Remove user"
+ text="Remove User"
icon="logout"
onClick={onClickRemoveUser}
dangerous
@@ -126,7 +92,7 @@
}
return null;
}),
- [memberInfo, onClickRemoveUser, onMemberAdminRoleToggled, threadInfo],
+ [memberInfo, onClickRemoveUser, onClickChangeRole, threadInfo],
);
const userSettingsIcon = React.useMemo(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 2:19 AM (14 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587352
Default Alt Text
D8135.diff (3 KB)
Attached To
Mode
D8135: [web] Show option to change role from the members modal
Attached
Detach File
Event Timeline
Log In to Comment