From 83b522a1b651fd20e45755c2ad0a0a124395fbd4 Mon Sep 17 00:00:00 2001 From: f0x52 Date: Mon, 6 Feb 2023 09:33:47 +0100 Subject: [PATCH] [feature/Frogend] basic report admin interface (#1424) * basic listing of reports * report detail overview, resolving * report detail styling tweaks * linter fixes --- web/source/settings/admin/reports/detail.jsx | 234 ++++++++++++++++++ web/source/settings/admin/reports/index.jsx | 112 +++++++++ .../settings/admin/reports/username.jsx | 54 ++++ web/source/settings/index.js | 1 + web/source/settings/lib/query/admin/index.js | 3 +- .../settings/lib/query/admin/reports.js | 52 ++++ web/source/settings/lib/query/base.js | 2 +- web/source/settings/style.css | 119 +++++++++ 8 files changed, 575 insertions(+), 2 deletions(-) create mode 100644 web/source/settings/admin/reports/detail.jsx create mode 100644 web/source/settings/admin/reports/index.jsx create mode 100644 web/source/settings/admin/reports/username.jsx create mode 100644 web/source/settings/lib/query/admin/reports.js diff --git a/web/source/settings/admin/reports/detail.jsx b/web/source/settings/admin/reports/detail.jsx new file mode 100644 index 000000000..20548a720 --- /dev/null +++ b/web/source/settings/admin/reports/detail.jsx @@ -0,0 +1,234 @@ +/* + GoToSocial + Copyright (C) 2021-2023 GoToSocial Authors admin@gotosocial.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +"use strict"; + +const React = require("react"); +const { useRoute, Redirect } = require("wouter"); + +const query = require("../../lib/query"); + +const FormWithData = require("../../lib/form/form-with-data"); +const BackButton = require("../../components/back-button"); + +const { useValue, useTextInput } = require("../../lib/form"); +const useFormSubmit = require("../../lib/form/submit"); + +const { TextArea } = require("../../components/form/inputs"); + +const MutationButton = require("../../components/form/mutation-button"); +const Username = require("./username"); + +module.exports = function ReportDetail({ baseUrl }) { + let [_match, params] = useRoute(`${baseUrl}/:reportId`); + if (params?.reportId == undefined) { + return ; + } else { + return ( +
+

+ Report Details +

+ +
+ ); + } +}; + +function ReportDetailForm({ data: report }) { + const from = report.account; + const target = report.target_account; + + return ( +
+
+ reported +
+ + {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} +
+ } + +
+

Report info:

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

{report.comment}

+ : none provided + } + +
+
+ + {!report.action_taken && } + + { + report.statuses.length > 0 && +
+

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

+
+ {report.statuses.map((status) => ( + + ))} +
+
+ } +
+ ); +} + +function ReportActionForm({ report }) { + const form = { + id: useValue("id", report.id), + comment: useTextInput("action_taken_comment") + }; + + const [submit, result] = useFormSubmit(form, query.useResolveReportMutation(), { changedOnly: false }); + + return ( +
+

Resolving 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! +

+