Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-751: Upgrade to Orchard Core 1.8 #160

Merged
merged 46 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c57ba17
Upgrading to .NET 8 and OC 1.8.2
Psichorex Jan 18, 2024
d845d84
Addressing warnings.
Psichorex Jan 19, 2024
c7e6731
Addressing warnings.
Psichorex Jan 20, 2024
a41d98e
Addressing warnings.
Psichorex Jan 20, 2024
425acc0
Addressing warnings.
Psichorex Jan 20, 2024
857e19d
Addressing warnings.
Psichorex Jan 20, 2024
f170b6c
Adding DecoratedResourceManager
Psichorex Jan 27, 2024
d0f85aa
Renaming.
Psichorex Jan 27, 2024
98d268a
Resolving jQuery not being registered prior to its user script.
Psichorex Jan 27, 2024
646c223
Updating ResourceManagerDecorator.
Psichorex Jan 28, 2024
c2004e8
Adding summary.
Psichorex Jan 28, 2024
71068ed
Keeping H.
Psichorex Jan 29, 2024
943ac57
Keeping T.
Psichorex Jan 29, 2024
ac6bf26
Keeping T.
Psichorex Jan 29, 2024
a857043
Keeping H.
Psichorex Jan 29, 2024
43545cc
Keeping H.
Psichorex Jan 29, 2024
bb5e8d3
Removing field.
Psichorex Jan 29, 2024
d2dc72a
Removing field.
Psichorex Jan 29, 2024
4cecd5a
Removing field.
Psichorex Jan 29, 2024
480e3dc
Removing field.
Psichorex Jan 29, 2024
8c35cf6
Removing field.
Psichorex Jan 29, 2024
a25607f
Keeping T.
Psichorex Jan 29, 2024
f946d0c
Merge remote-tracking branch 'origin/dev' into issue/OSOE-751
Psichorex Jan 29, 2024
761ef56
Merge remote-tracking branch 'origin/dev' into issue/OSOE-751
Psichorex Jan 30, 2024
edc7f6b
Revert "Addressing warnings."This reverts commit c7e673188b8bf5a278f1…
Psichorex Jan 30, 2024
ca914d8
Fix.
Psichorex Jan 30, 2024
8e2511d
Fix.
Psichorex Jan 30, 2024
c7e6e84
Fixes.
Psichorex Jan 30, 2024
6d6b049
Making ResourceManagerDecorator easier to update
Piedone Feb 1, 2024
0635547
Optimization
Piedone Feb 1, 2024
4bf30c3
Update Lombiq.HelpfulExtensions/Extensions/SiteTexts/Services/SiteTex…
Psichorex Feb 1, 2024
235f271
Moving decorator to BaseTheme.
Psichorex Feb 1, 2024
efc2dad
Merge branch 'issue/OSOE-751' of https://github.com/Lombiq/Helpful-Ex…
Psichorex Feb 1, 2024
6bbbc89
Addressing ctor logic.
Psichorex Feb 1, 2024
895bade
Adding directive.
Psichorex Feb 1, 2024
e61f9a2
Minor fixing.
Psichorex Feb 1, 2024
437f57c
Adding form-label.
Psichorex Feb 1, 2024
5481622
Removing supresses.
Psichorex Feb 5, 2024
8048da7
Upgrading alpha of Tests.UI.
Psichorex Feb 16, 2024
0ee41ad
Upgrading alpha of HelpfulLibraries.
Psichorex Feb 16, 2024
fce006c
Upgrading publish-nuget branch reference.
Psichorex Feb 16, 2024
f6c6265
Using alpha.
Psichorex Feb 17, 2024
3deab83
Updating UITT with latest Atata.
Psichorex Feb 18, 2024
90387bc
Using new UITT alpha.
Psichorex Feb 20, 2024
cc2d664
Using new UITT alpha.
Psichorex Feb 21, 2024
e39c494
Reverting to dev reference.
Psichorex Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
</PropertyGroup>

Expand Down
17 changes: 4 additions & 13 deletions Lombiq.HelpfulExtensions/Controllers/ContentSetController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Services;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Services;
using Microsoft.AspNetCore.Mvc;
using OrchardCore;
using OrchardCore.Modules;
Expand All @@ -7,19 +7,10 @@
namespace Lombiq.HelpfulExtensions.Extensions.ContentSets.Controllers;

