Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3486385
D3380.id10866.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
D3380.id10866.diff
View Options
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
@@ -1,17 +1,28 @@
// @flow
+import {
+ faPlusCircle,
+ faMinusCircle,
+ faSignOutAlt,
+} from '@fortawesome/free-solid-svg-icons';
import classNames from 'classnames';
import * as React from 'react';
-import { memberIsAdmin, memberHasAdminPowers } from 'lib/shared/thread-utils';
+import {
+ memberIsAdmin,
+ memberHasAdminPowers,
+ threadHasPermission,
+} from 'lib/shared/thread-utils';
import { stringForUser } from 'lib/shared/user-utils';
import type { SetState } from 'lib/types/hook-types';
import {
type RelativeMemberInfo,
type ThreadInfo,
+ threadPermissions,
} from 'lib/types/thread-types';
import Label from '../../../components/label.react';
+import MenuItem from '../../../components/menu-item.react';
import Menu from '../../../components/menu.react';
import SWMansionIcon from '../../../SWMansionIcon.react';
import css from './members-modal.css';
@@ -38,7 +49,55 @@
[memberInfo.id, setOpenMenu],
);
- const menuItems = [];
+ const menuItems = React.useMemo(() => {
+ const { role } = memberInfo;
+ if (!role) {
+ return [];
+ }
+
+ const canRemoveMembers = threadHasPermission(
+ threadInfo,
+ threadPermissions.REMOVE_MEMBERS,
+ );
+ const canChangeRoles = threadHasPermission(
+ threadInfo,
+ threadPermissions.CHANGE_ROLE,
+ );
+
+ const actions = [];
+
+ const isAdmin = memberIsAdmin(memberInfo, threadInfo);
+ if (canChangeRoles && memberInfo.username && isAdmin) {
+ actions.push(
+ <MenuItem
+ key="remove_admin"
+ text="Remove admin"
+ icon={faMinusCircle}
+ />,
+ );
+ } else if (canChangeRoles && memberInfo.username) {
+ actions.push(
+ <MenuItem key="make_admin" text="Make admin" icon={faPlusCircle} />,
+ );
+ }
+
+ if (
+ canRemoveMembers &&
+ !memberInfo.isViewer &&
+ (canChangeRoles || threadInfo.roles[role]?.isDefault)
+ ) {
+ actions.push(
+ <MenuItem
+ key="remove_user"
+ text="Remove user"
+ icon={faSignOutAlt}
+ dangerous
+ />,
+ );
+ }
+
+ return actions;
+ }, [memberInfo, threadInfo]);
const userSettingsIcon = React.useMemo(
() => <SWMansionIcon icon="edit" size={17} />,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 4:45 AM (21 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675330
Default Alt Text
D3380.id10866.diff (2 KB)
Attached To
Mode
D3380: [web] Introduce member action menu items in `ThreadMember` component
Attached
Detach File
Event Timeline
Log In to Comment