diff --git a/apps/web/src/app/page/[slug]/components/PublicPageView/PublicPageView.tsx b/apps/web/src/app/page/[slug]/components/PublicPageView/PublicPageView.tsx index 80f479905c4..cc41ab7b88f 100644 --- a/apps/web/src/app/page/[slug]/components/PublicPageView/PublicPageView.tsx +++ b/apps/web/src/app/page/[slug]/components/PublicPageView/PublicPageView.tsx @@ -6,6 +6,7 @@ import { PageFrame } from "@superset/ui/page-comments"; import { Globe } from "lucide-react"; import Link from "next/link"; import { OpenInSupersetButton } from "../OpenInSupersetButton"; +import { ReportPageDialog } from "./components/ReportPageDialog"; interface PublicPageViewProps { title: string; @@ -30,7 +31,8 @@ export function PublicPageView({ aria-label={t({ message: "Shared with everyone" })} /> {title} -
+
+ {signedIn ? ( ) : ( @@ -51,6 +53,13 @@ export function PublicPageView({
+ +
+ + This page was published by a Superset user. Its contents are + unverified. + +
); } diff --git a/apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/ReportPageDialog.tsx b/apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/ReportPageDialog.tsx new file mode 100644 index 00000000000..043597d6586 --- /dev/null +++ b/apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/ReportPageDialog.tsx @@ -0,0 +1,195 @@ +"use client"; + +import { useLingui as useTranslation } from "@lingui/react"; +import { Trans, useLingui } from "@lingui/react/macro"; +import type { PageReportReason } from "@superset/db/enums"; +import { errorMessage } from "@superset/i18n/errors"; +import { Button } from "@superset/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@superset/ui/dialog"; +import { Input } from "@superset/ui/input"; +import { Label } from "@superset/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@superset/ui/select"; +import { Textarea } from "@superset/ui/textarea"; +import { useMutation } from "@tanstack/react-query"; +import { Flag } from "lucide-react"; +import { useState } from "react"; +import { useTRPC } from "@/trpc/react"; +import { REPORT_REASONS } from "./constants"; + +interface ReportPageDialogProps { + slug: string; + signedIn: boolean; +} + +export function ReportPageDialog({ slug, signedIn }: ReportPageDialogProps) { + const { t } = useLingui(); + const { _: translate } = useTranslation(); + const trpc = useTRPC(); + const [open, setOpen] = useState(false); + const [reason, setReason] = useState(""); + const [details, setDetails] = useState(""); + const [email, setEmail] = useState(""); + + const report = useMutation(trpc.page.report.mutationOptions()); + + const reset = () => { + setReason(""); + setDetails(""); + setEmail(""); + report.reset(); + }; + + const submit = () => { + if (!reason) return; + report.mutate({ + slug, + reason, + details: details.trim() || undefined, + reporterEmail: !signedIn && email.trim() ? email.trim() : undefined, + }); + }; + + return ( + { + setOpen(next); + if (!next) reset(); + }} + > + + + + + {report.isSuccess ? ( + <> + + + Thanks, we got it + + + + Someone on the Superset team will review this page. We only + follow up if we need more from you. + + + + + + + + ) : ( + <> + + + Report this page + + + + Tell us what is wrong with it. Reporting does not remove the + page on its own. + + + + +
+
+ + +
+ +
+ +