[Feature(FeatureIds.ContentSets)]
public class ContentSetController : Controller
public class ContentSetController(IContentSetManager contentSetManager, IOrchardHelper orchardHelper) : Controller
{
private readonly IContentSetManager _contentSetManager;
private readonly IOrchardHelper _orchardHelper;

public ContentSetController(IContentSetManager contentSetManager, IOrchardHelper orchardHelper)
{
_contentSetManager = contentSetManager;
_orchardHelper = orchardHelper;
}

public async Task<IActionResult> Create(string fromContentItemId, string fromPartName, string newKey) =>
await _contentSetManager.CloneContentItemAsync(fromContentItemId, fromPartName, newKey) is { } content
? Redirect(_orchardHelper.GetItemEditUrl(content))
await contentSetManager.CloneContentItemAsync(fromContentItemId, fromPartName, newKey) is { } content
? Redirect(orchardHelper.GetItemEditUrl(content))
: NotFound();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AngleSharp.Io;
using AngleSharp.Io;
using Lombiq.HelpfulExtensions.Extensions.OrchardRecipeMigration.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -16,21 +16,11 @@ namespace Lombiq.HelpfulExtensions.Extensions.OrchardRecipeMigration.Controllers

[Admin]
[Feature(FeatureIds.OrchardRecipeMigration)]
public class OrchardRecipeMigrationAdminController : Controller
public class OrchardRecipeMigrationAdminController(
INotifier notifier,
IOrchardExportToRecipeConverter converter,
IHtmlLocalizer<OrchardRecipeMigrationAdminController> localizer) : Controller
{
private readonly INotifier _notifier;
private readonly IOrchardExportToRecipeConverter _converter;
private readonly IHtmlLocalizer<OrchardRecipeMigrationAdminController> H;
public OrchardRecipeMigrationAdminController(
INotifier notifier,
IOrchardExportToRecipeConverter converter,
IHtmlLocalizer<OrchardRecipeMigrationAdminController> localizer)
{
_notifier = notifier;
_converter = converter;
H = localizer;
}

public IActionResult Index() => View();

[HttpPost]
Expand All @@ -46,16 +36,16 @@ public async Task<IActionResult> Convert(IFormFile file)
}
catch (Exception)
{
await _notifier.ErrorAsync(H["Please add a file to import."]);
await notifier.ErrorAsync(localizer["Please add a file to import."]);
return Redirect(nameof(Index));
}

await using (stream)
{
json = await _converter.ConvertAsync(XDocument.Load(stream));
json = await converter.ConvertAsync(XDocument.Load(stream));
}

Response.Headers.Add("Content-Disposition", "attachment;filename=export.recipe.json");
Response.Headers.Append("Content-Disposition", "attachment;filename=export.recipe.json");
return Content(json, MimeTypeNames.ApplicationJson, Encoding.UTF8);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@

namespace Lombiq.HelpfulExtensions.Extensions.CodeGeneration;

public class CodeGenerationDisplayDriver : ContentTypeDefinitionDisplayDriver
public class CodeGenerationDisplayDriver(IStringLocalizer<CodeGenerationDisplayDriver> stringLocalizer)
: ContentTypeDefinitionDisplayDriver
{
private readonly IStringLocalizer T;

public CodeGenerationDisplayDriver(IStringLocalizer<CodeGenerationDisplayDriver> stringLocalizer) =>
T = stringLocalizer;
private readonly IStringLocalizer T = stringLocalizer;

public override IDisplayResult Edit(ContentTypeDefinition model) =>
Initialize<ContentTypeMigrationsViewModel>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Events;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Events;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Models;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Services;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.ViewModels;
using Lombiq.HelpfulLibraries.OrchardCore.Contents;
using Microsoft.Extensions.Localization;
using Newtonsoft.Json.Linq;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
Expand All @@ -15,44 +14,31 @@

namespace Lombiq.HelpfulExtensions.Extensions.ContentSets.Drivers;

public class ContentSetContentPickerFieldDisplayDriver : ContentFieldDisplayDriver<ContentSetContentPickerField>
public class ContentSetContentPickerFieldDisplayDriver(
IContentDefinitionManager contentDefinitionManager,
IContentSetManager contentSetManager,
IEnumerable<IContentSetEventHandler> contentSetEventHandlers,
IStringLocalizer<ContentSetPart> stringLocalizer) : ContentFieldDisplayDriver<ContentSetContentPickerField>
{
private readonly IContentDefinitionManager _contentDefinitionManager;
private readonly IContentSetManager _contentSetManager;
private readonly IEnumerable<IContentSetEventHandler> _contentSetEventHandlers;
private readonly IStringLocalizer<ContentSetPart> T;

public ContentSetContentPickerFieldDisplayDriver(
IContentDefinitionManager contentDefinitionManager,
IContentSetManager contentSetManager,
IEnumerable<IContentSetEventHandler> contentSetEventHandlers,
IStringLocalizer<ContentSetPart> stringLocalizer)
{
_contentDefinitionManager = contentDefinitionManager;
_contentSetManager = contentSetManager;
_contentSetEventHandlers = contentSetEventHandlers;
T = stringLocalizer;
}

public override IDisplayResult Display(
ContentSetContentPickerField field,
BuildFieldDisplayContext fieldDisplayContext)
{
var name = fieldDisplayContext.PartFieldDefinition.Name;
if (field.ContentItem.Get<ContentSetPart>(name) is not { } part) return null;

return Initialize<ContentSetContentPickerFieldViewModel>(GetDisplayShapeType(fieldDisplayContext), model =>
return Initialize<ContentSetContentPickerFieldViewModel>(GetDisplayShapeType(fieldDisplayContext), async model =>
{
model.PartFieldDefinition = fieldDisplayContext.PartFieldDefinition;
return model.InitializeAsync(
_contentSetManager,
_contentSetEventHandlers,
T,
await model.InitializeAsync(
contentSetManager,
contentSetEventHandlers,
stringLocalizer,
part,
new ContentTypePartDefinition(
name,
_contentDefinitionManager.GetPartDefinition(nameof(ContentSetPart)),
new JObject()),
await contentDefinitionManager.GetPartDefinitionAsync(nameof(ContentSetPart)),
[]),
isNew: false);
})
.Location(CommonContentDisplayTypes.Detail, CommonLocationNames.Content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,21 @@

namespace Lombiq.HelpfulExtensions.Extensions.ContentSets.Drivers;

public class ContentSetPartDisplayDriver : ContentPartDisplayDriver<ContentSetPart>
public class ContentSetPartDisplayDriver(
IContentSetManager contentSetManager,
IIdGenerator idGenerator,
IEnumerable<IContentSetEventHandler> contentSetEventHandlers,
IStringLocalizer<ContentSetPart> stringLocalizer) : ContentPartDisplayDriver<ContentSetPart>
{
private const string ShapeType = $"{nameof(ContentSetPart)}_{CommonContentDisplayTypes.SummaryAdmin}";

private readonly IContentSetManager _contentSetManager;
private readonly IIdGenerator _idGenerator;
private readonly IEnumerable<IContentSetEventHandler> _contentSetEventHandlers;
private readonly IStringLocalizer<ContentSetPart> T;

public ContentSetPartDisplayDriver(
IContentSetManager contentSetManager,
IIdGenerator idGenerator,
IEnumerable<IContentSetEventHandler> contentSetEventHandlers,
IStringLocalizer<ContentSetPart> stringLocalizer)
{
_contentSetManager = contentSetManager;
_idGenerator = idGenerator;
_contentSetEventHandlers = contentSetEventHandlers;
T = stringLocalizer;
}

public override IDisplayResult Display(ContentSetPart part, BuildPartDisplayContext context)
{
ValueTask InitializeAsync(ContentSetPartViewModel model) =>
model.InitializeAsync(
_contentSetManager,
_contentSetEventHandlers,
T,
contentSetManager,
contentSetEventHandlers,
stringLocalizer,
part,
context.TypePartDefinition,
isNew: false);
Expand All @@ -56,9 +43,9 @@ ValueTask InitializeAsync(ContentSetPartViewModel model) =>

public override IDisplayResult Edit(ContentSetPart part, BuildPartEditorContext context) =>
Initialize<ContentSetPartViewModel>($"{nameof(ContentSetPart)}_Edit", model => model.InitializeAsync(
_contentSetManager,
_contentSetEventHandlers,
T,
contentSetManager,
contentSetEventHandlers,
stringLocalizer,
part,
context.TypePartDefinition,
context.IsNew))
Expand All @@ -79,7 +66,7 @@ public override async Task<IDisplayResult> UpdateAsync(
// item has not been saved yet.
if (string.IsNullOrEmpty(part.ContentSet))
{
part.ContentSet = _idGenerator.GenerateUniqueId();
part.ContentSet = idGenerator.GenerateUniqueId();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Models;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Models;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Metadata;
Expand Down Expand Up @@ -27,25 +27,17 @@ public static ContentSetIndex FromPart(ContentSetPart part, string partName) =>
};
}

public class ContentSetIndexProvider : IndexProvider<ContentItem>
public class ContentSetIndexProvider(IServiceProvider provider) : IndexProvider<ContentItem>
{
private readonly IServiceProvider _provider;

// We can't inject Lazy<IContentDefinitionManager> because it will throw a "Cannot resolve scoped service
// 'OrchardCore.ContentManagement.Metadata.IContentDefinitionManager' from root provider." exception.
public ContentSetIndexProvider(IServiceProvider provider) =>
_provider = provider;

public override void Describe(DescribeContext<ContentItem> context) =>
context.For<ContentSetIndex>().Map(contentItem =>
context.For<ContentSetIndex>().Map(async contentItem =>
{
if (!contentItem.Latest) return Enumerable.Empty<ContentSetIndex>();

using var scope = _provider.CreateScope();
using var scope = provider.CreateScope();
var contentDefinitionManager = scope.ServiceProvider.GetRequiredService<IContentDefinitionManager>();

return contentDefinitionManager
.GetTypeDefinition(contentItem.ContentType)
return (await contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType))
.Parts
.Where(part => part.PartDefinition.Name == nameof(ContentSetPart))
.Select(part => new { Part = contentItem.Get<ContentSetPart>(part.Name), part.Name })
Expand Down
16 changes: 6 additions & 10 deletions Lombiq.HelpfulExtensions/Extensions/ContentSets/Migrations.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Indexes;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Indexes;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Models;
using Lombiq.HelpfulLibraries.OrchardCore.Data;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
using System.Threading.Tasks;
using YesSql.Sql;

namespace Lombiq.HelpfulExtensions.Extensions.ContentSets;

public class Migrations : DataMigration
public class Migrations(IContentDefinitionManager contentDefinitionManager) : DataMigration
{
private readonly IContentDefinitionManager _contentDefinitionManager;

public Migrations(IContentDefinitionManager contentDefinitionManager) =>
_contentDefinitionManager = contentDefinitionManager;

public int Create()
public async Task<int> CreateAsync()
{
_contentDefinitionManager.AlterPartDefinition(nameof(ContentSetPart), builder => builder
await contentDefinitionManager.AlterPartDefinitionAsync(nameof(ContentSetPart), builder => builder
.Attachable()
.Reusable()
.WithDisplayName("Content Set"));

SchemaBuilder.CreateMapIndexTable<ContentSetIndex>(table => table
await SchemaBuilder.CreateMapIndexTableAsync<ContentSetIndex>(table => table
.Column<string>(nameof(ContentSetIndex.ContentItemId), column => column.WithCommonUniqueIdLength())
.Column<string>(nameof(ContentSetIndex.PartName))
.Column<bool>(nameof(ContentSetIndex.IsPublished))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using OrchardCore.ContentManagement;
using System.Diagnostics.CodeAnalysis;
using OrchardCore.ContentManagement;

namespace Lombiq.HelpfulExtensions.Extensions.ContentSets.Models;

[SuppressMessage(
"Minor Code Smell",
"S2094:Classes should not be empty",
Justification = "Only data we need is the field name.")]
public class ContentSetContentPickerField : ContentField
{
}
Loading