diff --git a/web/invite-links/invite-links-menu.css b/web/invite-links/invite-links-menu.css index 6b33c182b..aa413da65 100644 --- 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 index 7e24809b9..271c53cb5 100644 --- a/web/invite-links/invite-links-menu.react.js +++ b/web/invite-links/invite-links-menu.react.js @@ -1,52 +1,103 @@ // @flow import * as React from 'react'; 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, }; function InviteLinksMenu(props: Props): React.Node { const { communityID } = props; const inviteLink: ?InviteLink = useSelector(primaryInviteLinksSelector)[ communityID ]; 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; } pushModal(); }, [inviteLink, pushModal]); - if (!inviteLink) { - return null; - } + const items = React.useMemo(() => { + const itemSpecs = []; + + if (canManageLinks) { + itemSpecs.push({ + text: 'Manage invite links', + iconComponent: , + 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 ( + + ); + } + return ( + + ); + }), + [items], + ); const icon = ; return (
- + {menuItems}
); } export default InviteLinksMenu; diff --git a/web/vectors.react.js b/web/vectors.react.js index 2ac011a02..fbff55d45 100644 --- a/web/vectors.react.js +++ b/web/vectors.react.js @@ -1,98 +1,121 @@ // @flow import * as React from 'react'; type SVGProps = { className?: string, viewBox: string, preserveAspectRatio?: string, children?: React.Node, + fill?: string, }; function SVG(props: SVGProps): React.Node { return ( ); } export function UpCaret(props: { className?: string }): React.Node { return ( ); } export function DownCaret(props: { className?: string }): React.Node { return ( ); } export function DeleteVector(props: { className?: string }): React.Node { return ( ); } export function AddVector(props: { className?: string }): React.Node { return ( ); } export function HistoryVector(props: { className?: string }): React.Node { return ( ); } export function MagnifyingGlass(props: { className?: string }): React.Node { return ( ); } + +export function AddLink(props: { className?: string }): React.Node { + return ( + + + + + + ); +}