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 all 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 Expand Up @@ -37,7 +37,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests.UI" Version="8.1.0-alpha.1.osoe-638" />
<PackageReference Include="Lombiq.Tests.UI" Version="8.2.1-alpha.22.osoe-751" />
</ItemGroup>

</Project>
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 Down Expand Up @@ -55,7 +55,7 @@ public async Task<IActionResult> Convert(IFormFile file)
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
@@ -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 Down Expand Up @@ -41,18 +40,18 @@ public override IDisplayResult Display(
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(
await model.InitializeAsync(
_contentSetManager,
_contentSetEventHandlers,
T,
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
@@ -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 @@ -37,15 +37,14 @@ 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();
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
9 changes: 5 additions & 4 deletions Lombiq.HelpfulExtensions/Extensions/ContentSets/Migrations.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
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;
Expand All @@ -15,14 +16,14 @@ public class Migrations : DataMigration
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
{
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Events;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Events;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Indexes;
using Lombiq.HelpfulExtensions.Extensions.ContentSets.Models;
using OrchardCore.ContentManagement;
Expand Down Expand Up @@ -58,8 +58,7 @@ await _contentManager.CloneAsync(original) is not { } content)
part.Key = newKey;
});

var contentTypePartDefinition = _contentDefinitionManager
.GetTypeDefinition(content.ContentType)
var contentTypePartDefinition = (await _contentDefinitionManager.GetTypeDefinitionAsync(content.ContentType))
.Parts
.Single(definition => definition.Name == fromPartName);

Expand Down
15 changes: 8 additions & 7 deletions Lombiq.HelpfulExtensions/Extensions/ContentTypes/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
using System.Threading.Tasks;
using static Lombiq.HelpfulExtensions.Extensions.ContentTypes.ContentTypes;

namespace Lombiq.HelpfulExtensions.Extensions.ContentTypes;
Expand All @@ -13,9 +14,9 @@ public class Migrations : DataMigration
public Migrations(IContentDefinitionManager contentDefinitionManager) =>
_contentDefinitionManager = contentDefinitionManager;

public int Create()
public async Task<int> CreateAsync()
{
_contentDefinitionManager.AlterTypeDefinition(Page, builder => builder
await _contentDefinitionManager.AlterTypeDefinitionAsync(Page, builder => builder
.Creatable()
.Securable()
.Draftable()
Expand All @@ -33,16 +34,16 @@ public int Create()
.WithPart("FlowPart", part => part.WithPosition("2"))
);

_contentDefinitionManager.AlterTypeDefinition(Empty, builder => builder
await _contentDefinitionManager.AlterTypeDefinitionAsync(Empty, builder => builder
.WithDescription("A base content type for ad-hoc welding parts or fields on.")
);

return 3;
}

public int UpdateFrom1()
public async Task<int> UpdateFrom1Async()
{
_contentDefinitionManager.AlterTypeDefinition(Page, builder => builder
await _contentDefinitionManager.AlterTypeDefinitionAsync(Page, builder => builder
.WithPart("TitlePart", part => part.WithPosition("0"))
.WithPart("AutoroutePart", part => part.WithPosition("1"))
.WithPart("FlowPart", part => part.WithPosition("2"))
Expand All @@ -51,9 +52,9 @@ public int UpdateFrom1()
return 2;
}

public int UpdateFrom2()
public async Task<int> UpdateFrom2Async()
{
_contentDefinitionManager.AlterTypeDefinition(Empty, builder => builder
await _contentDefinitionManager.AlterTypeDefinitionAsync(Empty, builder => builder
.WithDescription("A base content type for ad-hoc welding parts or fields on.")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ public class AdditionalStylingPartHandler : ContentHandlerBase
public AdditionalStylingPartHandler(IContentDefinitionManager contentDefinitionManager) =>
_contentDefinitionManager = contentDefinitionManager;

public override Task ActivatedAsync(ActivatedContentContext context)
public override async Task ActivatedAsync(ActivatedContentContext context)
{
if (!context.ContentItem.Has<AdditionalStylingPart>() &&
_contentDefinitionManager.GetTypeDefinition(context.ContentItem.ContentType)
(await _contentDefinitionManager.GetTypeDefinitionAsync(context.ContentItem.ContentType))
.GetSettings<ContentTypeSettings>().Stereotype == "Widget")
{
context.ContentItem.Weld<AdditionalStylingPart>();
}

return Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Lombiq.HelpfulExtensions.Extensions.OrchardRecipeMigration.Controllers;
using Lombiq.HelpfulExtensions.Extensions.OrchardRecipeMigration.Controllers;
using Lombiq.HelpfulLibraries.OrchardCore.Navigation;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Localization;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using System;
using System.Threading.Tasks;

namespace Lombiq.HelpfulExtensions.Extensions.OrchardRecipeMigration.Navigation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public class OrchardExportToRecipeConverter : IOrchardExportToRecipeConverter
private readonly IEnumerable<IOrchardExportConverter> _exportConverters;
private readonly IEnumerable<IOrchardContentConverter> _contentConverters;
private readonly IEnumerable<IOrchardUserConverter> _userConverters;

private readonly ICollection<string> _contentTypes;
private readonly IContentDefinitionManager _contentDefinitionManager;

public OrchardExportToRecipeConverter(
IContentDefinitionManager contentDefinitionManager,
Expand All @@ -35,21 +34,20 @@ public OrchardExportToRecipeConverter(
_exportConverters = exportConverters;
_contentConverters = contentConverters;
_userConverters = userConverters;

_contentTypes = contentDefinitionManager
.ListTypeDefinitions()
.Select(definition => definition.Name)
.ToList();
_contentDefinitionManager = contentDefinitionManager;
}

public async Task<string> ConvertAsync(XDocument export)
{
var contentItems = new List<ContentItem>();
var contents = export.XPathSelectElement("//Content")?.Elements() ?? Enumerable.Empty<XElement>();
var contentTypes = (await _contentDefinitionManager.ListTypeDefinitionsAsync())
.Select(definition => definition.Name)
.ToList();

foreach (var content in contents)
{
if (await CreateContentItemAsync(content) is { } contentItem)
if (await CreateContentItemAsync(content, contentTypes) is { } contentItem)
{
contentItem.ContentItemId ??= _idGenerator.GenerateUniqueId();
contentItem.ContentItemVersionId ??= _idGenerator.GenerateUniqueId();
Expand Down Expand Up @@ -80,7 +78,7 @@ await _contentConverters
return recipe.ToString();
}

private async Task<ContentItem> CreateContentItemAsync(XElement content)
private async Task<ContentItem> CreateContentItemAsync(XElement content, List<string> contentTypes)
{
foreach (var converter in _contentConverters.OrderBy(converter => converter.Order))
{
Expand All @@ -90,7 +88,7 @@ private async Task<ContentItem> CreateContentItemAsync(XElement content)
}
}

return _contentTypes.Contains(content.Name.LocalName)
return contentTypes.Contains(content.Name.LocalName)
? await _contentManager.NewAsync(content.Name.LocalName)
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using OrchardCore.Users.Models;
using OrchardCore.Users.Services;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using static Lombiq.HelpfulLibraries.OrchardCore.Users.PasswordHelper;
Expand Down Expand Up @@ -30,7 +29,7 @@ public async Task ImportAsync(XElement element)
return;

var roles = element.Element("UserRolesPart").Attribute("Roles")?.Value;
var rolesList = string.IsNullOrEmpty(roles) ? new List<string>() : roles.Split(',').ToList();
var rolesList = string.IsNullOrEmpty(roles) ? new List<string>() : [.. roles.Split(',')];

await _userService.CreateUserAsync(
new User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ public class StrictSecurityPermissionAuthorizationHandler : AuthorizationHandler
public StrictSecurityPermissionAuthorizationHandler(IContentDefinitionManager contentDefinitionManager) =>
_contentDefinitionManager = contentDefinitionManager;

protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement)
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement)
{
if ((context.Resource as IContent)?.ContentItem is not { } contentItem ||
!_permissionTemplates.TryGetValue(requirement.Permission.Name, out var claims) ||
_contentDefinitionManager.GetTypeDefinition(contentItem.ContentType) is not { } definition ||
await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType) is not { } definition ||
definition.GetSettings<StrictSecuritySettings>()?.Enabled != true)
{
return Task.CompletedTask;
return;
}

if (!context.User.Identity.IsAuthenticated)
{
context.Fail();
return Task.CompletedTask;
return;
}

var contentType = contentItem.ContentType;
Expand All @@ -54,7 +54,6 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte
.Select(claim => claim.Value);

if (!permissionNames.Any(claims.Contains)) context.Fail();
return Task.CompletedTask;
}

private static IList<string> GetPermissionTemplates(Permission permission, IList<string> templates)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void AddIfNotNullOrEmpty(string name, string value)
}
}

if (shapeMetadata.Alternates.Any())
if (shapeMetadata.Alternates.Count != 0)
{
builder.AppendHtml("Alternates: ");
builder.AppendHtmlLine(string.Join(", ", shapeMetadata.Alternates));
Expand All @@ -49,7 +49,7 @@ void AddIfNotNullOrEmpty(string name, string value)
builder.AppendHtmlLine(string.Join(", ", shapeMetadata.BindingSources));
}

if (shapeMetadata.Wrappers.Any())
if (shapeMetadata.Wrappers.Count != 0)
{
builder.AppendHtml("Wrappers: ");
builder.AppendHtmlLine(string.Join(", ", shapeMetadata.Wrappers));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using OrchardCore.ContentLocalization.Models;
using OrchardCore.ContentLocalization.Models;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.Data.Migration;
using System.Threading.Tasks;
using static Lombiq.HelpfulExtensions.Extensions.SiteTexts.Constants.ContentTypes;

namespace Lombiq.HelpfulExtensions.Extensions.SiteTexts;
Expand All @@ -12,9 +13,9 @@ public class LocalizationMigrations : DataMigration
public LocalizationMigrations(IContentDefinitionManager contentDefinitionManager) =>
_contentDefinitionManager = contentDefinitionManager;

public int Create()
public async Task<int> CreateAsync()
{
_contentDefinitionManager.AlterTypeDefinition(SiteText, builder => builder
await _contentDefinitionManager.AlterTypeDefinitionAsync(SiteText, builder => builder
.WithPart(nameof(LocalizationPart)));

return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected async Task<HtmlString> RenderMarkdownAsync(string markdown)

// If it's a single-line expression, then it's presumably inline so don't wrap it in a <p> element.
if (doc.Body is { ChildElementCount: 1, FirstElementChild: { } first } &&
first.TagName.ToUpperInvariant() == "P")
first.TagName.EqualsOrdinalIgnoreCase("P"))
{
html = first.InnerHtml.Trim();
}
Expand Down
Loading