Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3272404
D3192.id9796.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
D3192.id9796.diff
View Options
diff --git a/web/chat/thread-menu.css b/web/chat/thread-menu.css
--- a/web/chat/thread-menu.css
+++ b/web/chat/thread-menu.css
@@ -49,3 +49,9 @@
button.topBarMenuActionDangerous:hover {
color: var(--thread-menu-color-dangerous-hover);
}
+
+hr.separator {
+ border: 1px solid var(--thread-menu-separator-color);
+ margin: 10px 16px;
+ max-width: 130px;
+}
diff --git a/web/chat/thread-menu.react.js b/web/chat/thread-menu.react.js
--- a/web/chat/thread-menu.react.js
+++ b/web/chat/thread-menu.react.js
@@ -5,13 +5,14 @@
faBell,
faCog,
faCommentAlt,
+ faSignOutAlt,
faPlusCircle,
faUserFriends,
} from '@fortawesome/free-solid-svg-icons';
import * as React from 'react';
import { childThreadInfos } from 'lib/selectors/thread-selectors';
-import { threadHasPermission } from 'lib/shared/thread-utils';
+import { threadHasPermission, viewerIsMember } from 'lib/shared/thread-utils';
import {
type ThreadInfo,
threadTypes,
@@ -95,6 +96,24 @@
);
}, [canCreateSubchannels]);
+ const leaveThreadItem = React.useMemo(() => {
+ const canLeaveThread = threadHasPermission(
+ threadInfo,
+ threadPermissions.LEAVE_THREAD,
+ );
+ if (!viewerIsMember(threadInfo) || !canLeaveThread) {
+ return null;
+ }
+ return (
+ <ThreadMenuItem
+ key="leave"
+ text="Leave Thread"
+ icon={faSignOutAlt}
+ dangerous
+ />
+ );
+ }, [threadInfo]);
+
const menuItems = React.useMemo(() => {
const settingsItem = (
<ThreadMenuItem key="settings" text="Settings" icon={faCog} />
@@ -102,6 +121,8 @@
const notificationsItem = (
<ThreadMenuItem key="notifications" text="Notifications" icon={faBell} />
);
+ const separator = <hr key="separator" className={css.separator} />;
+
const items = [
settingsItem,
notificationsItem,
@@ -109,9 +130,17 @@
sidebarItem,
viewSubchannelsItem,
createSubchannelsItem,
+ leaveThreadItem && separator,
+ leaveThreadItem,
];
return items.filter(Boolean);
- }, [membersItem, sidebarItem, viewSubchannelsItem, createSubchannelsItem]);
+ }, [
+ membersItem,
+ sidebarItem,
+ viewSubchannelsItem,
+ createSubchannelsItem,
+ leaveThreadItem,
+ ]);
const closeMenuCallback = React.useCallback(() => {
document.removeEventListener('click', closeMenuCallback);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 5:34 AM (20 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2514971
Default Alt Text
D3192.id9796.diff (2 KB)
Attached To
Mode
D3192: [web] Introduce `Leave` thread menu action
Attached
Detach File
Event Timeline
Log In to Comment