Update group URLs to use slugs

This commit is contained in:
Alex Gleason 2023-04-17 15:42:08 -04:00
parent 1bce61182c
commit f2d5b2eaef
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
12 changed files with 27 additions and 21 deletions

View file

@ -80,7 +80,7 @@ const GroupPopover = (props: IGroupPopoverContainer) => {
</Stack> </Stack>
<div className='px-4 pb-4'> <div className='px-4 pb-4'>
<Link to={`/groups/${group.id}`}> <Link to={`/group/${group.slug}`}>
<Button type='button' theme='secondary' block> <Button type='button' theme='secondary' block>
{intl.formatMessage(messages.action)} {intl.formatMessage(messages.action)}
</Button> </Button>

View file

@ -253,7 +253,7 @@ const Status: React.FC<IStatus> = (props) => {
return ( return (
<StatusInfo <StatusInfo
avatarSize={avatarSize} avatarSize={avatarSize}
to={`/groups/${group.id}`} to={`/group/${group.slug}`}
icon={<Icon src={require('@tabler/icons/circles.svg')} className='h-4 w-4 text-primary-600 dark:text-accent-blue' />} icon={<Icon src={require('@tabler/icons/circles.svg')} className='h-4 w-4 text-primary-600 dark:text-accent-blue' />}
text={ text={
<Text size='xs' theme='muted' weight='medium'> <Text size='xs' theme='muted' weight='medium'>

View file

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

View file

@ -86,7 +86,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={`/groups/${id}/manage`}> <Column label={intl.formatMessage(messages.heading)} backHref={`/group/${group.slug}/manage`}>
<ScrollableList <ScrollableList
scrollKey='group_blocks' scrollKey='group_blocks'
emptyMessage={emptyMessage} emptyMessage={emptyMessage}

View file

@ -58,7 +58,10 @@ const GroupMembers: React.FC<IGroupMembers> = (props) => {
itemClassName='py-3 last:pb-0' itemClassName='py-3 last:pb-0'
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 to={`/groups/${groupId}/manage/requests`} count={pendingCount} /> <PendingItemsRow
to={`/group/${group?.slug}/manage/requests`}
count={pendingCount}
/>
</div> </div>
)} )}
> >

View file

@ -77,12 +77,12 @@ const ManageGroup: React.FC<IManageGroup> = ({ params }) => {
}, },
})); }));
const navigateToEdit = () => history.push(`/groups/${id}/manage/edit`); const navigateToEdit = () => history.push(`/group/${group.slug}/manage/edit`);
const navigateToPending = () => history.push(`/groups/${id}/manage/requests`); const navigateToPending = () => history.push(`/group/${group.slug}/manage/requests`);
const navigateToBlocks = () => history.push(`/groups/${id}/manage/blocks`); const navigateToBlocks = () => history.push(`/group/${group.slug}/manage/blocks`);
return ( return (
<Column label={intl.formatMessage(messages.heading)} backHref={`/groups/${id}`}> <Column label={intl.formatMessage(messages.heading)} backHref={`/group/${group.slug}`}>
<CardBody className='space-y-4'> <CardBody className='space-y-4'>
{isOwner && ( {isOwner && (
<> <>

View file

@ -25,7 +25,7 @@ const GroupGridItem = forwardRef((props: IGroup, ref: React.ForwardedRef<HTMLDiv
width, width,
}} }}
> >
<Link to={`/groups/${group.id}`}> <Link to={`/group/${group.slug}`}>
<Stack <Stack
className='aspect-h-7 aspect-w-10 h-full w-full overflow-hidden rounded-lg' className='aspect-h-7 aspect-w-10 h-full w-full overflow-hidden rounded-lg'
ref={ref} ref={ref}

View file

@ -21,7 +21,7 @@ const GroupListItem = (props: IGroup) => {
alignItems='center' alignItems='center'
justifyContent='between' justifyContent='between'
> >
<Link key={group.id} to={`/groups/${group.id}`}> <Link key={group.id} to={`/group/${group.slug}`}>
<HStack alignItems='center' space={2}> <HStack alignItems='center' space={2}>
<GroupAvatar <GroupAvatar
group={group} group={group}

View file

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

View file

@ -57,7 +57,7 @@ export default () => {
showLoading={isLoading && groups.length === 0} showLoading={isLoading && groups.length === 0}
> >
{groups.map((group) => ( {groups.map((group) => (
<Link key={group.id} to={`/groups/${group.id}`}> <Link key={group.id} to={`/group/${group.slug}`}>
<GroupCard group={group} /> <GroupCard group={group} />
</Link> </Link>
))} ))}

View file

@ -119,6 +119,7 @@ type DisplayMedia = 'default' | 'hide_all' | 'show_all';
type RouteParams = { type RouteParams = {
statusId: string statusId: string
groupId?: string groupId?: string
groupSlug?: string
}; };
interface IThread { interface IThread {
@ -517,8 +518,10 @@ const Thread: React.FC<IThread> = (props) => {
children.push(...renderChildren(descendantsIds).toArray()); children.push(...renderChildren(descendantsIds).toArray());
} }
if (status.group && typeof status.group === 'object' && !props.params.groupId) { if (status.group && typeof status.group === 'object') {
return <Redirect to={`/groups/${status.group.id}/posts/${props.params.statusId}`} />; if (status.group.slug && !props.params.groupSlug) {
return <Redirect to={`/group/${status.group.slug}/posts/${props.params.statusId}`} />;
}
} }
const titleMessage = () => { const titleMessage = () => {

View file

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