Skip to content

Commit

Permalink
Use AdminRouteAttributeRouteMapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Feb 4, 2024
1 parent e1fbd4f commit 1d828df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Lombiq.JsonEditor/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AngleSharp.Common;
using Lombiq.HelpfulLibraries.OrchardCore.Contents;
using Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection;
using Lombiq.HelpfulLibraries.OrchardCore.Mvc;
using Lombiq.JsonEditor.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -57,6 +58,7 @@ public AdminController(
H = services.HtmlLocalizer.Value;
}

[AdminRoute("Contents/ContentItems/{contentItemId}/Edit/Json")]
public async Task<IActionResult> Edit(string contentItemId)
{
if (string.IsNullOrWhiteSpace(contentItemId) ||
Expand Down
9 changes: 2 additions & 7 deletions Lombiq.JsonEditor/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection;
using Lombiq.HelpfulLibraries.OrchardCore.Mvc;
using Lombiq.JsonEditor.Constants;
using Lombiq.JsonEditor.Drivers;
using Lombiq.JsonEditor.Fields;
Expand Down Expand Up @@ -48,12 +49,6 @@ public override void ConfigureServices(IServiceCollection services)
services.AddOrchardServices();
services.AddScoped<ApiController>();
services.AddContentSecurityPolicyProvider<JsonEditorContentSecurityPolicyProvider>();
AdminRouteAttributeRouteMapper.AddToServices(services);
}

public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) =>
routes.MapAreaControllerRoute(
name: "EditContentItem",
areaName: FeatureIds.Area,
pattern: _adminOptions.AdminUrlPrefix + "/Contents/ContentItems/{contentItemId}/Edit/Json",
defaults: new { controller = typeof(AdminController).ControllerName(), action = nameof(AdminController.Edit) });
}

0 comments on commit 1d828df

Please sign in to comment.