Maintenance page when in upgrade state (#13551)

* Added functionality to show maintenance page and fixed issues with showing custom api controllers and 404 page, when umbraco had been in install or upgrade state

* Fixed Tests

* Fixed typo

* Fixed issue with login screen redirecting to website when in upgrade state, instead of backoffice
This commit is contained in:
Bjarke Berg
2022-12-14 08:14:19 +01:00
committed by GitHub
parent fd7778320a
commit 2d564a11b9
12 changed files with 217 additions and 29 deletions

View File

@@ -41,13 +41,22 @@ public sealed class FrontEndRoutes : IAreaRoutes
/// <inheritdoc />
public void CreateRoutes(IEndpointRouteBuilder endpoints)
{
if (_runtimeState.Level != RuntimeLevel.Run)
switch (_runtimeState.Level)
{
return;
case RuntimeLevel.Install:
case RuntimeLevel.Upgrade:
case RuntimeLevel.Run:
AutoRouteSurfaceControllers(endpoints);
AutoRouteFrontEndApiControllers(endpoints);
break;
case RuntimeLevel.BootFailed:
case RuntimeLevel.Unknown:
case RuntimeLevel.Boot:
break;
}
AutoRouteSurfaceControllers(endpoints);
AutoRouteFrontEndApiControllers(endpoints);
}
/// <summary>

View File

@@ -117,9 +117,20 @@ public class UmbracoRouteValueTransformer : DynamicRouteValueTransformer
public override async ValueTask<RouteValueDictionary> TransformAsync(
HttpContext httpContext, RouteValueDictionary values)
{
// If we aren't running, then we have nothing to route
if (_runtime.Level != RuntimeLevel.Run)
// If we aren't running, then we have nothing to route. We allow the frontend to continue while in upgrade mode.
if (_runtime.Level != RuntimeLevel.Run && _runtime.Level != RuntimeLevel.Upgrade)
{
if (_runtime.Level == RuntimeLevel.Install)
{
return new RouteValueDictionary()
{
//TODO figure out constants
[ControllerToken] = "Install",
[ActionToken] = "Index",
[AreaToken] = Constants.Web.Mvc.InstallArea,
};
}
return null!;
}
@@ -184,6 +195,7 @@ public class UmbracoRouteValueTransformer : DynamicRouteValueTransformer
// our default 404 page but we cannot return route values now because
// it's possible that a developer is handling dynamic routes too.
// Our 404 page will be handled with the NotFoundSelectorPolicy
return null!;
}