Page MenuHomePhabricator

D3192.diff
No OneTemporary

D3192.diff

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,11 @@
button.topBarMenuActionDangerous:hover {
color: var(--thread-menu-color-dangerous-hover);
}
+
+hr.separator {
+ height: 1px;
+ background: var(--thread-menu-separator-color);
+ margin: 10px 16px;
+ max-width: 130px;
+ border: none;
+}
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

Mime Type
text/plain
Expires
Sun, Nov 17, 3:04 AM (20 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2511572
Default Alt Text
D3192.diff (2 KB)

Event Timeline