Skip to content

Commit

Permalink
OCC-160: Upgrade to Orchard Core 1.6 (#308)
Browse files Browse the repository at this point in the history
* Updating Orchard Core versions and other NuGet packages related to Orchard Core.

* Adding interface implementation

* Changing parameter name instance to part in order to match the identifier

* Updating Ids

* Updating Ids

* Using queryselector instead of specific id selector
  • Loading branch information
wAsnk authored Jun 19, 2023
1 parent bafc437 commit 1272a87
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Indexing.Abstractions" Version="1.5.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.5.0" />
<PackageReference Include="OrchardCore.Indexing.Abstractions" Version="1.6.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -44,7 +44,7 @@
<ProjectReference Include="$(LombiqHelpfulLibrariesPath)" />
</ItemGroup>
<ItemGroup Condition="!Exists($(LombiqHelpfulLibrariesPath))">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="5.2.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="6.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.ContentFields" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.5.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.6.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.6.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.6.0" />
</ItemGroup>

<PropertyGroup>
Expand All @@ -41,7 +41,7 @@
<ProjectReference Include="$(LombiqHelpfulLibrariesPath)" />
</ItemGroup>
<ItemGroup Condition="!Exists($(LombiqHelpfulLibrariesPath))">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="5.2.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="6.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Module.Targets" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.5.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.6.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Module.Targets" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.5.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.6.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ window.initializeToggleSecondAddress = function (
};

(function autoInitializeToggleSecondAddress() {
if (document.getElementById('UserAddressesPart_BillingAndShippingAddressesMatch_Value')) {
if (document.querySelector('[id$=UserAddressesPart_BillingAndShippingAddressesMatch_Value]')) {
initializeToggleSecondAddress(
document.getElementById('UserAddressesPart_BillingAndShippingAddressesMatch_Value'),
document.querySelector('[id$=UserAddressesPart_BillingAndShippingAddressesMatch_Value]'),
document.querySelector('.address_billing-address'),
document.querySelector('.address_shipping-address'));
}

if (document.getElementById('OrderPart_BillingAndShippingAddressesMatch_Value')) {
if (document.querySelector('[id$=OrderPart_BillingAndShippingAddressesMatch_Value]')) {
initializeToggleSecondAddress(
document.getElementById('OrderPart_BillingAndShippingAddressesMatch_Value'),
document.querySelector('[id$=OrderPart_BillingAndShippingAddressesMatch_Value]'),
document.querySelector('.address_billing-address'),
document.querySelector('.address_shipping-address'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public DiscountPartHandler(
T = stringLocalizer;
}

public override Task UpdatedAsync(UpdateContentContext context, DiscountPart instance)
public override Task UpdatedAsync(UpdateContentContext context, DiscountPart part)
{
if (instance.ContentItem.As<DiscountPart>() is not { } discountPart) return Task.CompletedTask;
if (part.ContentItem.As<DiscountPart>() is not { } discountPart) return Task.CompletedTask;

var discountPercentage = discountPart.DiscountPercentage?.Value ?? 0;
var discountAmount = discountPart.DiscountAmount.Amount;
Expand All @@ -42,10 +42,10 @@ public override Task UpdatedAsync(UpdateContentContext context, DiscountPart ins
InvalidateEvenState();
}

if ((instance.ContentItem.As<PricePart>()?.Price is { } pricePartPrice &&
if ((part.ContentItem.As<PricePart>()?.Price is { } pricePartPrice &&
pricePartPrice.Currency.Equals(discountAmount.Currency) &&
pricePartPrice < discountAmount) ||
(instance.ContentItem.As<TaxPart>()?.GrossPrice.Amount is { } taxPartGrossPriceAmount &&
(part.ContentItem.As<TaxPart>()?.GrossPrice.Amount is { } taxPartGrossPriceAmount &&
taxPartGrossPriceAmount.IsValid &&
taxPartGrossPriceAmount.Currency.Equals(discountAmount.Currency) &&
taxPartGrossPriceAmount < discountAmount))
Expand Down
16 changes: 8 additions & 8 deletions src/Modules/OrchardCore.Commerce/Handlers/PricePartHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public PricePartHandler(IMoneyService moneyService, ISession session)
_session = session;
}

public override Task LoadingAsync(LoadContentContext context, PricePart instance)
public override Task LoadingAsync(LoadContentContext context, PricePart part)
{
var amount = _moneyService.EnsureCurrency(instance.Price);
instance.Price = amount;
var amount = _moneyService.EnsureCurrency(part.Price);
part.Price = amount;

// Migrate objects to use PriceField instead of PricePart.Amount.
if (instance.Content.Price is { } price && instance.Content.PriceField?.Amount.ToString() != price.ToString())
if (part.Content.Price is { } price && part.Content.PriceField?.Amount.ToString() != price.ToString())
{
instance.Content.PriceField = JObject.FromObject(new PriceField { Amount = amount });
((JObject)instance.Content).Remove(nameof(PricePart.Price));
part.Content.PriceField = JObject.FromObject(new PriceField { Amount = amount });
((JObject)part.Content).Remove(nameof(PricePart.Price));

_session.Save(instance.ContentItem);
_session.Save(part.ContentItem);
}

return base.LoadingAsync(context, instance);
return base.LoadingAsync(context, part);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ public class PriceVariantsPartHandler : ContentPartHandler<PriceVariantsPart>

public PriceVariantsPartHandler(IMoneyService moneyService) => _moneyService = moneyService;

public override Task LoadingAsync(LoadContentContext context, PriceVariantsPart instance)
public override Task LoadingAsync(LoadContentContext context, PriceVariantsPart part)
{
if (instance.Variants != null)
if (part.Variants != null)
{
foreach (var variantKey in instance.Variants.Keys)
foreach (var variantKey in part.Variants.Keys)
{
instance.Variants[variantKey] = _moneyService.EnsureCurrency(instance.Variants[variantKey]);
part.Variants[variantKey] = _moneyService.EnsureCurrency(part.Variants[variantKey]);
}
}

return base.LoadingAsync(context, instance);
return base.LoadingAsync(context, part);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ public SkuValidationHandler(
_updateModelAccessor = updateModelAccessor;
}

public override async Task UpdatedAsync(UpdateContentContext context, ProductPart instance)
public override async Task UpdatedAsync(UpdateContentContext context, ProductPart part)
{
if (string.IsNullOrWhiteSpace(instance.Sku))
if (string.IsNullOrWhiteSpace(part.Sku))
{
_updateModelAccessor.ModelUpdater.ModelState.AddModelError(nameof(instance.Sku), "SKU must not be empty.");
_updateModelAccessor.ModelUpdater.ModelState.AddModelError(nameof(part.Sku), "SKU must not be empty.");
return;
}

var isProductSkuAlreadyExisting = await _session
.Query<ContentItem, ProductPartIndex>(index =>
index.Sku == instance.Sku &&
index.ContentItemId != instance.ContentItem.ContentItemId)
index.Sku == part.Sku &&
index.ContentItemId != part.ContentItem.ContentItemId)
.CountAsync() > 0;

if (isProductSkuAlreadyExisting)
{
_updateModelAccessor.ModelUpdater.ModelState.AddModelError(
nameof(instance.Sku),
nameof(part.Sku),
"SKU must be unique. A product with the given SKU already exists.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public TaxPartAndPricePartHandler(
T = stringLocalizer;
}

public override Task UpdatedAsync(UpdateContentContext context, PricePart instance)
public override Task UpdatedAsync(UpdateContentContext context, PricePart part)
{
if (instance.ContentItem.As<TaxPart>() is not { } taxPart) return Task.CompletedTask;
if (part.ContentItem.As<TaxPart>() is not { } taxPart) return Task.CompletedTask;

var taxRate = taxPart.TaxRate?.Value ?? 0;

Expand All @@ -43,7 +43,7 @@ public override Task UpdatedAsync(UpdateContentContext context, PricePart instan

if (isGrossPricePresent && isTaxRatePresent)
{
UpdatePricePart(instance.ContentItem, taxPart.GrossPrice.Amount, taxRate);
UpdatePricePart(part.ContentItem, taxPart.GrossPrice.Amount, taxRate);
}
else if (isGrossPricePresent ^ isTaxRatePresent)
{
Expand Down
22 changes: 11 additions & 11 deletions src/Modules/OrchardCore.Commerce/OrchardCore.Commerce.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.ContentFields" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentTypes" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="1.5.0" />
<PackageReference Include="OrchardCore.Html" Version="1.5.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.5.0" />
<PackageReference Include="OrchardCore.Navigation.Core" Version="1.5.0" />
<PackageReference Include="OrchardCore.Title" Version="1.5.0" />
<PackageReference Include="OrchardCore.Templates" Version="1.5.0" />
<PackageReference Include="OrchardCore.Workflows.Abstractions" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.6.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.6.0" />
<PackageReference Include="OrchardCore.ContentTypes" Version="1.6.0" />
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="1.6.0" />
<PackageReference Include="OrchardCore.Html" Version="1.6.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.6.0" />
<PackageReference Include="OrchardCore.Navigation.Core" Version="1.6.0" />
<PackageReference Include="OrchardCore.Title" Version="1.6.0" />
<PackageReference Include="OrchardCore.Templates" Version="1.6.0" />
<PackageReference Include="OrchardCore.Workflows.Abstractions" Version="1.6.0" />
<PackageReference Include="Stripe.net" Version="41.18.0" />
</ItemGroup>

Expand All @@ -58,7 +58,7 @@
<Import Project="..\..\..\..\..\Utilities\Lombiq.NodeJs.Extensions\Lombiq.NodeJs.Extensions\Lombiq.NodeJs.Extensions.targets" />
</ImportGroup>
<ItemGroup Condition="!Exists($(LombiqNodeJsExtensionsPath))">
<PackageReference Include="Lombiq.NodeJs.Extensions" Version="1.2.3" />
<PackageReference Include="Lombiq.NodeJs.Extensions" Version="1.2.4" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/OrchardCore.Commerce.Web/OrchardCore.Commerce.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</ItemGroup> -->

<ItemGroup>
<PackageReference Include="Lombiq.Tests.UI.Shortcuts" Version="6.0.1" />
<PackageReference Include="OrchardCore.Application.Cms.Targets" Version="1.5.0" />
<PackageReference Include="OrchardCore.Logging.NLog" Version="1.5.0" />
<PackageReference Include="Lombiq.Tests.UI.Shortcuts" Version="7.0.0" />
<PackageReference Include="OrchardCore.Application.Cms.Targets" Version="1.6.0" />
<PackageReference Include="OrchardCore.Logging.NLog" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Module.Targets" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentManagement.Abstractions" Version="1.5.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.6.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.6.0" />
<PackageReference Include="OrchardCore.ContentManagement.Abstractions" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -29,7 +29,7 @@
<ProjectReference Include="$(LombiqHelpfulLibrariesPath)" />
</ItemGroup>
<ItemGroup Condition="!Exists($(LombiqHelpfulLibrariesPath))">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="5.2.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="6.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Lombiq.Tests.UI" Version="6.0.1" />
<PackageReference Include="Lombiq.Tests.UI.AppExtensions" Version="6.0.1" />
<PackageReference Include="Lombiq.Tests.UI" Version="7.0.0" />
<PackageReference Include="Lombiq.Tests.UI.AppExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ await context.ClickReliablyOnAsync(By.XPath(

const string testCustomerName = "Test Customer Name";
await context.ClickAndFillInWithRetriesAsync(
By.Id("UserAddressesPart_BillingAddress_Address_Name"),
By.Id("User_UserAddressesPart_BillingAddress_Address_Name"),
testCustomerName);
await context.SetCheckboxValueAsync(
By.Id("UserAddressesPart_BillingAndShippingAddressesMatch_Value"),
By.Id("User_UserAddressesPart_BillingAndShippingAddressesMatch_Value"),
isChecked: true);

await SubmitAndGoToUserAddressesAsync();

context
.Get(By.Id("UserAddressesPart_ShippingAddress_Address_Name").OfAnyVisibility())
.Get(By.Id("User_UserAddressesPart_ShippingAddress_Address_Name").OfAnyVisibility())
.GetAttribute("value")?
.Trim()
.ShouldBe(testCustomerName);
Expand Down
3 changes: 3 additions & 0 deletions test/OrchardCore.Commerce.Tests/Fakes/FakeContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public Task<ContentValidateResult> CreateContentItemVersionAsync(ContentItem con
public Task<IEnumerable<ContentItem>> GetAsync(IEnumerable<string> contentItemIds, bool latest = false) =>
throw new NotSupportedException();

public Task<IEnumerable<ContentItem>> GetAsync(IEnumerable<string> contentItemIds, VersionOptions options) =>
throw new NotSupportedException();

public Task<ContentItem> GetVersionAsync(string contentItemVersionId) => throw new NotSupportedException();

public Task ImportAsync(IEnumerable<ContentItem> contentItems) => throw new NotSupportedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.1" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.5.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.6.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down

0 comments on commit 1272a87

Please sign in to comment.