Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3753363
D8307.id28054.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D8307.id28054.diff
View Options
diff --git a/web/invite-links/invite-links-menu.css b/web/invite-links/invite-links-menu.css
--- a/web/invite-links/invite-links-menu.css
+++ b/web/invite-links/invite-links-menu.css
@@ -1,3 +1,4 @@
.container {
color: var(--menu-color-light);
+ width: 24px;
}
diff --git a/web/invite-links/invite-links-menu.react.js b/web/invite-links/invite-links-menu.react.js
--- a/web/invite-links/invite-links-menu.react.js
+++ b/web/invite-links/invite-links-menu.react.js
@@ -5,13 +5,17 @@
import { useModalContext } from 'lib/components/modal-provider.react.js';
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import { primaryInviteLinksSelector } from 'lib/selectors/invite-links-selectors.js';
+import { threadInfoSelector } from 'lib/selectors/thread-selectors.js';
+import { threadHasPermission } from 'lib/shared/thread-utils.js';
import type { InviteLink } from 'lib/types/link-types.js';
+import { threadPermissions } from 'lib/types/thread-permission-types.js';
import css from './invite-links-menu.css';
import ViewInviteLinkModal from './view-invite-link-modal.react.js';
import MenuItem from '../components/menu-item.react.js';
import Menu from '../components/menu.react.js';
import { useSelector } from '../redux/redux-utils.js';
+import { AddLink } from '../vectors.react.js';
type Props = {
+communityID: string,
@@ -24,6 +28,14 @@
];
const { pushModal } = useModalContext();
+ const community = useSelector(
+ state => threadInfoSelector(state)[communityID],
+ );
+ const canManageLinks = threadHasPermission(
+ community,
+ threadPermissions.MANAGE_INVITE_LINKS,
+ );
+
const openViewInviteLinkModal = React.useCallback(() => {
if (!inviteLink) {
return;
@@ -31,19 +43,58 @@
pushModal(<ViewInviteLinkModal inviteLink={inviteLink} />);
}, [inviteLink, pushModal]);
- if (!inviteLink) {
- return null;
- }
+ const items = React.useMemo(() => {
+ const itemSpecs = [];
+
+ if (canManageLinks) {
+ itemSpecs.push({
+ text: 'Manage Invite Links',
+ iconComponent: <AddLink />,
+ onClick: () => {},
+ });
+ }
+
+ if (inviteLink) {
+ itemSpecs.push({
+ text: 'Invite Link',
+ icon: 'link',
+ onClick: openViewInviteLinkModal,
+ });
+ }
+
+ return itemSpecs;
+ }, [canManageLinks, inviteLink, openViewInviteLinkModal]);
+
+ const menuItems = React.useMemo(
+ () =>
+ items.map(item => {
+ if (item.icon) {
+ return (
+ <MenuItem
+ key={item.text}
+ text={item.text}
+ icon={item.icon}
+ onClick={item.onClick}
+ />
+ );
+ }
+ return (
+ <MenuItem
+ key={item.text}
+ text={item.text}
+ iconComponent={item.iconComponent}
+ onClick={item.onClick}
+ />
+ );
+ }),
+ [items],
+ );
const icon = <SWMansionIcon icon="menu-vertical" size={24} />;
return (
<div className={css.container}>
<Menu icon={icon} variant="community-actions">
- <MenuItem
- text="Invite Link"
- icon="link"
- onClick={openViewInviteLinkModal}
- />
+ {menuItems}
</Menu>
</div>
);
diff --git a/web/vectors.react.js b/web/vectors.react.js
--- a/web/vectors.react.js
+++ b/web/vectors.react.js
@@ -7,6 +7,7 @@
viewBox: string,
preserveAspectRatio?: string,
children?: React.Node,
+ fill?: string,
};
function SVG(props: SVGProps): React.Node {
@@ -96,3 +97,25 @@
</SVG>
);
}
+
+export function AddLink(props: { className?: string }): React.Node {
+ return (
+ <SVG className={props.className} viewBox="0 0 24 24" fill="none">
+ <path
+ d={
+ 'M16.9488 12.7106L18.363 11.2964C19.9251 9.73433 19.9251 7.20167 ' +
+ '18.363 5.63957C16.8009 4.07747 14.2682 4.07747 12.7061 ' +
+ '5.63957L11.2919 7.05378M9.1706 14.832L14.8275 9.1751M7.04928 ' +
+ '11.2964L5.63507 12.7106C4.07297 14.2727 4.07297 16.8054 5.63507 ' +
+ '18.3675C7.19717 19.9296 9.72983 19.9296 11.2919 18.3675L12.7061 ' +
+ '16.9533'
+ }
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ <path d="M19.5 15V21" strokeWidth="1.5" strokeLinecap="round" />
+ <path d="M22.5 18H16.5" strokeWidth="1.5" strokeLinecap="round" />
+ </SVG>
+ );
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 11, 1:54 AM (19 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2858251
Default Alt Text
D8307.id28054.diff (4 KB)
Attached To
Mode
D8307: [web] Add manage invite links menu item
Attached
Detach File
Event Timeline
Log In to Comment