Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
91 lines
2.9 KiB
TypeScript
91 lines
2.9 KiB
TypeScript
import { Box, Callout, Message, StatesAction, StatesActions, StatesIcon, StatesTitle } from '@rocket.chat/fuselage';
|
|
import { useStableCallback } from '@rocket.chat/fuselage-hooks';
|
|
import { ContextualbarFooter } from '@rocket.chat/ui-client';
|
|
import { useEndpoint } from '@rocket.chat/ui-contexts';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { Fragment } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import MessageContextFooter from './MessageContextFooter';
|
|
import ContextMessage from './helpers/ContextMessage';
|
|
import GenericNoResults from '../../../components/GenericNoResults';
|
|
|
|
// TODO: We should use Contextualbar components here
|
|
const UserMessages = ({ userId, onRedirect }: { userId: string; onRedirect: (mid: string) => void }) => {
|
|
const { t } = useTranslation();
|
|
const getUserMessages = useEndpoint('GET', '/v1/moderation.user.reportedMessages');
|
|
|
|
const {
|
|
data: report,
|
|
refetch: reloadUserMessages,
|
|
isLoading,
|
|
isSuccess,
|
|
isError,
|
|
} = useQuery({
|
|
queryKey: ['moderation', 'msgReports', 'fetchDetails', { userId }],
|
|
queryFn: async () => {
|
|
const messages = await getUserMessages({ userId });
|
|
return messages;
|
|
},
|
|
meta: {
|
|
apiErrorToastMessage: true,
|
|
},
|
|
});
|
|
|
|
const handleChange = useStableCallback(() => {
|
|
reloadUserMessages();
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<Box display='flex' flexDirection='column' width='full' height='full' overflowY='auto' overflowX='hidden'>
|
|
{isLoading && <Message>{t('Loading')}</Message>}
|
|
{isSuccess && (
|
|
<Box padding={24}>
|
|
{report.messages.length > 0 && (
|
|
<Callout title={t('Moderation_Duplicate_messages')} type='warning' icon='warning'>
|
|
{t('Moderation_Duplicate_messages_warning')}
|
|
</Callout>
|
|
)}
|
|
{!report.user && (
|
|
<Callout marginBlockStart={8} type='warning' icon='warning'>
|
|
{t('Moderation_User_deleted_warning')}
|
|
</Callout>
|
|
)}
|
|
</Box>
|
|
)}
|
|
{isSuccess &&
|
|
report.messages.length > 0 &&
|
|
report.messages.map((message) => (
|
|
<Fragment key={message._id}>
|
|
<ContextMessage
|
|
message={message.message}
|
|
room={message.room}
|
|
onRedirect={onRedirect}
|
|
onChange={handleChange}
|
|
deleted={!report.user}
|
|
/>
|
|
</Fragment>
|
|
))}
|
|
{isSuccess && report.messages.length === 0 && <GenericNoResults title={t('No_message_reports')} icon='message' />}
|
|
{isError && (
|
|
<Box display='flex' flexDirection='column' alignItems='center' paddingBlock={20} color='default'>
|
|
<StatesIcon name='warning' variation='danger' />
|
|
<StatesTitle>{t('Something_went_wrong')}</StatesTitle>
|
|
<StatesActions>
|
|
<StatesAction onClick={handleChange}>{t('Reload_page')}</StatesAction>
|
|
</StatesActions>
|
|
</Box>
|
|
)}
|
|
</Box>
|
|
{isSuccess && report.messages.length > 0 && (
|
|
<ContextualbarFooter>
|
|
<MessageContextFooter userId={userId} deleted={!report.user} />
|
|
</ContextualbarFooter>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default UserMessages;
|