From d2b3d37724a999d4cc78c46157593267e29d184e Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:18:00 +0200 Subject: [feature/frontend] Reports frontend v2 (#3022) * use apiutil + paging in admin processor+handlers * we're making it happen * fix little whoopsie * styling for report list * don't youuuu forget about meee don't don't don't don't * last bits * sanitize content before showing in report statuses * update report docs --- .../settings/views/moderation/reports/detail.tsx | 335 +++++++++++---------- .../settings/views/moderation/reports/overview.tsx | 97 ------ .../settings/views/moderation/reports/search.tsx | 252 ++++++++++++++++ 3 files changed, 420 insertions(+), 264 deletions(-) delete mode 100644 web/source/settings/views/moderation/reports/overview.tsx create mode 100644 web/source/settings/views/moderation/reports/search.tsx (limited to 'web/source/settings/views/moderation/reports') diff --git a/web/source/settings/views/moderation/reports/detail.tsx b/web/source/settings/views/moderation/reports/detail.tsx index ad8d69a47..7d6e542fb 100644 --- a/web/source/settings/views/moderation/reports/detail.tsx +++ b/web/source/settings/views/moderation/reports/detail.tsx @@ -17,8 +17,8 @@ along with this program. If not, see . */ -import React, { useState } from "react"; -import { useParams } from "wouter"; +import React from "react"; +import { useLocation, useParams } from "wouter"; import FormWithData from "../../../lib/form/form-with-data"; import BackButton from "../../../components/back-button"; import { useValue, useTextInput } from "../../../lib/form"; @@ -28,84 +28,172 @@ import MutationButton from "../../../components/form/mutation-button"; import Username from "../../../components/username"; import { useGetReportQuery, useResolveReportMutation } from "../../../lib/query/admin/reports"; import { useBaseUrl } from "../../../lib/navigation/util"; +import { AdminReport } from "../../../lib/types/report"; +import { yesOrNo } from "../../../lib/util"; +import { Status } from "../../../components/status"; export default function ReportDetail({ }) { + const params: { reportId: string } = useParams(); const baseUrl = useBaseUrl(); - const params = useParams(); + const backLocation: String = history.state?.backLocation ?? `~${baseUrl}`; return ( -
-

Report Details

+
+

Report Details

); } -function ReportDetailForm({ data: report }) { +function ReportDetailForm({ data: report }: { data: AdminReport }) { + const [ location ] = useLocation(); + const baseUrl = useBaseUrl(); + + return ( + <> + + + { report.action_taken + && + } + + { report.statuses && + + } + + { !report.action_taken && + + } + + ); +} + +interface ReportSectionProps { + report: AdminReport; + baseUrl: string; + location: string; +} + +function ReportBasicInfo({ report, baseUrl, location }: ReportSectionProps) { const from = report.account; const target = report.target_account; + const comment = report.comment; + const status = report.action_taken ? "Resolved" : "Unresolved"; + const created = new Date(report.created_at).toLocaleString(); return ( -
-
- - <> reported - +
+
+
Reported account
+
+ +
+
+ +
+
Reported by
+
+ +
- {report.action_taken && -
-

Resolved by @{report.action_taken_by_account.account.acct}

- at {new Date(report.action_taken_at).toLocaleString()} -
- Comment: {report.action_taken_comment} -
- } +
+
Status
+
+ { report.action_taken + ? <>{status} + : {status} + } +
+
-
-

Report info:

-
- Created: - {new Date(report.created_at).toLocaleString()} +
+
Reason
+
+ { comment.length > 0 + ? <>{comment} + : none provided + } +
+
- Forwarded: {report.forwarded ? "Yes" : "No"} - Category: {report.category} +
+
Created
+
+ +
+
- Reason: - {report.comment.length > 0 - ?

{report.comment}

- : none provided - } +
+
Category
+
{ report.category }
+
-
+
+
Forwarded
+
{ yesOrNo(report.forwarded) }
+
+ ); +} - {!report.action_taken && } - - { - report.statuses.length > 0 && -
-

Reported toots ({report.statuses.length}):

-
- {report.statuses.map((status) => ( - - ))} -
+function ReportHistory({ report, baseUrl, location }: ReportSectionProps) { + const handled_by = report.action_taken_by_account; + if (!handled_by) { + throw "report handled by action_taken_by_account undefined"; + } + + const handled = report.action_taken_at ? new Date(report.action_taken_at).toLocaleString() : "never"; + + return ( + <> +

Moderation History

+
+
+
Handled by
+
+ +
- } -
+ +
+
Handled
+
+ +
+
+ +
+
Comment
+
{ report.action_taken_comment ?? "none"}
+
+ + ); } @@ -118,13 +206,18 @@ function ReportActionForm({ report }) { const [submit, result] = useFormSubmit(form, useResolveReportMutation(), { changedOnly: false }); return ( -
-

Resolving this report

-

+ +

Resolve this report

+ <> An optional comment can be included while resolving this report. - Useful for providing an explanation about what action was taken (if any) before the report was marked as resolved.
- This will be visible to the user that created the report! -

+ This is useful for providing an explanation about what action was + taken (if any) before the report was marked as resolved. +
+ + Any comment made here will be visible + to the user that created the report! + +