From 2006485d606b43dffa29688b95121dae1dbfdd57 Mon Sep 17 00:00:00 2001 From: Krzysztof Gutkowski Date: Tue, 5 May 2026 12:49:24 +0200 Subject: [PATCH] Allow reporting users from their profile page (#36335) This PR refactors the report popover to have an optional confirmation message after completing the request. This was initially meant for #32584, but then I realized I can first test it out on the user profiles, so I've implemented it here as well. Can be reviewed commit by commit. https://github.com/user-attachments/assets/cd59c560-c824-4a5e-bab6-5ecbf5125af1 --------- Co-authored-by: Dean Herbert --- .../Visual/Online/TestSceneCommentActions.cs | 9 +- .../Visual/Online/TestSceneReportPopover.cs | 118 ++++++++ .../Graphics/UserInterfaceV2/ReportPopover.cs | 272 +++++++++++++----- .../Online/API/Requests/UserReportRequest.cs | 38 +++ osu.Game/Overlays/Chat/ReportChatPopover.cs | 29 +- .../Overlays/Comments/CommentReportButton.cs | 27 +- .../Overlays/Comments/ReportCommentPopover.cs | 13 +- .../Header/Components/UserActionsButton.cs | 51 +++- .../Overlays/Profile/ReportUserPopover.cs | 24 ++ osu.Game/Overlays/Profile/UserReportReason.cs | 26 ++ 10 files changed, 494 insertions(+), 113 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs create mode 100644 osu.Game/Online/API/Requests/UserReportRequest.cs create mode 100644 osu.Game/Overlays/Profile/ReportUserPopover.cs create mode 100644 osu.Game/Overlays/Profile/UserReportReason.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs index f47322b9e0..56b161db2a 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs @@ -253,6 +253,11 @@ namespace osu.Game.Tests.Visual.Online InputManager.MoveMouseTo(btn); InputManager.Click(MouseButton.Left); }); + AddStep("Set reason to other", () => + { + var reason = this.ChildrenOfType>().Single(); + reason.Current.Value = CommentReportReason.Other; + }); AddStep("Try to report", () => { var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); @@ -261,12 +266,10 @@ namespace osu.Game.Tests.Visual.Online }); AddWaitStep("Wait", 3); AddAssert("Nothing happened", () => this.ChildrenOfType().Any()); - AddStep("Set report data", () => + AddStep("Add comment", () => { var field = this.ChildrenOfType().Single().ChildrenOfType().First(); field.Current.Value = report_text; - var reason = this.ChildrenOfType>().Single(); - reason.Current.Value = CommentReportReason.Other; }); AddStep("Try to report", () => { diff --git a/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs b/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs new file mode 100644 index 0000000000..e2e90535d0 --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs @@ -0,0 +1,118 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using System.Net.Http; +using NUnit.Framework; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Testing; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Overlays.Chat; + +namespace osu.Game.Tests.Visual.Online +{ + public partial class TestSceneReportPopover : OsuTestScene + { + private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; + + private ReportPopoverContainer popover = null!; + + [SetUpSteps] + public void SetUp() + { + AddStep("create popover", () => + { + Child = new PopoverContainer + { + RelativeSizeAxes = Axes.Both, + Child = popover = new ReportPopoverContainer(), + }; + }); + } + + [Test] + public void TestSuccess() + { + ChatReportRequest pendingRequest = null!; + + AddStep("setup request handling", () => + { + dummyAPI.HandleRequest += request => + { + if (request is ChatReportRequest chatReportRequest) + { + pendingRequest = chatReportRequest; + return true; + } + + return false; + }; + }); + AddStep("show popover", () => popover.ShowPopover()); + AddStep("input reason", () => this.ChildrenOfType().First().Text = "reason"); + AddStep("send report", () => this.ChildrenOfType