bigbuffet-rw/app/soapbox/features/admin/components/report-status.tsx

66 lines
1.9 KiB
TypeScript
Raw Normal View History

2022-04-28 11:28:08 -07:00
import React from 'react';
import { useIntl, defineMessages } from 'react-intl';
import { deleteStatusModal } from 'soapbox/actions/moderation';
import DropdownMenu from 'soapbox/components/dropdown-menu';
2022-11-15 08:00:49 -08:00
import StatusContent from 'soapbox/components/status-content';
2022-11-27 11:12:40 -08:00
import StatusMedia from 'soapbox/components/status-media';
import { HStack, Stack } from 'soapbox/components/ui';
2022-04-28 11:28:08 -07:00
import { useAppDispatch } from 'soapbox/hooks';
2022-11-27 11:12:40 -08:00
import type { AdminReport, Status } from 'soapbox/types/entities';
2022-04-28 11:28:08 -07:00
const messages = defineMessages({
viewStatus: { id: 'admin.reports.actions.view_status', defaultMessage: 'View post' },
deleteStatus: { id: 'admin.statuses.actions.delete_status', defaultMessage: 'Delete post' },
});
interface IReportStatus {
status: Status,
report?: AdminReport,
2022-04-28 11:28:08 -07:00
}
const ReportStatus: React.FC<IReportStatus> = ({ status }) => {
const intl = useIntl();
const dispatch = useAppDispatch();
const handleDeleteStatus = () => {
dispatch(deleteStatusModal(intl, status.id));
};
const makeMenu = () => {
const acct = status.getIn(['account', 'acct']);
return [{
text: intl.formatMessage(messages.viewStatus, { acct: `@${acct}` }),
to: `/@${acct}/posts/${status.id}`,
icon: require('@tabler/icons/pencil.svg'),
2022-04-28 11:28:08 -07:00
}, {
text: intl.formatMessage(messages.deleteStatus, { acct: `@${acct}` }),
action: handleDeleteStatus,
icon: require('@tabler/icons/trash.svg'),
2022-04-28 11:28:08 -07:00
destructive: true,
}];
};
const menu = makeMenu();
return (
2022-11-27 11:12:40 -08:00
<HStack space={2} alignItems='start'>
2022-11-28 07:41:19 -08:00
<Stack space={2} className='overflow-hidden' grow>
2022-04-28 11:28:08 -07:00
<StatusContent status={status} />
2022-11-27 11:12:40 -08:00
<StatusMedia status={status} />
</Stack>
2022-11-28 07:41:19 -08:00
<div className='flex-none'>
<DropdownMenu
items={menu}
src={require('@tabler/icons/dots-vertical.svg')}
/>
</div>
2022-11-27 11:12:40 -08:00
</HStack>
2022-04-28 11:28:08 -07:00
);
};
export default ReportStatus;