Hide 'View group' button if already on Group
This commit is contained in:
parent
e5cf1dfa85
commit
7548c26490
1 changed files with 18 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, matchPath, useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import { Button, Divider, HStack, Popover, Stack, Text } from 'soapbox/components/ui';
|
import { Button, Divider, HStack, Popover, Stack, Text } from 'soapbox/components/ui';
|
||||||
import GroupMemberCount from 'soapbox/features/group/components/group-member-count';
|
import GroupMemberCount from 'soapbox/features/group/components/group-member-count';
|
||||||
|
@ -26,6 +26,13 @@ const GroupPopover = (props: IGroupPopoverContainer) => {
|
||||||
const { children, group, isEnabled } = props;
|
const { children, group, isEnabled } = props;
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
const path = history.location.pathname;
|
||||||
|
const shouldHideAction = matchPath(path, {
|
||||||
|
path: ['/group/:groupSlug'],
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
|
||||||
if (!isEnabled) {
|
if (!isEnabled) {
|
||||||
return children;
|
return children;
|
||||||
|
@ -36,7 +43,7 @@ const GroupPopover = (props: IGroupPopoverContainer) => {
|
||||||
interaction='click'
|
interaction='click'
|
||||||
referenceElementClassName='cursor-pointer'
|
referenceElementClassName='cursor-pointer'
|
||||||
content={
|
content={
|
||||||
<Stack space={4} className='w-80'>
|
<Stack space={4} className='w-80 pb-4'>
|
||||||
<Stack
|
<Stack
|
||||||
className='relative h-60 rounded-lg bg-white dark:border-primary-800 dark:bg-primary-900'
|
className='relative h-60 rounded-lg bg-white dark:border-primary-800 dark:bg-primary-900'
|
||||||
data-testid='group-card'
|
data-testid='group-card'
|
||||||
|
@ -79,13 +86,15 @@ const GroupPopover = (props: IGroupPopoverContainer) => {
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<div className='px-4 pb-4'>
|
{!shouldHideAction && (
|
||||||
<Link to={`/group/${group.slug}`}>
|
<div className='px-4'>
|
||||||
<Button type='button' theme='secondary' block>
|
<Link to={`/group/${group.slug}`}>
|
||||||
{intl.formatMessage(messages.action)}
|
<Button type='button' theme='secondary' block>
|
||||||
</Button>
|
{intl.formatMessage(messages.action)}
|
||||||
</Link>
|
</Button>
|
||||||
</div>
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
}
|
}
|
||||||
isFlush
|
isFlush
|
||||||
|
|
Loading…
Reference in a new issue