diff --git a/playwright/e2e/right-panel/right-panel.spec.ts b/playwright/e2e/right-panel/right-panel.spec.ts index 44b051c987..12b188c9e3 100644 --- a/playwright/e2e/right-panel/right-panel.spec.ts +++ b/playwright/e2e/right-panel/right-panel.spec.ts @@ -136,13 +136,30 @@ test.describe("RightPanel", () => { }); test.describe("room reporting", () => { test.skip(isDendrite, "Dendrite does not implement room reporting"); - test("should handle reporting a room", async ({ page, app }) => { + test("should handle reporting a room", { tag: "@screenshot" }, async ({ page, app }) => { await viewRoomSummaryByName(page, app, ROOM_NAME); + await page.getByRole("menuitem", { name: "Report room" }).click(); const dialog = await page.getByRole("dialog", { name: "Report Room" }); await dialog.getByLabel("reason").fill("This room should be reported"); + await expect(dialog).toMatchScreenshot("room-report-dialog.png"); await dialog.getByRole("button", { name: "Send report" }).click(); - await expect(page.getByText("Your report was sent.")).toBeVisible(); + + // Dialog should have gone + await expect(page.locator(".mx_Dialog")).toHaveCount(0); + }); + test("should handle reporting a room and leaving the room", async ({ page, app }) => { + await viewRoomSummaryByName(page, app, ROOM_NAME); + + await page.getByRole("menuitem", { name: "Report room" }).click(); + const dialog = await page.getByRole("dialog", { name: "Report room" }); + await dialog.getByRole("switch", { name: "Leave room" }).click(); + await dialog.getByLabel("reason").fill("This room should be reported"); + await dialog.getByRole("button", { name: "Send report" }).click(); + await page.getByRole("dialog", { name: "Leave room" }).getByRole("button", { name: "Leave" }).click(); + + // Dialog should have gone + await expect(page.locator(".mx_Dialog")).toHaveCount(0); }); }); }); diff --git a/playwright/snapshots/right-panel/right-panel.spec.ts/room-report-dialog-linux.png b/playwright/snapshots/right-panel/right-panel.spec.ts/room-report-dialog-linux.png new file mode 100644 index 0000000000..bfaf0e909e Binary files /dev/null and b/playwright/snapshots/right-panel/right-panel.spec.ts/room-report-dialog-linux.png differ diff --git a/playwright/snapshots/right-panel/right-panel.spec.ts/with-leave-room-linux.png b/playwright/snapshots/right-panel/right-panel.spec.ts/with-leave-room-linux.png index 931e9f9491..febb73c235 100644 Binary files a/playwright/snapshots/right-panel/right-panel.spec.ts/with-leave-room-linux.png and b/playwright/snapshots/right-panel/right-panel.spec.ts/with-leave-room-linux.png differ diff --git a/res/css/views/dialogs/_ReportRoomDialog.pcss b/res/css/views/dialogs/_ReportRoomDialog.pcss index 7323ac65c9..fc9d087de1 100644 --- a/res/css/views/dialogs/_ReportRoomDialog.pcss +++ b/res/css/views/dialogs/_ReportRoomDialog.pcss @@ -13,4 +13,9 @@ Please see LICENSE files in the repository root for full details. border-radius: 0.5rem; padding: var(--cpd-space-3x) var(--cpd-space-4x); } + + label { + color: var(--cpd-color-text-primary); + font-weight: var(--cpd-font-weight-semibold); + } } diff --git a/src/components/views/dialogs/ReportRoomDialog.tsx b/src/components/views/dialogs/ReportRoomDialog.tsx index 23a8334f41..2204153c0e 100644 --- a/src/components/views/dialogs/ReportRoomDialog.tsx +++ b/src/components/views/dialogs/ReportRoomDialog.tsx @@ -6,7 +6,7 @@ Please see LICENSE files in the repository root for full details. */ import React, { type JSX, type ChangeEventHandler, useCallback, useState } from "react"; -import { Root, Field, Label, InlineSpinner, ErrorMessage } from "@vector-im/compound-web"; +import { Root, Field, Label, InlineSpinner, ErrorMessage, HelpMessage } from "@vector-im/compound-web"; import { _t } from "../../../languageHandler"; import SdkConfig from "../../../SdkConfig"; @@ -14,10 +14,11 @@ import Markdown from "../../../Markdown"; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; import { MatrixClientPeg } from "../../../MatrixClientPeg"; +import LabelledToggleSwitch from "../elements/LabelledToggleSwitch"; interface IProps { roomId: string; - onFinished(complete: boolean): void; + onFinished(leave: boolean): void; } /* @@ -27,27 +28,26 @@ interface IProps { export const ReportRoomDialog: React.FC = function ({ roomId, onFinished }) { const [error, setErr] = useState(); const [busy, setBusy] = useState(false); - const [sent, setSent] = useState(false); const [reason, setReason] = useState(""); + const [leaveRoom, setLeaveRoom] = useState(false); const client = MatrixClientPeg.safeGet(); const onReasonChange = useCallback>((e) => setReason(e.target.value), []); - const onCancel = useCallback(() => onFinished(sent), [sent, onFinished]); + const onCancel = useCallback(() => onFinished(false), [onFinished]); const onSubmit = useCallback(async () => { setBusy(true); try { await client.reportRoom(roomId, reason); - setSent(true); + onFinished(leaveRoom); } catch (ex) { + setBusy(false); if (ex instanceof Error) { setErr(ex.message); } else { setErr("Unknown error"); } - } finally { - setBusy(false); } - }, [roomId, reason, client]); + }, [roomId, reason, client, leaveRoom, onFinished]); const adminMessageMD = SdkConfig.getObject("report_event")?.get("admin_message_md", "adminMessageMD"); let adminMessage: JSX.Element | undefined; @@ -59,37 +59,39 @@ export const ReportRoomDialog: React.FC = function ({ roomId, onFinished return ( onFinished(sent)} - title={_t("report_room|title")} + onFinished={onCancel} + title={_t("action|report_room")} contentId="mx_ReportEventDialog" > - {sent &&

{_t("report_room|sent")}

} - {!sent && ( - -

{_t("report_room|description")}

- {adminMessage} - - -