Remove some group-related stuff

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-06-18 23:59:15 +02:00
parent dd5b1359c1
commit 5f8c9427bf
13 changed files with 31 additions and 104 deletions

View file

@ -36,10 +36,6 @@ const GroupCard: React.FC<IGroupCard> = ({ group }) => (
<Stack alignItems='center' justifyContent='end' grow className='basis-1/2 py-4' space={0.5}> <Stack alignItems='center' justifyContent='end' grow className='basis-1/2 py-4' space={0.5}>
<HStack alignItems='center' space={1.5}> <HStack alignItems='center' space={1.5}>
<Text size='lg' weight='bold' dangerouslySetInnerHTML={{ __html: group.display_name_html }} /> <Text size='lg' weight='bold' dangerouslySetInnerHTML={{ __html: group.display_name_html }} />
{group.relationship?.pending_requests && (
<div className='h-2 w-2 rounded-full bg-secondary-500' />
)}
</HStack> </HStack>
<HStack className='text-gray-700 dark:text-gray-600' space={2} wrap> <HStack className='text-gray-700 dark:text-gray-600' space={2} wrap>

View file

@ -501,14 +501,12 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
} }
if (isGroupStatus && !!status.group) { if (isGroupStatus && !!status.group) {
const group = status.group as Group;
const account = status.account;
const isGroupOwner = groupRelationship?.role === GroupRoles.OWNER; const isGroupOwner = groupRelationship?.role === GroupRoles.OWNER;
const isGroupAdmin = groupRelationship?.role === GroupRoles.ADMIN; const isGroupAdmin = groupRelationship?.role === GroupRoles.ADMIN;
const isStatusFromOwner = group.owner.id === account.id; // const isStatusFromOwner = group.owner.id === account.id;
const canBanUser = match?.isExact && (isGroupOwner || isGroupAdmin) && !isStatusFromOwner && !ownAccount; const canBanUser = match?.isExact && (isGroupOwner || isGroupAdmin) && !ownAccount;
const canDeleteStatus = !ownAccount && (isGroupOwner || (isGroupAdmin && !isStatusFromOwner)); const canDeleteStatus = !ownAccount && (isGroupOwner || isGroupAdmin);
if (canBanUser || canDeleteStatus) { if (canBanUser || canDeleteStatus) {
menu.push(null); menu.push(null);

View file

@ -37,7 +37,6 @@ const GroupActionButton = ({ group }: IGroupActionButton) => {
const isNonMember = !group.relationship?.member && !isRequested; const isNonMember = !group.relationship?.member && !isRequested;
const isOwner = group.relationship?.role === GroupRoles.OWNER; const isOwner = group.relationship?.role === GroupRoles.OWNER;
const isAdmin = group.relationship?.role === GroupRoles.ADMIN; const isAdmin = group.relationship?.role === GroupRoles.ADMIN;
const isBlocked = group.relationship?.blocked_by;
const onJoinGroup = () => joinGroup.mutate({}, { const onJoinGroup = () => joinGroup.mutate({}, {
onSuccess(entity) { onSuccess(entity) {
@ -80,10 +79,6 @@ const GroupActionButton = ({ group }: IGroupActionButton) => {
}, },
}); });
if (isBlocked) {
return null;
}
if (isOwner || isAdmin) { if (isOwner || isAdmin) {
return ( return (
<Button <Button

View file

@ -52,8 +52,6 @@ const GroupHeader: React.FC<IGroupHeader> = ({ group }) => {
); );
} }
const isDeleted = !!group.deleted_at;
const onAvatarClick = () => { const onAvatarClick = () => {
const avatar = normalizeAttachment({ const avatar = normalizeAttachment({
type: 'image', type: 'image',
@ -142,29 +140,25 @@ const GroupHeader: React.FC<IGroupHeader> = ({ group }) => {
data-testid='group-name' data-testid='group-name'
/> />
{!isDeleted && ( <Stack data-testid='group-meta' space={1} alignItems='center'>
<> <HStack className='text-gray-700 dark:text-gray-600' space={2} wrap>
<Stack data-testid='group-meta' space={1} alignItems='center'> <GroupRelationship group={group} />
<HStack className='text-gray-700 dark:text-gray-600' space={2} wrap> <GroupPrivacy group={group} />4
<GroupRelationship group={group} /> <GroupMemberCount group={group} />
<GroupPrivacy group={group} /> </HStack>
<GroupMemberCount group={group} />
</HStack>
<Text <Text
theme='muted' theme='muted'
align='center' align='center'
dangerouslySetInnerHTML={{ __html: group.note_emojified }} dangerouslySetInnerHTML={{ __html: group.note_emojified }}
className='[&_a]:text-primary-600 [&_a]:hover:underline [&_a]:dark:text-accent-blue' className='[&_a]:text-primary-600 [&_a]:hover:underline [&_a]:dark:text-accent-blue'
/> />
</Stack> </Stack>
<HStack alignItems='center' space={2} data-testid='group-actions'> <HStack alignItems='center' space={2} data-testid='group-actions'>
<GroupOptionsButton group={group} /> <GroupOptionsButton group={group} />
<GroupActionButton group={group} /> <GroupActionButton group={group} />
</HStack> </HStack>
</>
)}
</Stack> </Stack>
</div> </div>
); );

View file

@ -33,8 +33,6 @@ const GroupOptionsButton = ({ group }: IGroupActionButton) => {
const isMember = group.relationship?.role === GroupRoles.USER; const isMember = group.relationship?.role === GroupRoles.USER;
const isAdmin = group.relationship?.role === GroupRoles.ADMIN; const isAdmin = group.relationship?.role === GroupRoles.ADMIN;
const isInGroup = !!group.relationship?.member; const isInGroup = !!group.relationship?.member;
const isBlocked = group.relationship?.blocked_by;
const isMuting = group.relationship?.muting;
const handleShare = () => { const handleShare = () => {
navigator.share({ navigator.share({
@ -80,9 +78,9 @@ const GroupOptionsButton = ({ group }: IGroupActionButton) => {
} }
return items; return items;
}, [isMember, isAdmin, isInGroup, isMuting]); }, [isMember, isAdmin, isInGroup]);
if (isBlocked || menu.length === 0) { if (menu.length === 0) {
return null; return null;
} }

View file

@ -4,7 +4,7 @@ import { FormattedMessage, useIntl } from 'react-intl';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { groupCompose, uploadCompose } from 'soapbox/actions/compose'; import { groupCompose, uploadCompose } from 'soapbox/actions/compose';
import { expandGroupFeaturedTimeline, expandGroupTimeline } from 'soapbox/actions/timelines'; import { expandGroupTimeline } from 'soapbox/actions/timelines';
import { useGroup, useGroupStream } from 'soapbox/api/hooks'; import { useGroup, useGroupStream } from 'soapbox/api/hooks';
import { Avatar, HStack, Icon, Stack, Text } from 'soapbox/components/ui'; import { Avatar, HStack, Icon, Stack, Text } from 'soapbox/components/ui';
import ComposeForm from 'soapbox/features/compose/components/compose-form'; import ComposeForm from 'soapbox/features/compose/components/compose-form';
@ -47,7 +47,7 @@ const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
useEffect(() => { useEffect(() => {
dispatch(expandGroupTimeline(groupId)); dispatch(expandGroupTimeline(groupId));
dispatch(expandGroupFeaturedTimeline(groupId)); // dispatch(expandGroupFeaturedTimeline(groupId));
dispatch(groupCompose(composeId, groupId)); dispatch(groupCompose(composeId, groupId));
}, [groupId]); }, [groupId]);

View file

@ -40,7 +40,7 @@ const GroupMediaPanel: React.FC<IGroupMediaPanel> = ({ group }) => {
useEffect(() => { useEffect(() => {
setLoading(true); setLoading(true);
if (group && !group.deleted_at && (isMember || !isPrivate)) { if (group && (isMember || !isPrivate)) {
dispatch(expandGroupMediaTimeline(group.id)) dispatch(expandGroupMediaTimeline(group.id))
// @ts-ignore // @ts-ignore
.then(() => setLoading(false)) .then(() => setLoading(false))
@ -72,7 +72,7 @@ const GroupMediaPanel: React.FC<IGroupMediaPanel> = ({ group }) => {
} }
}; };
if ((isPrivate && !isMember) || group?.deleted_at) { if (isPrivate && !isMember) {
return null; return null;
} }

View file

@ -808,10 +808,8 @@
"gdpr.title": "{siteTitle} uses cookies", "gdpr.title": "{siteTitle} uses cookies",
"generic.saved": "Saved", "generic.saved": "Saved",
"getting_started.open_source_notice": "{code_name} is open source software. You can contribute or report issues at {code_link} (v{code_version}).", "getting_started.open_source_notice": "{code_name} is open source software. You can contribute or report issues at {code_link} (v{code_version}).",
"group.banned.message": "You are banned from {group}",
"group.cancel_request": "Cancel request", "group.cancel_request": "Cancel request",
"group.delete.success": "Group successfully deleted", "group.delete.success": "Group successfully deleted",
"group.deleted.message": "This group has been deleted.",
"group.demote.user.success": "@{name} is now a member", "group.demote.user.success": "@{name} is now a member",
"group.group_mod_authorize.fail": "Failed to approve @{name}", "group.group_mod_authorize.fail": "Failed to approve @{name}",
"group.group_mod_block": "Ban from group", "group.group_mod_block": "Ban from group",

View file

@ -781,7 +781,7 @@
"group.join.success": "Pomyślnie dołączono do grupy!", "group.join.success": "Pomyślnie dołączono do grupy!",
"group.leave": "Opuść grupę", "group.leave": "Opuść grupę",
"group.leave.label": "Opuść", "group.leave.label": "Opuść",
"group.leave.success": "Opuść grupę", "group.leave.success": "Opuszczono grupę",
"group.manage": "Zarządzaj grupę", "group.manage": "Zarządzaj grupę",
"group.member.admin.limit.summary": "Możesz teraz przypisać do {count, plural, one {# administratora}, other {# administratorów}} do grupy.", "group.member.admin.limit.summary": "Możesz teraz przypisać do {count, plural, one {# administratora}, other {# administratorów}} do grupy.",
"group.member.admin.limit.title": "Przekroczono limit administratorów", "group.member.admin.limit.title": "Przekroczono limit administratorów",

View file

@ -21,7 +21,6 @@ const GroupRecord = ImmutableRecord({
avatar: '', avatar: '',
avatar_static: '', avatar_static: '',
created_at: '', created_at: '',
deleted_at: null,
display_name: '', display_name: '',
domain: '', domain: '',
emojis: [] as Emoji[], emojis: [] as Emoji[],

View file

@ -13,8 +13,6 @@ import {
} from 'soapbox/features/ui/util/async-components'; } from 'soapbox/features/ui/util/async-components';
import { useOwnAccount } from 'soapbox/hooks'; import { useOwnAccount } from 'soapbox/hooks';
import type { Group } from 'soapbox/schemas';
const messages = defineMessages({ const messages = defineMessages({
all: { id: 'group.tabs.all', defaultMessage: 'All' }, all: { id: 'group.tabs.all', defaultMessage: 'All' },
members: { id: 'group.tabs.members', defaultMessage: 'Members' }, members: { id: 'group.tabs.members', defaultMessage: 'Members' },
@ -28,24 +26,6 @@ interface IGroupPage {
children: React.ReactNode; children: React.ReactNode;
} }
const DeletedBlankslate = () => (
<Stack space={4} className='py-10' alignItems='center'>
<div className='rounded-full bg-danger-200 p-3 dark:bg-danger-400/20'>
<Icon
src={require('@tabler/icons/outline/trash.svg')}
className='h-6 w-6 text-danger-600 dark:text-danger-400'
/>
</div>
<Text theme='muted'>
<FormattedMessage
id='group.deleted.message'
defaultMessage='This group has been deleted.'
/>
</Text>
</Stack>
);
const PrivacyBlankslate = () => ( const PrivacyBlankslate = () => (
<Stack space={4} className='py-10' alignItems='center'> <Stack space={4} className='py-10' alignItems='center'>
<div className='rounded-full bg-gray-200 p-3 dark:bg-gray-800'> <div className='rounded-full bg-gray-200 p-3 dark:bg-gray-800'>
@ -64,27 +44,6 @@ const PrivacyBlankslate = () => (
</Stack> </Stack>
); );
const BlockedBlankslate = ({ group }: { group: Group }) => (
<Stack space={4} className='py-10' alignItems='center'>
<div className='rounded-full bg-danger-200 p-3 dark:bg-danger-400/20'>
<Icon
src={require('@tabler/icons/outline/ban.svg')}
className='h-6 w-6 text-danger-600 dark:text-danger-400'
/>
</div>
<Text theme='muted'>
<FormattedMessage
id='group.banned.message'
defaultMessage='You are banned from {group}'
values={{
group: <Text theme='inherit' tag='span' dangerouslySetInnerHTML={{ __html: group.display_name_html }} />,
}}
/>
</Text>
</Stack>
);
/** Page to display a group. */ /** Page to display a group. */
const GroupPage: React.FC<IGroupPage> = ({ params, children }) => { const GroupPage: React.FC<IGroupPage> = ({ params, children }) => {
const intl = useIntl(); const intl = useIntl();
@ -97,9 +56,7 @@ const GroupPage: React.FC<IGroupPage> = ({ params, children }) => {
const { accounts: pending } = useGroupMembershipRequests(id); const { accounts: pending } = useGroupMembershipRequests(id);
const isMember = !!group?.relationship?.member; const isMember = !!group?.relationship?.member;
const isBlocked = group?.relationship?.blocked_by;
const isPrivate = group?.locked; const isPrivate = group?.locked;
const isDeleted = !!group?.deleted_at;
const tabItems = useMemo(() => { const tabItems = useMemo(() => {
const items = []; const items = [];
@ -127,12 +84,8 @@ const GroupPage: React.FC<IGroupPage> = ({ params, children }) => {
}, [pending.length, id]); }, [pending.length, id]);
const renderChildren = () => { const renderChildren = () => {
if (isDeleted) { if (!isMember && isPrivate) {
return <DeletedBlankslate />;
} else if (!isMember && isPrivate) {
return <PrivacyBlankslate />; return <PrivacyBlankslate />;
} else if (isBlocked) {
return <BlockedBlankslate group={group} />;
} else { } else {
return children; return children;
} }

View file

@ -3,14 +3,11 @@ import z from 'zod';
import { GroupRoles } from './group-member'; import { GroupRoles } from './group-member';
const groupRelationshipSchema = z.object({ const groupRelationshipSchema = z.object({
blocked_by: z.boolean().catch(false),
id: z.string(), id: z.string(),
member: z.boolean().catch(false), member: z.boolean().catch(false),
muting: z.boolean().nullable().catch(false),
notifying: z.boolean().nullable().catch(null),
pending_requests: z.boolean().catch(false),
requested: z.boolean().catch(false),
role: z.nativeEnum(GroupRoles).catch(GroupRoles.USER), role: z.nativeEnum(GroupRoles).catch(GroupRoles.USER),
requested: z.boolean().catch(false),
owner: z.boolean().catch(false),
}); });
type GroupRelationship = z.infer<typeof groupRelationshipSchema>; type GroupRelationship = z.infer<typeof groupRelationshipSchema>;

View file

@ -15,7 +15,6 @@ const groupSchema = z.object({
avatar: z.string().catch(avatarMissing), avatar: z.string().catch(avatarMissing),
avatar_static: z.string().catch(''), avatar_static: z.string().catch(''),
created_at: z.string().datetime().catch(new Date().toUTCString()), created_at: z.string().datetime().catch(new Date().toUTCString()),
deleted_at: z.string().datetime().or(z.null()).catch(null),
display_name: z.string().catch(''), display_name: z.string().catch(''),
domain: z.string().catch(''), domain: z.string().catch(''),
emojis: filteredArray(customEmojiSchema), emojis: filteredArray(customEmojiSchema),
@ -25,7 +24,7 @@ const groupSchema = z.object({
locked: z.boolean().catch(false), locked: z.boolean().catch(false),
membership_required: z.boolean().catch(false), membership_required: z.boolean().catch(false),
members_count: z.number().catch(0), members_count: z.number().catch(0),
owner: z.object({ id: z.string() }), owner: z.object({ id: z.string() }).nullable().catch(null),
note: z.string().transform(note => note === '<p></p>' ? '' : note).catch(''), note: z.string().transform(note => note === '<p></p>' ? '' : note).catch(''),
relationship: groupRelationshipSchema.nullable().catch(null), // Dummy field to be overwritten later relationship: groupRelationshipSchema.nullable().catch(null), // Dummy field to be overwritten later
source: z.object({ source: z.object({