Merge branch 'my-groups-blankslate' into 'develop'

Update blankslate to allow Group Creation

See merge request soapbox-pub/soapbox!2326
environments/review-develop-3zknud/deployments/2828
Chewbacca 2 years ago
commit 879ac883aa

@ -52,6 +52,8 @@ interface IScrollableList extends VirtuosoProps<any, any> {
alwaysPrepend?: boolean alwaysPrepend?: boolean
/** Message to display when the list is loaded but empty. */ /** Message to display when the list is loaded but empty. */
emptyMessage?: React.ReactNode emptyMessage?: React.ReactNode
/** Should the empty message be displayed in a Card */
emptyMessageCard?: boolean
/** Scrollable content. */ /** Scrollable content. */
children: Iterable<React.ReactNode> children: Iterable<React.ReactNode>
/** Callback when the list is scrolled to the top. */ /** Callback when the list is scrolled to the top. */
@ -87,6 +89,7 @@ const ScrollableList = React.forwardRef<VirtuosoHandle, IScrollableList>(({
children, children,
isLoading, isLoading,
emptyMessage, emptyMessage,
emptyMessageCard = true,
showLoading, showLoading,
onRefresh, onRefresh,
onScroll, onScroll,
@ -158,13 +161,17 @@ const ScrollableList = React.forwardRef<VirtuosoHandle, IScrollableList>(({
<div className='mt-2'> <div className='mt-2'>
{alwaysPrepend && prepend} {alwaysPrepend && prepend}
<Card variant='rounded' size='lg'>
{isLoading ? ( {isLoading ? (
<Spinner /> <Spinner />
) : ( ) : (
emptyMessage <>
)} {emptyMessageCard ? (
<Card variant='rounded' size='lg'>
{emptyMessage}
</Card> </Card>
) : emptyMessage}
</>
)}
</div> </div>
); );
}; };

@ -15,8 +15,20 @@ import TabBar, { TabItems } from './components/tab-bar';
import type { Group as GroupEntity } from 'soapbox/types/entities'; import type { Group as GroupEntity } from 'soapbox/types/entities';
const EmptyMessage = () => ( const Groups: React.FC = () => {
<Stack space={6} alignItems='center' justifyContent='center' className='h-full p-6'> const dispatch = useAppDispatch();
const features = useFeatures();
const canCreateGroup = useAppSelector((state) => hasPermission(state, PERMISSION_CREATE_GROUPS));
const { groups, isLoading } = useGroups();
const createGroup = () => {
dispatch(openModal('MANAGE_GROUP'));
};
const renderBlankslate = () => (
<Stack space={4} alignItems='center' justifyContent='center' className='py-6'>
<Stack space={2} className='max-w-sm'> <Stack space={2} className='max-w-sm'>
<Text size='2xl' weight='bold' tag='h2' align='center'> <Text size='2xl' weight='bold' tag='h2' align='center'>
<FormattedMessage <FormattedMessage
@ -32,20 +44,19 @@ const EmptyMessage = () => (
/> />
</Text> </Text>
</Stack> </Stack>
</Stack>
);
const Groups: React.FC = () => {
const dispatch = useAppDispatch();
const features = useFeatures();
const canCreateGroup = useAppSelector((state) => hasPermission(state, PERMISSION_CREATE_GROUPS)); {canCreateGroup && (
<Button
const { groups, isLoading } = useGroups(); className='self-center'
onClick={createGroup}
theme='secondary'
>
<FormattedMessage id='new_group_panel.action' defaultMessage='Create Group' />
</Button>
)}
</Stack>
);
const createGroup = () => {
dispatch(openModal('MANAGE_GROUP'));
};
return ( return (
<Stack space={4}> <Stack space={4}>
@ -67,7 +78,8 @@ const Groups: React.FC = () => {
<ScrollableList <ScrollableList
scrollKey='groups' scrollKey='groups'
emptyMessage={<EmptyMessage />} emptyMessage={renderBlankslate()}
emptyMessageCard={false}
itemClassName='py-3 first:pt-0 last:pb-0' itemClassName='py-3 first:pt-0 last:pb-0'
isLoading={isLoading} isLoading={isLoading}
showLoading={isLoading && groups.length === 0} showLoading={isLoading && groups.length === 0}

Loading…
Cancel
Save