1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:22:56 +08:00

Merge pull request #13318 from gagahpangeran/error-page-placeholder

Add error page placeholder for wiki overlay
This commit is contained in:
Dan Balasescu 2021-06-04 12:20:21 +09:00 committed by GitHub
commit 0ba493d598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Net;
using NUnit.Framework;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
@ -32,7 +33,14 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Show Article Page", () => wiki.ShowPage("Interface"));
}
private void setUpWikiResponse(APIWikiPage r)
[Test]
public void TestErrorPage()
{
setUpWikiResponse(null, true);
AddStep("Show Error Page", () => wiki.ShowPage("Error"));
}
private void setUpWikiResponse(APIWikiPage r, bool isFailed = false)
=> AddStep("set up response", () =>
{
dummyAPI.HandleRequest = request =>
@ -40,7 +48,11 @@ namespace osu.Game.Tests.Visual.Online
if (!(request is GetWikiRequest getWikiRequest))
return false;
getWikiRequest.TriggerSuccess(r);
if (isFailed)
getWikiRequest.TriggerFailure(new WebException());
else
getWikiRequest.TriggerSuccess(r);
return true;
};
});

View File

@ -92,7 +92,7 @@ namespace osu.Game.Overlays
Loading.Show();
request.Success += response => Schedule(() => onSuccess(response));
request.Failure += _ => Schedule(() => LoadDisplay(Empty()));
request.Failure += _ => Schedule(onFail);
api.PerformAsync(request);
}
@ -132,6 +132,24 @@ namespace osu.Game.Overlays
}
}
private void onFail()
{
LoadDisplay(new WikiMarkdownContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
CurrentPath = $@"{api.WebsiteRootUrl}/wiki/",
Text = $"Something went wrong when trying to fetch page \"{path.Value}\".\n\n[Return to the main page](Main_Page).",
DocumentMargin = new MarginPadding(0),
DocumentPadding = new MarginPadding
{
Vertical = 20,
Left = 30,
Right = 50,
},
});
}
private void showParentPage()
{
var parentPath = string.Join("/", path.Value.Split('/').SkipLast(1));