From 10857d04909ea5d1b9e46eec73701b1e121663ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Thu, 18 Jan 2024 12:07:02 +0100 Subject: [PATCH 01/11] Upgrading to .NET 8 and OC 1.8.2 --- .../Lombiq.JsonEditor.Tests.UI.csproj | 2 +- Lombiq.JsonEditor/Controllers/AdminController.cs | 4 ++-- Lombiq.JsonEditor/Lombiq.JsonEditor.csproj | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj index c76204e..1225cd7 100644 --- a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj +++ b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 diff --git a/Lombiq.JsonEditor/Controllers/AdminController.cs b/Lombiq.JsonEditor/Controllers/AdminController.cs index ed8b29b..812aa96 100644 --- a/Lombiq.JsonEditor/Controllers/AdminController.cs +++ b/Lombiq.JsonEditor/Controllers/AdminController.cs @@ -1,4 +1,4 @@ -using AngleSharp.Common; +using AngleSharp.Common; using Lombiq.HelpfulLibraries.OrchardCore.Contents; using Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection; using Lombiq.JsonEditor.ViewModels; @@ -75,7 +75,7 @@ await _contentManager.GetAsync(contentItemId, VersionOptions.Latest) is not { } }); await _layoutAccessor.AddShapeToZoneAsync("Title", titleShape); - var definition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType); + var definition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType); return View(new EditContentItemViewModel(contentItem, definition, JsonConvert.SerializeObject(contentItem))); } diff --git a/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj b/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj index d737fa5..f0789e1 100644 --- a/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj +++ b/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj @@ -3,7 +3,7 @@ - net6.0 + net8.0 true $(DefaultItemExcludes);.git*;node_modules\**;Tests\** @@ -36,12 +36,12 @@ - - - - - - + + + + + + From 73f96ccce1f2398314612b2eb2cfea67afbc76f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Fri, 19 Jan 2024 14:06:47 +0100 Subject: [PATCH 02/11] Addressing warnings. --- Lombiq.JsonEditor/Manifest.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lombiq.JsonEditor/Manifest.cs b/Lombiq.JsonEditor/Manifest.cs index a2704cf..1b4da6d 100644 --- a/Lombiq.JsonEditor/Manifest.cs +++ b/Lombiq.JsonEditor/Manifest.cs @@ -14,11 +14,11 @@ Name = "Lombiq JSON Editor", Category = "Content", Description = "Module for displaying a JSON Editor like on jsoneditoronline.org.", - Dependencies = new[] - { + Dependencies = + [ "OrchardCore.Contents", "OrchardCore.ResourceManagement", - } + ] )] [assembly: Feature( @@ -26,8 +26,8 @@ Name = "Lombiq JSON Content Editor", Category = "Content", Description = "Adds an actions menu item to the content item list for editing them as JSON.", - Dependencies = new[] - { + Dependencies = + [ Default, - } + ] )] From 523249b3c2fde6c30003a5189a93b297a713cefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Sat, 20 Jan 2024 12:14:57 +0100 Subject: [PATCH 03/11] Addressing warnings. --- .../Controllers/AdminController.cs | 60 +++++++------------ ...EditJsonActionsMenuContentDisplayDriver.cs | 15 +---- .../Drivers/JsonFieldDisplayDriver.cs | 6 +- .../Settings/JsonFieldSettingsDriver.cs | 6 +- Lombiq.JsonEditor/Startup.cs | 6 +- .../TagHelpers/JsonEditorTagHelper.cs | 15 +---- 6 files changed, 32 insertions(+), 76 deletions(-) diff --git a/Lombiq.JsonEditor/Controllers/AdminController.cs b/Lombiq.JsonEditor/Controllers/AdminController.cs index 812aa96..4c95d23 100644 --- a/Lombiq.JsonEditor/Controllers/AdminController.cs +++ b/Lombiq.JsonEditor/Controllers/AdminController.cs @@ -23,39 +23,19 @@ namespace Lombiq.JsonEditor.Controllers; -public class AdminController : Controller +public class AdminController( + IContentDefinitionManager contentDefinitionManager, + ILayoutAccessor layoutAccessor, + INotifier notifier, + IPageTitleBuilder pageTitleBuilder, + IShapeFactory shapeFactory, + IOrchardServices services, + Lazy contentApiControllerLazy) : Controller { - private readonly IAuthorizationService _authorizationService; - private readonly IContentManager _contentManager; - private readonly IContentDefinitionManager _contentDefinitionManager; - private readonly ILayoutAccessor _layoutAccessor; - private readonly INotifier _notifier; - private readonly IPageTitleBuilder _pageTitleBuilder; - private readonly IShapeFactory _shapeFactory; - private readonly Lazy _contentApiControllerLazy; - private readonly IStringLocalizer T; - private readonly IHtmlLocalizer H; - - public AdminController( - IContentDefinitionManager contentDefinitionManager, - ILayoutAccessor layoutAccessor, - INotifier notifier, - IPageTitleBuilder pageTitleBuilder, - IShapeFactory shapeFactory, - IOrchardServices services, - Lazy contentApiControllerLazy) - { - _authorizationService = services.AuthorizationService.Value; - _contentManager = services.ContentManager.Value; - _contentDefinitionManager = contentDefinitionManager; - _layoutAccessor = layoutAccessor; - _notifier = notifier; - _pageTitleBuilder = pageTitleBuilder; - _shapeFactory = shapeFactory; - _contentApiControllerLazy = contentApiControllerLazy; - T = services.StringLocalizer.Value; - H = services.HtmlLocalizer.Value; - } + private readonly IAuthorizationService _authorizationService = services.AuthorizationService.Value; + private readonly IContentManager _contentManager = services.ContentManager.Value; + private readonly IStringLocalizer T = services.StringLocalizer.Value; + private readonly IHtmlLocalizer H = services.HtmlLocalizer.Value; public async Task Edit(string contentItemId) { @@ -67,15 +47,15 @@ await _contentManager.GetAsync(contentItemId, VersionOptions.Latest) is not { } } var title = T["Edit {0} as JSON", GetName(contentItem)].Value; - _pageTitleBuilder.AddSegment(new StringHtmlContent(title)); - var titleShape = await _shapeFactory.CreateAsync("TitlePart", model => + pageTitleBuilder.AddSegment(new StringHtmlContent(title)); + var titleShape = await shapeFactory.CreateAsync("TitlePart", model => { model.Title = title; model.ContentItem = contentItem; }); - await _layoutAccessor.AddShapeToZoneAsync("Title", titleShape); + await layoutAccessor.AddShapeToZoneAsync("Title", titleShape); - var definition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType); + var definition = await contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType); return View(new EditContentItemViewModel(contentItem, definition, JsonConvert.SerializeObject(contentItem))); } @@ -107,13 +87,13 @@ public async Task EditPost( { case BadRequestObjectResult { Value: ValidationProblemDetails details } when !string.IsNullOrWhiteSpace(details.Detail): - await _notifier.ErrorAsync(new LocalizedHtmlString(details.Detail, details.Detail)); + await notifier.ErrorAsync(new LocalizedHtmlString(details.Detail, details.Detail)); return await Edit(contentItem.ContentItemId); case OkObjectResult: - await _notifier.SuccessAsync(H["Content item {0} has been successfully saved.", GetName(contentItem)]); + await notifier.SuccessAsync(H["Content item {0} has been successfully saved.", GetName(contentItem)]); break; default: - await _notifier.ErrorAsync(H["The submission has failed, please try again."]); + await notifier.ErrorAsync(H["The submission has failed, please try again."]); return await Edit(contentItem.ContentItemId); } @@ -142,7 +122,7 @@ private async Task UpdateContentAsync(ContentItem contentItem, bo { // Here the API controller is called directly. The behavior is the same as if we sent a POST request using an // HTTP client (except the permission bypass above), but it's faster and more resource-efficient. - var contentApiController = _contentApiControllerLazy.Value; + var contentApiController = contentApiControllerLazy.Value; contentApiController.ControllerContext.HttpContext = HttpContext; return await contentApiController.Post(contentItem, isDraft); } diff --git a/Lombiq.JsonEditor/Drivers/EditJsonActionsMenuContentDisplayDriver.cs b/Lombiq.JsonEditor/Drivers/EditJsonActionsMenuContentDisplayDriver.cs index e744842..5a7d6db 100644 --- a/Lombiq.JsonEditor/Drivers/EditJsonActionsMenuContentDisplayDriver.cs +++ b/Lombiq.JsonEditor/Drivers/EditJsonActionsMenuContentDisplayDriver.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; @@ -10,19 +10,10 @@ namespace Lombiq.JsonEditor.Drivers; -public class EditJsonActionsMenuContentDisplayDriver : ContentDisplayDriver +public class EditJsonActionsMenuContentDisplayDriver(IAuthorizationService authorizationService, IHttpContextAccessor hca) : ContentDisplayDriver { - private readonly IAuthorizationService _authorizationService; - private readonly IHttpContextAccessor _hca; - - public EditJsonActionsMenuContentDisplayDriver(IAuthorizationService authorizationService, IHttpContextAccessor hca) - { - _authorizationService = authorizationService; - _hca = hca; - } - public override async Task DisplayAsync(ContentItem model, BuildDisplayContext context) => - await _authorizationService.AuthorizeAsync(_hca.HttpContext?.User, CommonPermissions.EditContent, model) + await authorizationService.AuthorizeAsync(hca.HttpContext?.User, CommonPermissions.EditContent, model) ? Initialize("Content_EditJsonActions", viewModel => viewModel.ContentItem = model.ContentItem) .Location("ActionsMenu:after") diff --git a/Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs b/Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs index 4ba1683..04bb497 100644 --- a/Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs +++ b/Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs @@ -11,11 +11,9 @@ namespace Lombiq.JsonEditor.Drivers; -public class JsonFieldDisplayDriver : ContentFieldDisplayDriver +public class JsonFieldDisplayDriver(IStringLocalizer stringLocalizer) : ContentFieldDisplayDriver { - private readonly IStringLocalizer T; - - public JsonFieldDisplayDriver(IStringLocalizer stringLocalizer) => T = stringLocalizer; + private readonly IStringLocalizer T = stringLocalizer; public override IDisplayResult Display(JsonField field, BuildFieldDisplayContext fieldDisplayContext) => Initialize(GetDisplayShapeType(fieldDisplayContext), model => diff --git a/Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs b/Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs index 4d5b3a4..85134c4 100644 --- a/Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs +++ b/Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs @@ -9,11 +9,9 @@ namespace Lombiq.JsonEditor.Settings; -public class JsonFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriver +public class JsonFieldSettingsDriver(IStringLocalizer stringLocalizer) : ContentPartFieldDefinitionDisplayDriver { - private readonly IStringLocalizer T; - - public JsonFieldSettingsDriver(IStringLocalizer stringLocalizer) => T = stringLocalizer; + private readonly IStringLocalizer T = stringLocalizer; public override IDisplayResult Edit(ContentPartFieldDefinition model) => Initialize($"{nameof(JsonFieldSettings)}_Edit", model.PopulateSettings) diff --git a/Lombiq.JsonEditor/Startup.cs b/Lombiq.JsonEditor/Startup.cs index eaad775..8fc660e 100644 --- a/Lombiq.JsonEditor/Startup.cs +++ b/Lombiq.JsonEditor/Startup.cs @@ -36,11 +36,9 @@ public override void ConfigureServices(IServiceCollection services) } [Feature(FeatureIds.ContentEditor)] -public class ContentEditorStartup : StartupBase +public class ContentEditorStartup(IOptions adminOptions) : StartupBase { - private readonly AdminOptions _adminOptions; - - public ContentEditorStartup(IOptions adminOptions) => _adminOptions = adminOptions.Value; + private readonly AdminOptions _adminOptions = adminOptions.Value; public override void ConfigureServices(IServiceCollection services) { diff --git a/Lombiq.JsonEditor/TagHelpers/JsonEditorTagHelper.cs b/Lombiq.JsonEditor/TagHelpers/JsonEditorTagHelper.cs index aa7e695..5290513 100644 --- a/Lombiq.JsonEditor/TagHelpers/JsonEditorTagHelper.cs +++ b/Lombiq.JsonEditor/TagHelpers/JsonEditorTagHelper.cs @@ -7,11 +7,8 @@ namespace Lombiq.JsonEditor.TagHelpers; [HtmlTargetElement("json-editor")] -public class JsonEditorTagHelper : TagHelper +public class JsonEditorTagHelper(IDisplayHelper displayHelper, IShapeFactory factory) : TagHelper { - private readonly IDisplayHelper _displayHelper; - private readonly IShapeFactory _shapeFactory; - [HtmlAttributeName("content")] public object Content { get; set; } @@ -24,20 +21,14 @@ public class JsonEditorTagHelper : TagHelper [HtmlAttributeName("name")] public string InputName { get; set; } - public JsonEditorTagHelper(IDisplayHelper displayHelper, IShapeFactory factory) - { - _displayHelper = displayHelper; - _shapeFactory = factory; - } - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - var shape = await _shapeFactory.New.JsonEditor( + var shape = await factory.New.JsonEditor( Content: Content, SerializedJson: SerializedJson, Options: Options, InputName: InputName); - var content = (IHtmlContent)await _displayHelper.ShapeExecuteAsync(shape); + var content = (IHtmlContent)await displayHelper.ShapeExecuteAsync(shape); output.TagName = null; output.TagMode = TagMode.StartTagAndEndTag; From 929466ffe187a20277a706d072fa5db7ff2d4ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Tue, 30 Jan 2024 11:33:44 +0100 Subject: [PATCH 04/11] Revert "Addressing warnings." This reverts commit 523249b3c2fde6c30003a5189a93b297a713cefe. --- .../Controllers/AdminController.cs | 60 ++++++++++++------- ...EditJsonActionsMenuContentDisplayDriver.cs | 15 ++++- .../Drivers/JsonFieldDisplayDriver.cs | 6 +- .../Settings/JsonFieldSettingsDriver.cs | 6 +- Lombiq.JsonEditor/Startup.cs | 6 +- .../TagHelpers/JsonEditorTagHelper.cs | 15 ++++- 6 files changed, 76 insertions(+), 32 deletions(-) diff --git a/Lombiq.JsonEditor/Controllers/AdminController.cs b/Lombiq.JsonEditor/Controllers/AdminController.cs index 4c95d23..812aa96 100644 --- a/Lombiq.JsonEditor/Controllers/AdminController.cs +++ b/Lombiq.JsonEditor/Controllers/AdminController.cs @@ -23,19 +23,39 @@ namespace Lombiq.JsonEditor.Controllers; -public class AdminController( - IContentDefinitionManager contentDefinitionManager, - ILayoutAccessor layoutAccessor, - INotifier notifier, - IPageTitleBuilder pageTitleBuilder, - IShapeFactory shapeFactory, - IOrchardServices services, - Lazy contentApiControllerLazy) : Controller +public class AdminController : Controller { - private readonly IAuthorizationService _authorizationService = services.AuthorizationService.Value; - private readonly IContentManager _contentManager = services.ContentManager.Value; - private readonly IStringLocalizer T = services.StringLocalizer.Value; - private readonly IHtmlLocalizer H = services.HtmlLocalizer.Value; + private readonly IAuthorizationService _authorizationService; + private readonly IContentManager _contentManager; + private readonly IContentDefinitionManager _contentDefinitionManager; + private readonly ILayoutAccessor _layoutAccessor; + private readonly INotifier _notifier; + private readonly IPageTitleBuilder _pageTitleBuilder; + private readonly IShapeFactory _shapeFactory; + private readonly Lazy _contentApiControllerLazy; + private readonly IStringLocalizer T; + private readonly IHtmlLocalizer H; + + public AdminController( + IContentDefinitionManager contentDefinitionManager, + ILayoutAccessor layoutAccessor, + INotifier notifier, + IPageTitleBuilder pageTitleBuilder, + IShapeFactory shapeFactory, + IOrchardServices services, + Lazy contentApiControllerLazy) + { + _authorizationService = services.AuthorizationService.Value; + _contentManager = services.ContentManager.Value; + _contentDefinitionManager = contentDefinitionManager; + _layoutAccessor = layoutAccessor; + _notifier = notifier; + _pageTitleBuilder = pageTitleBuilder; + _shapeFactory = shapeFactory; + _contentApiControllerLazy = contentApiControllerLazy; + T = services.StringLocalizer.Value; + H = services.HtmlLocalizer.Value; + } public async Task Edit(string contentItemId) { @@ -47,15 +67,15 @@ await _contentManager.GetAsync(contentItemId, VersionOptions.Latest) is not { } } var title = T["Edit {0} as JSON", GetName(contentItem)].Value; - pageTitleBuilder.AddSegment(new StringHtmlContent(title)); - var titleShape = await shapeFactory.CreateAsync("TitlePart", model => + _pageTitleBuilder.AddSegment(new StringHtmlContent(title)); + var titleShape = await _shapeFactory.CreateAsync("TitlePart", model => { model.Title = title; model.ContentItem = contentItem; }); - await layoutAccessor.AddShapeToZoneAsync("Title", titleShape); + await _layoutAccessor.AddShapeToZoneAsync("Title", titleShape); - var definition = await contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType); + var definition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType); return View(new EditContentItemViewModel(contentItem, definition, JsonConvert.SerializeObject(contentItem))); } @@ -87,13 +107,13 @@ public async Task EditPost( { case BadRequestObjectResult { Value: ValidationProblemDetails details } when !string.IsNullOrWhiteSpace(details.Detail): - await notifier.ErrorAsync(new LocalizedHtmlString(details.Detail, details.Detail)); + await _notifier.ErrorAsync(new LocalizedHtmlString(details.Detail, details.Detail)); return await Edit(contentItem.ContentItemId); case OkObjectResult: - await notifier.SuccessAsync(H["Content item {0} has been successfully saved.", GetName(contentItem)]); + await _notifier.SuccessAsync(H["Content item {0} has been successfully saved.", GetName(contentItem)]); break; default: - await notifier.ErrorAsync(H["The submission has failed, please try again."]); + await _notifier.ErrorAsync(H["The submission has failed, please try again."]); return await Edit(contentItem.ContentItemId); } @@ -122,7 +142,7 @@ private async Task UpdateContentAsync(ContentItem contentItem, bo { // Here the API controller is called directly. The behavior is the same as if we sent a POST request using an // HTTP client (except the permission bypass above), but it's faster and more resource-efficient. - var contentApiController = contentApiControllerLazy.Value; + var contentApiController = _contentApiControllerLazy.Value; contentApiController.ControllerContext.HttpContext = HttpContext; return await contentApiController.Post(contentItem, isDraft); } diff --git a/Lombiq.JsonEditor/Drivers/EditJsonActionsMenuContentDisplayDriver.cs b/Lombiq.JsonEditor/Drivers/EditJsonActionsMenuContentDisplayDriver.cs index 5a7d6db..e744842 100644 --- a/Lombiq.JsonEditor/Drivers/EditJsonActionsMenuContentDisplayDriver.cs +++ b/Lombiq.JsonEditor/Drivers/EditJsonActionsMenuContentDisplayDriver.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; @@ -10,10 +10,19 @@ namespace Lombiq.JsonEditor.Drivers; -public class EditJsonActionsMenuContentDisplayDriver(IAuthorizationService authorizationService, IHttpContextAccessor hca) : ContentDisplayDriver +public class EditJsonActionsMenuContentDisplayDriver : ContentDisplayDriver { + private readonly IAuthorizationService _authorizationService; + private readonly IHttpContextAccessor _hca; + + public EditJsonActionsMenuContentDisplayDriver(IAuthorizationService authorizationService, IHttpContextAccessor hca) + { + _authorizationService = authorizationService; + _hca = hca; + } + public override async Task DisplayAsync(ContentItem model, BuildDisplayContext context) => - await authorizationService.AuthorizeAsync(hca.HttpContext?.User, CommonPermissions.EditContent, model) + await _authorizationService.AuthorizeAsync(_hca.HttpContext?.User, CommonPermissions.EditContent, model) ? Initialize("Content_EditJsonActions", viewModel => viewModel.ContentItem = model.ContentItem) .Location("ActionsMenu:after") diff --git a/Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs b/Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs index 04bb497..4ba1683 100644 --- a/Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs +++ b/Lombiq.JsonEditor/Drivers/JsonFieldDisplayDriver.cs @@ -11,9 +11,11 @@ namespace Lombiq.JsonEditor.Drivers; -public class JsonFieldDisplayDriver(IStringLocalizer stringLocalizer) : ContentFieldDisplayDriver +public class JsonFieldDisplayDriver : ContentFieldDisplayDriver { - private readonly IStringLocalizer T = stringLocalizer; + private readonly IStringLocalizer T; + + public JsonFieldDisplayDriver(IStringLocalizer stringLocalizer) => T = stringLocalizer; public override IDisplayResult Display(JsonField field, BuildFieldDisplayContext fieldDisplayContext) => Initialize(GetDisplayShapeType(fieldDisplayContext), model => diff --git a/Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs b/Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs index 85134c4..4d5b3a4 100644 --- a/Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs +++ b/Lombiq.JsonEditor/Settings/JsonFieldSettingsDriver.cs @@ -9,9 +9,11 @@ namespace Lombiq.JsonEditor.Settings; -public class JsonFieldSettingsDriver(IStringLocalizer stringLocalizer) : ContentPartFieldDefinitionDisplayDriver +public class JsonFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriver { - private readonly IStringLocalizer T = stringLocalizer; + private readonly IStringLocalizer T; + + public JsonFieldSettingsDriver(IStringLocalizer stringLocalizer) => T = stringLocalizer; public override IDisplayResult Edit(ContentPartFieldDefinition model) => Initialize($"{nameof(JsonFieldSettings)}_Edit", model.PopulateSettings) diff --git a/Lombiq.JsonEditor/Startup.cs b/Lombiq.JsonEditor/Startup.cs index 8fc660e..eaad775 100644 --- a/Lombiq.JsonEditor/Startup.cs +++ b/Lombiq.JsonEditor/Startup.cs @@ -36,9 +36,11 @@ public override void ConfigureServices(IServiceCollection services) } [Feature(FeatureIds.ContentEditor)] -public class ContentEditorStartup(IOptions adminOptions) : StartupBase +public class ContentEditorStartup : StartupBase { - private readonly AdminOptions _adminOptions = adminOptions.Value; + private readonly AdminOptions _adminOptions; + + public ContentEditorStartup(IOptions adminOptions) => _adminOptions = adminOptions.Value; public override void ConfigureServices(IServiceCollection services) { diff --git a/Lombiq.JsonEditor/TagHelpers/JsonEditorTagHelper.cs b/Lombiq.JsonEditor/TagHelpers/JsonEditorTagHelper.cs index 5290513..aa7e695 100644 --- a/Lombiq.JsonEditor/TagHelpers/JsonEditorTagHelper.cs +++ b/Lombiq.JsonEditor/TagHelpers/JsonEditorTagHelper.cs @@ -7,8 +7,11 @@ namespace Lombiq.JsonEditor.TagHelpers; [HtmlTargetElement("json-editor")] -public class JsonEditorTagHelper(IDisplayHelper displayHelper, IShapeFactory factory) : TagHelper +public class JsonEditorTagHelper : TagHelper { + private readonly IDisplayHelper _displayHelper; + private readonly IShapeFactory _shapeFactory; + [HtmlAttributeName("content")] public object Content { get; set; } @@ -21,14 +24,20 @@ public class JsonEditorTagHelper(IDisplayHelper displayHelper, IShapeFactory fac [HtmlAttributeName("name")] public string InputName { get; set; } + public JsonEditorTagHelper(IDisplayHelper displayHelper, IShapeFactory factory) + { + _displayHelper = displayHelper; + _shapeFactory = factory; + } + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - var shape = await factory.New.JsonEditor( + var shape = await _shapeFactory.New.JsonEditor( Content: Content, SerializedJson: SerializedJson, Options: Options, InputName: InputName); - var content = (IHtmlContent)await displayHelper.ShapeExecuteAsync(shape); + var content = (IHtmlContent)await _displayHelper.ShapeExecuteAsync(shape); output.TagName = null; output.TagMode = TagMode.StartTagAndEndTag; From 00fb9f515bf9b5db6b7a20f2d9be5a60a19fcef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Thu, 1 Feb 2024 17:48:54 +0100 Subject: [PATCH 05/11] Adding form-label. --- Lombiq.JsonEditor/Views/JsonField.Edit.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.JsonEditor/Views/JsonField.Edit.cshtml b/Lombiq.JsonEditor/Views/JsonField.Edit.cshtml index 5056bca..7ca9237 100644 --- a/Lombiq.JsonEditor/Views/JsonField.Edit.cshtml +++ b/Lombiq.JsonEditor/Views/JsonField.Edit.cshtml @@ -10,7 +10,7 @@ }
- + Date: Fri, 16 Feb 2024 17:27:51 +0100 Subject: [PATCH 06/11] Using issue branch reference. --- .github/workflows/publish-nuget.yml | 2 +- Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj | 2 +- Lombiq.JsonEditor/Lombiq.JsonEditor.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 4b26cfc..8360fd9 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -7,6 +7,6 @@ on: jobs: publish-nuget: - uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev + uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OSOE-751 secrets: API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }} diff --git a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj index 1225cd7..01f3207 100644 --- a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj +++ b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj @@ -21,7 +21,7 @@ - + diff --git a/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj b/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj index f0789e1..6122bf9 100644 --- a/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj +++ b/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj @@ -50,7 +50,7 @@ - + From 975639660091a8f3917a5f8a48634da52ad1c3fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Sat, 17 Feb 2024 10:53:59 +0100 Subject: [PATCH 07/11] Using alpha. --- Lombiq.JsonEditor/Lombiq.JsonEditor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj b/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj index 6122bf9..1d0e315 100644 --- a/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj +++ b/Lombiq.JsonEditor/Lombiq.JsonEditor.csproj @@ -51,7 +51,7 @@ - + From 1d32858f42aa30aa8c423519f086b585a258247f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Sun, 18 Feb 2024 14:11:37 +0100 Subject: [PATCH 08/11] Using alphas. --- Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj index 01f3207..01573a4 100644 --- a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj +++ b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj @@ -21,7 +21,7 @@ - + From 8e187aaa090f93f3f9bbdd0acec9182d88adb9a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Tue, 20 Feb 2024 10:08:21 +0100 Subject: [PATCH 09/11] Updating UITT alpha. --- Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj index 01573a4..8582ebf 100644 --- a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj +++ b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj @@ -21,7 +21,7 @@ - + From 717ae2a3dd2e6e2178c4c3c37e00cde3ce820ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Wed, 21 Feb 2024 12:06:26 +0100 Subject: [PATCH 10/11] Using new UITT alpha. --- Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj index 8582ebf..da8703f 100644 --- a/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj +++ b/Lombiq.JsonEditor.Test.UI/Lombiq.JsonEditor.Tests.UI.csproj @@ -21,7 +21,7 @@ - + From 18e19f6b9bb383c9065c4d9552a1c2638ec7a208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20M=C3=A1rkus?= Date: Wed, 21 Feb 2024 16:24:34 +0100 Subject: [PATCH 11/11] Reverting to dev reference. --- .github/workflows/publish-nuget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 8360fd9..4b26cfc 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -7,6 +7,6 @@ on: jobs: publish-nuget: - uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OSOE-751 + uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev secrets: API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }}