Skip to content

Commit

Permalink
Merge pull request #174 from Lombiq/issue/OSOE-893
Browse files Browse the repository at this point in the history
OSOE-893: Fix breaking changes
  • Loading branch information
sarahelsaig authored Aug 9, 2024
2 parents 32e8bee + b3575d6 commit a379d58
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests.UI" Version="10.0.2-alpha.1.occ-245" />
<PackageReference Include="Lombiq.Tests.UI" Version="10.0.2-alpha.2.osoe-893" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
using System;
using System.Collections.Generic;
Expand All @@ -22,7 +23,7 @@ public class CodeGenerationDisplayDriver : ContentTypeDefinitionDisplayDriver
public CodeGenerationDisplayDriver(IStringLocalizer<CodeGenerationDisplayDriver> stringLocalizer) =>
T = stringLocalizer;

public override IDisplayResult Edit(ContentTypeDefinition model) =>
public override IDisplayResult Edit(ContentTypeDefinition model, BuildEditorContext context) =>
Initialize<ContentTypeMigrationsViewModel>(
"ContentTypeMigrations_Edit",
viewModel => viewModel.MigrationCodeLazy = new Lazy<string>(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Extensions.Localization;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Entities;
using System.Collections.Generic;
Expand Down Expand Up @@ -64,23 +64,17 @@ public override IDisplayResult Edit(ContentSetPart part, BuildPartEditorContext
context.IsNew))
.Location($"Parts:0%{context.TypePartDefinition.Name};0");

public override async Task<IDisplayResult> UpdateAsync(
ContentSetPart part,
IUpdateModel updater,
UpdatePartEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(ContentSetPart part, UpdatePartEditorContext context)
{
var viewModel = new ContentSetPartViewModel();
var viewModel = await context.CreateModelAsync<ContentSetPartViewModel>(Prefix);

if (await updater.TryUpdateModelAsync(viewModel, Prefix))
{
part.Key = viewModel.Key;
part.Key = viewModel.Key;

// Need to do this here to support displaying the message to save before adding when the
// item has not been saved yet.
if (string.IsNullOrEmpty(part.ContentSet))
{
part.ContentSet = _idGenerator.GenerateUniqueId();
}
// Need to do this here to support displaying the message to save before adding when the item has not been saved
// yet.
if (string.IsNullOrEmpty(part.ContentSet))
{
part.ContentSet = _idGenerator.GenerateUniqueId();
}

return await EditAsync(part, context);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
using Lombiq.HelpfulExtensions.Extensions.Flows.Models;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
using System.Threading.Tasks;

namespace Lombiq.HelpfulExtensions.Extensions.Flows.Drivers;

public class AdditionalStylingPartDisplay : ContentDisplayDriver
{
public override IDisplayResult Edit(ContentItem model, IUpdateModel updater) =>
public override IDisplayResult Edit(ContentItem model, BuildEditorContext context) =>
Initialize<AdditionalStylingPart>(
$"{nameof(AdditionalStylingPart)}_Edit",
viewModel => PopulateViewModel(model, viewModel))
.PlaceInZone("Footer", 3);

public override async Task<IDisplayResult> UpdateAsync(ContentItem model, IUpdateModel updater)
public override async Task<IDisplayResult> UpdateAsync(ContentItem model, UpdateEditorContext context)
{
var additionalStylingPart = model.As<AdditionalStylingPart>();

Expand All @@ -24,9 +24,9 @@ public override async Task<IDisplayResult> UpdateAsync(ContentItem model, IUpdat
return null;
}

await model.AlterAsync<AdditionalStylingPart>(model => updater.TryUpdateModelAsync(model, Prefix));
await model.AlterAsync<AdditionalStylingPart>(model => context.Updater.TryUpdateModelAsync(model, Prefix));

return await EditAsync(model, updater);
return await EditAsync(model, context);
}

private static void PopulateViewModel(ContentItem model, AdditionalStylingPart viewModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Lombiq.HelpfulExtensions.Extensions.Security.Driver;

public class StrictSecuritySettingsDisplayDriver : ContentTypeDefinitionDisplayDriver
{
public override IDisplayResult Edit(ContentTypeDefinition model) =>
public override IDisplayResult Edit(ContentTypeDefinition model, BuildEditorContext context) =>
Initialize<StrictSecuritySettingsViewModel>("StrictSecuritySetting_Edit", viewModel =>
{
var settings = model.GetSettings<StrictSecuritySettings>();
Expand All @@ -21,13 +21,13 @@ public override IDisplayResult Edit(ContentTypeDefinition model) =>

public override async Task<IDisplayResult> UpdateAsync(ContentTypeDefinition model, UpdateTypeEditorContext context)
{
var viewModel = await context.CreateModelMaybeAsync<StrictSecuritySettingsViewModel>(Prefix);
var viewModel = await context.CreateModelAsync<StrictSecuritySettingsViewModel>(Prefix);

// Securable must be enabled for Strict Securable to make sense. Also checked on the client side too.
if (model.GetSettings<ContentTypeSettings>()?.Securable != true) viewModel.Enabled = false;

context.Builder.MergeSettings<StrictSecuritySettings>(settings => settings.Enabled = viewModel.Enabled);

return Edit(model);
return await EditAsync(model, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace Lombiq.HelpfulExtensions.Extensions.Widgets.Drivers;
public abstract class ConditionDisplayDriver<TCondition> : DisplayDriver<Condition, TCondition>
where TCondition : Condition
{
public override IDisplayResult Display(TCondition model) =>
public override IDisplayResult Display(TCondition model, BuildDisplayContext context) =>
Combine(
InitializeDisplayType(CommonContentDisplayTypes.Summary, model),
InitializeDisplayType(CommonContentDisplayTypes.Thumbnail, model));

public override IDisplayResult Edit(TCondition model) =>
public override IDisplayResult Edit(TCondition model, BuildEditorContext context) =>
Combine(
InitializeDisplayType(CommonContentDisplayTypes.Detail, model, "Title"),
GetEditor(model));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.Extensions.Localization;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
using System.Linq;
using System.Text.Json;
Expand All @@ -15,6 +15,7 @@ public class MvcConditionDisplayDriver : ConditionDisplayDriver<MvcCondition>
{
private readonly IHtmlLocalizer<MvcConditionDisplayDriver> H;
private readonly IStringLocalizer<MvcConditionDisplayDriver> T;

public MvcConditionDisplayDriver(
IHtmlLocalizer<MvcConditionDisplayDriver> htmlLocalizer,
IStringLocalizer<MvcConditionDisplayDriver> stringLocalizer)
Expand All @@ -37,30 +38,28 @@ protected override IDisplayResult GetEditor(MvcCondition model) =>
}
}).PlaceInContent();

public override async Task<IDisplayResult> UpdateAsync(MvcCondition model, IUpdateModel updater)
public override async Task<IDisplayResult> UpdateAsync(MvcCondition model, UpdateEditorContext context)
{
var viewModel = new MvcConditionViewModel();
if (await updater.TryUpdateModelAsync(viewModel, Prefix))
var viewModel = await context.CreateModelAsync<MvcConditionViewModel>(Prefix);

if (viewModel.OtherRouteNames.Count != viewModel.OtherRouteValues.Count)
{
if (viewModel.OtherRouteNames.Count != viewModel.OtherRouteValues.Count)
{
updater.ModelState.AddModelError(
nameof(viewModel.OtherRouteNames),
T["The count of other route value names didn't match the count of other route values."]);
}
context.Updater.ModelState.AddModelError(
nameof(viewModel.OtherRouteNames),
T["The count of other route value names didn't match the count of other route values."]);
}

model.Area = viewModel.Area;
model.Controller = viewModel.Controller;
model.Action = viewModel.Action;
model.Area = viewModel.Area;
model.Controller = viewModel.Controller;
model.Action = viewModel.Action;

model.OtherRouteValues.Clear();
for (var i = 0; i < viewModel.OtherRouteNames.Count; i++)
{
model.OtherRouteValues[viewModel.OtherRouteNames[i]] = viewModel.OtherRouteValues[i];
}
model.OtherRouteValues.Clear();
for (var i = 0; i < viewModel.OtherRouteNames.Count; i++)
{
model.OtherRouteValues[viewModel.OtherRouteNames[i]] = viewModel.OtherRouteValues[i];
}

return Edit(model);
return await EditAsync(model, context);
}

protected override ConditionViewModel GetConditionViewModel(MvcCondition condition)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Lombiq.HelpfulExtensions.Extensions.Workflows.Activities;
using Lombiq.HelpfulExtensions.Extensions.Workflows.ViewModels;
using Microsoft.Extensions.Localization;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Users.Models;
using OrchardCore.Workflows.Display;
using OrchardCore.Workflows.Models;
using System.Threading.Tasks;

namespace Lombiq.HelpfulExtensions.Extensions.Workflows.Drivers;
Expand All @@ -26,16 +24,14 @@ protected override void EditActivity(GenerateResetPasswordTokenTask activity, Ge
model.ResetPasswordUrlPropertyKey = activity.ResetPasswordUrlPropertyKey;
}

public override async Task<IDisplayResult> UpdateAsync(GenerateResetPasswordTokenTask model, IUpdateModel updater)
public override async Task<IDisplayResult> UpdateAsync(GenerateResetPasswordTokenTask activity, UpdateEditorContext context)
{
var viewModel = new GenerateResetPasswordTokenTaskViewModel();
if (await updater.TryUpdateModelAsync(viewModel, Prefix))
{
model.User = new WorkflowExpression<User>(viewModel.UserExpression);
model.ResetPasswordTokenPropertyKey = viewModel.ResetPasswordTokenPropertyKey;
model.ResetPasswordUrlPropertyKey = viewModel.ResetPasswordUrlPropertyKey;
}
var viewModel = await context.CreateModelAsync<GenerateResetPasswordTokenTaskViewModel>(Prefix);

return Edit(model);
activity.User = new(viewModel.UserExpression);
activity.ResetPasswordTokenPropertyKey = viewModel.ResetPasswordTokenPropertyKey;
activity.ResetPasswordUrlPropertyKey = viewModel.ResetPasswordUrlPropertyKey;

return await EditAsync(activity, context);
}
}
26 changes: 13 additions & 13 deletions Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Autoroute" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.ContentFields" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Contents" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Flows" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Html" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Lists" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Liquid.Abstractions" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Markdown" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.MetaWeblog.Abstractions" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Rules.Abstractions" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Workflows" Version="2.0.0-preview-18296" />
<PackageReference Include="OrchardCore.Autoroute" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.ContentFields" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Contents" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Flows" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Html" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Lists" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Liquid.Abstractions" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Markdown" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.MetaWeblog.Abstractions" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Rules.Abstractions" Version="2.0.0-preview-18300" />
<PackageReference Include="OrchardCore.Workflows" Version="2.0.0-preview-18300" />
<PackageReference Include="Scrutor" Version="4.2.2" />
</ItemGroup>

Expand All @@ -56,7 +56,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.1-alpha.2.occ-245" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.1-alpha.4.osoe-893" />
<PackageReference Include="Lombiq.NodeJs.Extensions" Version="2.1.0" />
</ItemGroup>

Expand Down

0 comments on commit a379d58

Please sign in to comment.