import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { Link, matchPath, useHistory } from 'react-router-dom'; import { Button, Divider, HStack, Popover, Stack, Text } from 'soapbox/components/ui'; import GroupMemberCount from 'soapbox/features/group/components/group-member-count'; import GroupPrivacy from 'soapbox/features/group/components/group-privacy'; import GroupAvatar from '../group-avatar'; import type { Group } from 'soapbox/schemas'; interface IGroupPopoverContainer { children: React.ReactElement>; isEnabled: boolean; group: Group; } const messages = defineMessages({ title: { id: 'group.popover.title', defaultMessage: 'Membership required' }, summary: { id: 'group.popover.summary', defaultMessage: 'You must be a member of the group in order to reply to this status.' }, action: { id: 'group.popover.action', defaultMessage: 'View Group' }, }); const GroupPopover = (props: IGroupPopoverContainer) => { const { children, group, isEnabled } = props; const intl = useIntl(); const history = useHistory(); const path = history.location.pathname; const shouldHideAction = matchPath(path, { path: ['/group/:groupSlug'], exact: true, }); if (!isEnabled) { return children; } return ( {/* Group Cover Image */} {group.header && ( )} {/* Group Avatar */}
{/* Group Info */}
{intl.formatMessage(messages.title)} {intl.formatMessage(messages.summary)} {!shouldHideAction && (
)} } isFlush children={
{children}
} /> ); }; export default GroupPopover;