2022-12-15 14:51:30 -08:00
|
|
|
import React from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
import { openModal } from 'soapbox/actions/modals';
|
|
|
|
import { Button, Stack, Text } from 'soapbox/components/ui';
|
2022-12-19 05:10:13 -08:00
|
|
|
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
2022-12-18 09:18:26 -08:00
|
|
|
import { PERMISSION_CREATE_GROUPS, hasPermission } from 'soapbox/utils/permissions';
|
2022-12-15 14:51:30 -08:00
|
|
|
|
|
|
|
const NewGroupPanel = () => {
|
|
|
|
const dispatch = useAppDispatch();
|
2022-12-19 05:10:13 -08:00
|
|
|
|
|
|
|
const canCreateGroup = useAppSelector((state) => hasPermission(state, PERMISSION_CREATE_GROUPS));
|
2022-12-15 14:51:30 -08:00
|
|
|
|
|
|
|
const createGroup = () => {
|
2023-04-03 13:12:50 -07:00
|
|
|
dispatch(openModal('CREATE_GROUP'));
|
2022-12-15 14:51:30 -08:00
|
|
|
};
|
|
|
|
|
2022-12-19 05:10:13 -08:00
|
|
|
if (!canCreateGroup) return null;
|
2022-12-18 09:18:26 -08:00
|
|
|
|
2022-12-15 14:51:30 -08:00
|
|
|
return (
|
|
|
|
<Stack space={2}>
|
|
|
|
<Stack>
|
|
|
|
<Text size='lg' weight='bold'>
|
2023-02-27 05:25:59 -08:00
|
|
|
<FormattedMessage id='new_group_panel.title' defaultMessage='Create Group' />
|
2022-12-15 14:51:30 -08:00
|
|
|
</Text>
|
|
|
|
|
|
|
|
<Text theme='muted' size='sm'>
|
|
|
|
<FormattedMessage id='new_group_panel.subtitle' defaultMessage="Can't find what you're looking for? Start your own private or public group." />
|
|
|
|
</Text>
|
|
|
|
</Stack>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
onClick={createGroup}
|
|
|
|
theme='secondary'
|
|
|
|
block
|
|
|
|
>
|
2023-02-27 05:25:59 -08:00
|
|
|
<FormattedMessage id='new_group_panel.action' defaultMessage='Create Group' />
|
2022-12-15 14:51:30 -08:00
|
|
|
</Button>
|
|
|
|
</Stack>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default NewGroupPanel;
|