Groups fixes

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-06-23 19:29:18 +02:00
parent b03256b53b
commit e82b9bc579
18 changed files with 29 additions and 29 deletions

View file

@ -8,7 +8,7 @@ const useGroupRelationships = (listKey: string[], ids: string[]) => {
const { isLoggedIn } = useLoggedIn(); const { isLoggedIn } = useLoggedIn();
const fetchGroupRelationships = (ids: string[]) => const fetchGroupRelationships = (ids: string[]) =>
api('/api/v1/groups/relationships', { params: { ids } }); api('/api/v1/groups/relationships', { params: { id: ids } });
const { entityMap: relationships, ...result } = useBatchedEntities<GroupRelationship>( const { entityMap: relationships, ...result } = useBatchedEntities<GroupRelationship>(
[Entities.RELATIONSHIPS, ...listKey], [Entities.RELATIONSHIPS, ...listKey],

View file

@ -30,7 +30,7 @@ const GroupPopover = (props: IGroupPopoverContainer) => {
const path = history.location.pathname; const path = history.location.pathname;
const shouldHideAction = matchPath(path, { const shouldHideAction = matchPath(path, {
path: ['/group/:groupId'], path: ['/groups/:groupId'],
exact: true, exact: true,
}); });
@ -88,7 +88,7 @@ const GroupPopover = (props: IGroupPopoverContainer) => {
{!shouldHideAction && ( {!shouldHideAction && (
<div className='px-4'> <div className='px-4'>
<Link to={`/group/${group.id}`}> <Link to={`/groups/${group.id}`}>
<Button type='button' theme='secondary' block> <Button type='button' theme='secondary' block>
{intl.formatMessage(messages.action)} {intl.formatMessage(messages.action)}
</Button> </Button>

View file

@ -119,7 +119,7 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
const intl = useIntl(); const intl = useIntl();
const history = useHistory(); const history = useHistory();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const match = useRouteMatch<{ groupId: string }>('/group/:groupId'); const match = useRouteMatch<{ groupId: string }>('/groups/:groupId');
const { group } = useGroup((status.group as Group)?.id as string); const { group } = useGroup((status.group as Group)?.id as string);
const deleteGroupStatus = useDeleteGroupStatus(group as Group, status.id); const deleteGroupStatus = useDeleteGroupStatus(group as Group, status.id);

View file

@ -223,7 +223,7 @@ const Status: React.FC<IStatus> = (props) => {
</Link> </Link>
), ),
group: ( group: (
<Link to={`/group/${group.id}`} className='hover:underline'> <Link to={`/groups/${group.id}`} className='hover:underline'>
<strong <strong
className='text-gray-800 dark:text-gray-200' className='text-gray-800 dark:text-gray-200'
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
@ -300,7 +300,7 @@ const Status: React.FC<IStatus> = (props) => {
defaultMessage='Posted in {group}' defaultMessage='Posted in {group}'
values={{ values={{
group: ( group: (
<Link to={`/group/${group.id}`} className='hover:underline'> <Link to={`/groups/${group.id}`} className='hover:underline'>
<bdi className='truncate'> <bdi className='truncate'>
<strong className='text-gray-800 dark:text-gray-200'> <strong className='text-gray-800 dark:text-gray-200'>
<span dangerouslySetInnerHTML={{ __html: group.display_name_html }} /> <span dangerouslySetInnerHTML={{ __html: group.display_name_html }} />

View file

@ -30,7 +30,7 @@ const ReplyGroupIndicator = (props: IReplyGroupIndicator) => {
defaultMessage='Posting to {groupLink}' defaultMessage='Posting to {groupLink}'
values={{ values={{
groupLink: <Link groupLink: <Link
to={`/group/${group.id}`} to={`/groups/${group.id}`}
dangerouslySetInnerHTML={{ __html: group.display_name_html }} dangerouslySetInnerHTML={{ __html: group.display_name_html }}
/>, />,
}} }}

View file

@ -83,7 +83,7 @@ const GroupActionButton = ({ group }: IGroupActionButton) => {
return ( return (
<Button <Button
theme='secondary' theme='secondary'
to={`/group/${group.id}/manage`} to={`/groups/${group.id}/manage`}
> >
<FormattedMessage id='group.manage' defaultMessage='Manage group' /> <FormattedMessage id='group.manage' defaultMessage='Manage group' />
</Button> </Button>

View file

@ -143,7 +143,7 @@ const GroupHeader: React.FC<IGroupHeader> = ({ group }) => {
<Stack data-testid='group-meta' space={1} alignItems='center'> <Stack data-testid='group-meta' space={1} alignItems='center'>
<HStack className='text-gray-700 dark:text-gray-600' space={2} wrap> <HStack className='text-gray-700 dark:text-gray-600' space={2} wrap>
<GroupRelationship group={group} /> <GroupRelationship group={group} />
<GroupPrivacy group={group} />4 <GroupPrivacy group={group} />
<GroupMemberCount group={group} /> <GroupMemberCount group={group} />
</HStack> </HStack>

View file

@ -11,7 +11,7 @@ interface IGroupMemberCount {
} }
const GroupMemberCount = ({ group }: IGroupMemberCount) => ( const GroupMemberCount = ({ group }: IGroupMemberCount) => (
<Link to={`/group/${group.id}/members`} className='hover:underline'> <Link to={`/groups/${group.id}/members`} className='hover:underline'>
<Text theme='inherit' tag='span' size='sm' weight='medium' data-testid='group-member-count'> <Text theme='inherit' tag='span' size='sm' weight='medium' data-testid='group-member-count'>
{shortNumberFormat(group.members_count)} {shortNumberFormat(group.members_count)}
{' '} {' '}

View file

@ -82,7 +82,7 @@ const GroupBlockedMembers: React.FC<IGroupBlockedMembers> = ({ params }) => {
const emptyMessage = <FormattedMessage id='empty_column.group_blocks' defaultMessage="The group hasn't banned any users yet." />; const emptyMessage = <FormattedMessage id='empty_column.group_blocks' defaultMessage="The group hasn't banned any users yet." />;
return ( return (
<Column label={intl.formatMessage(messages.heading)} backHref={`/group/${group.id}/manage`}> <Column label={intl.formatMessage(messages.heading)} backHref={`/groups/${group.id}/manage`}>
<ScrollableList <ScrollableList
scrollKey='group_blocks' scrollKey='group_blocks'
emptyMessage={emptyMessage} emptyMessage={emptyMessage}

View file

@ -49,7 +49,7 @@ const GroupMembers: React.FC<IGroupMembers> = (props) => {
prepend={(pendingCount > 0) && ( prepend={(pendingCount > 0) && (
<div className={clsx('py-3', { 'border-b border-gray-200 dark:border-gray-800': members.length })}> <div className={clsx('py-3', { 'border-b border-gray-200 dark:border-gray-800': members.length })}>
<PendingItemsRow <PendingItemsRow
to={`/group/${group?.id}/manage/requests`} to={`/groups/${group?.id}/manage/requests`}
count={pendingCount} count={pendingCount}
/> />
</div> </div>

View file

@ -74,7 +74,7 @@ const ManageGroup: React.FC<IManageGroup> = ({ params }) => {
})); }));
return ( return (
<Column label={intl.formatMessage(messages.heading)} backHref={`/group/${group.id}`}> <Column label={intl.formatMessage(messages.heading)} backHref={`/groups/${group.id}`}>
<CardBody className='space-y-4'> <CardBody className='space-y-4'>
{isOwner && ( {isOwner && (
<> <>
@ -83,7 +83,7 @@ const ManageGroup: React.FC<IManageGroup> = ({ params }) => {
</CardHeader> </CardHeader>
<List> <List>
<ListItem label={intl.formatMessage(messages.editGroup)} to={`/group/${group.id}/manage/edit`}> <ListItem label={intl.formatMessage(messages.editGroup)} to={`/groups/${group.id}/manage/edit`}>
<span dangerouslySetInnerHTML={{ __html: group.display_name_html }} /> <span dangerouslySetInnerHTML={{ __html: group.display_name_html }} />
</ListItem> </ListItem>
</List> </List>
@ -95,9 +95,9 @@ const ManageGroup: React.FC<IManageGroup> = ({ params }) => {
</CardHeader> </CardHeader>
<List> <List>
<ListItem label={intl.formatMessage(messages.pendingRequests)} to={`/group/${group.id}/manage/requests`} /> <ListItem label={intl.formatMessage(messages.pendingRequests)} to={`/groups/${group.id}/manage/requests`} />
<ListItem label={intl.formatMessage(messages.blockedMembers)} to={`/group/${group.id}/manage/blocks`} /> <ListItem label={intl.formatMessage(messages.blockedMembers)} to={`/groups/${group.id}/manage/blocks`} />
</List> </List>
{isOwner && ( {isOwner && (

View file

@ -22,7 +22,7 @@ const GroupListItem = (props: IGroupListItem) => {
justifyContent='between' justifyContent='between'
data-testid='group-list-item' data-testid='group-list-item'
> >
<Link key={group.id} to={`/group/${group.id}`} className='overflow-hidden'> <Link key={group.id} to={`/groups/${group.id}`} className='overflow-hidden'>
<HStack alignItems='center' space={2}> <HStack alignItems='center' space={2}>
<GroupAvatar <GroupAvatar
group={group} group={group}

View file

@ -84,7 +84,7 @@ const Groups: React.FC = () => {
hasMore={hasNextPage} hasMore={hasNextPage}
> >
{groups.map((group) => ( {groups.map((group) => (
<Link key={group.id} to={`/group/${group.id}`}> <Link key={group.id} to={`/groups/${group.id}`}>
<GroupCard group={group} /> <GroupCard group={group} />
</Link> </Link>
))} ))}

View file

@ -64,7 +64,7 @@ const DetailedStatus: React.FC<IDetailedStatus> = ({
defaultMessage='Posted in {group}' defaultMessage='Posted in {group}'
values={{ values={{
group: ( group: (
<Link to={`/group/${status.group.id}`} className='hover:underline'> <Link to={`/groups/${status.group.id}`} className='hover:underline'>
<bdi className='truncate'> <bdi className='truncate'>
<strong className='text-gray-800 dark:text-gray-200'> <strong className='text-gray-800 dark:text-gray-200'>
<span dangerouslySetInnerHTML={{ __html: (status.group as Group).display_name_html }} /> <span dangerouslySetInnerHTML={{ __html: (status.group as Group).display_name_html }} />

View file

@ -88,7 +88,7 @@ const StatusDetails: React.FC<IStatusDetails> = (props) => {
if (status.group && typeof status.group === 'object') { if (status.group && typeof status.group === 'object') {
if (status.group.id && !props.params.groupId) { if (status.group.id && !props.params.groupId) {
return <Redirect to={`/group/${status.group.id}/posts/${props.params.statusId}`} />; return <Redirect to={`/groups/${status.group.id}/posts/${props.params.statusId}`} />;
} }
} }

View file

@ -11,7 +11,7 @@ import { useAppDispatch } from 'soapbox/hooks';
const ComposeButton = () => { const ComposeButton = () => {
const location = useLocation(); const location = useLocation();
const isOnGroupPage = location.pathname.startsWith('/group/'); const isOnGroupPage = location.pathname.startsWith('/group/');
const match = useRouteMatch<{ groupId: string }>('/group/:groupId'); const match = useRouteMatch<{ groupId: string }>('/groups/:groupId');
const { group } = useGroup(match?.params.groupId || ''); const { group } = useGroup(match?.params.groupId || '');
const isGroupMember = !!group?.relationship?.member; const isGroupMember = !!group?.relationship?.member;
@ -40,7 +40,7 @@ const HomeComposeButton = () => {
const GroupComposeButton = () => { const GroupComposeButton = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const match = useRouteMatch<{ groupId: string }>('/group/:groupId'); const match = useRouteMatch<{ groupId: string }>('/groups/:groupId');
const { group } = useGroup(match?.params.groupId || ''); const { group } = useGroup(match?.params.groupId || '');
if (!group) return null; if (!group) return null;

View file

@ -53,7 +53,7 @@ const GroupFAB: React.FC = () => {
const intl = useIntl(); const intl = useIntl();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const match = useRouteMatch<{ groupId: string }>('/group/:groupId'); const match = useRouteMatch<{ groupId: string }>('/groups/:groupId');
const { group } = useGroup(match?.params.groupId || ''); const { group } = useGroup(match?.params.groupId || '');
if (!group) return null; if (!group) return null;

View file

@ -62,20 +62,20 @@ const GroupPage: React.FC<IGroupPage> = ({ params, children }) => {
const items = []; const items = [];
items.push({ items.push({
text: intl.formatMessage(messages.all), text: intl.formatMessage(messages.all),
to: `/group/${id}`, to: `/groups/${id}`,
name: '/group/:groupId', name: '/groups/:groupId',
}); });
items.push( items.push(
{ {
text: intl.formatMessage(messages.media), text: intl.formatMessage(messages.media),
to: `/group/${id}/media`, to: `/groups/${id}/media`,
name: '/group/:groupId/media', name: '/groups/:groupId/media',
}, },
{ {
text: intl.formatMessage(messages.members), text: intl.formatMessage(messages.members),
to: `/group/${id}/members`, to: `/groups/${id}/members`,
name: '/group/:groupId/members', name: '/groups/:groupId/members',
count: pending.length, count: pending.length,
}, },
); );