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-903: Update to Orchard Core 2.1.0 #76

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -8,26 +8,21 @@

namespace Lombiq.Hosting.MediaTheme.Bridge.Deployment;

public class MediaThemeDeploymentSource : IDeploymentSource
public class MediaThemeDeploymentSource : DeploymentSourceBase<MediaThemeDeploymentStep>
{
private readonly IMediaThemeStateStore _mediaThemeStateStore;

public MediaThemeDeploymentSource(IMediaThemeStateStore mediaThemeStateStore) =>
_mediaThemeStateStore = mediaThemeStateStore;

public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result)
protected override async Task ProcessAsync(MediaThemeDeploymentStep step, DeploymentPlanResult result)
{
if (step is not MediaThemeDeploymentStep mediaThemeStep)
{
return;
}

var mediaThemeState = await _mediaThemeStateStore.GetMediaThemeStateAsync();

result.Steps.Add(new JsonObject(new Dictionary<string, JsonNode>
{
["name"] = RecipeStepIds.MediaTheme,
[nameof(MediaThemeDeploymentStep.ClearMediaThemeFolder)] = mediaThemeStep.ClearMediaThemeFolder,
[nameof(MediaThemeDeploymentStep.ClearMediaThemeFolder)] = step.ClearMediaThemeFolder,
[nameof(MediaThemeStateDocument.BaseThemeId)] = mediaThemeState.BaseThemeId,
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Deployment.Abstractions" Version="2.0.0" />
<PackageReference Include="OrchardCore.DisplayManagement.Abstractions" Version="2.0.0" />
<PackageReference Include="OrchardCore.Recipes.Abstractions" Version="2.0.0" />
<PackageReference Include="OrchardCore.ResourceManagement.Abstractions" Version="2.0.0" />
<PackageReference Include="OrchardCore.Media" Version="2.0.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0" />
<PackageReference Include="OrchardCore.Deployment.Abstractions" Version="2.1.0" />
<PackageReference Include="OrchardCore.DisplayManagement.Abstractions" Version="2.1.0" />
<PackageReference Include="OrchardCore.Recipes.Abstractions" Version="2.1.0" />
<PackageReference Include="OrchardCore.ResourceManagement.Abstractions" Version="2.1.0" />
<PackageReference Include="OrchardCore.Media" Version="2.1.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.1.0" />
<PackageReference Include="Scrutor" Version="4.2.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
using Lombiq.HelpfulLibraries.OrchardCore.Users;
using OrchardCore.Security.Permissions;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Lombiq.Hosting.MediaTheme.Bridge.Permissions;

public sealed class MediaThemeDeploymentPermissions : IPermissionProvider
public sealed class MediaThemeDeploymentPermissions : AdminPermissionBase
{
public static readonly Permission ManageMediaTheme = new(
nameof(ManageMediaTheme),
"Manage Media Theme.");
public static readonly Permission ManageMediaTheme = new(nameof(ManageMediaTheme), "Manage Media Theme.");

public Task<IEnumerable<Permission>> GetPermissionsAsync() =>
Task.FromResult(new[]
{
ManageMediaTheme,
}
.AsEnumerable());

public IEnumerable<PermissionStereotype> GetDefaultStereotypes() =>
[
new PermissionStereotype
{
Name = "Administrator",
Permissions = [ManageMediaTheme],
},
];
protected override IEnumerable<Permission> AdminPermissions => [ManageMediaTheme];
}
11 changes: 3 additions & 8 deletions Lombiq.Hosting.MediaTheme.Bridge/Services/MediaThemeStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@
using OrchardCore.Media;
using OrchardCore.Recipes.Models;
using OrchardCore.Recipes.Services;
using System;
using System.Text.Json;
using System.Threading.Tasks;

namespace Lombiq.Hosting.MediaTheme.Bridge.Services;

public sealed class MediaThemeStep : IRecipeStepHandler
public sealed class MediaThemeStep : NamedRecipeStepHandler
{
private readonly IMediaFileStore _mediaFileStore;
private readonly IMediaThemeManager _mediaThemeManager;

public MediaThemeStep(
IMediaFileStore mediaFileStore,
IMediaThemeManager mediaThemeManager)
: base(RecipeStepIds.MediaTheme)
{
_mediaFileStore = mediaFileStore;
_mediaThemeManager = mediaThemeManager;
}

public async Task ExecuteAsync(RecipeExecutionContext context)
protected override async Task HandleAsync(RecipeExecutionContext context)
{
if (!string.Equals(context.Name, RecipeStepIds.MediaTheme, StringComparison.OrdinalIgnoreCase))
{
return;
}

var model = context.Step.Deserialize<MediaThemeStepModel>();

await _mediaThemeManager.UpdateBaseThemeAsync(model.BaseThemeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Theme.Targets" Version="2.0.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="2.0.0" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="2.0.0" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="2.0.0" />
<PackageReference Include="OrchardCore.Theme.Targets" Version="2.1.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="2.1.0" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="2.1.0" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Hosting.MediaTheme/Lombiq.Hosting.MediaTheme.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Theme.Targets" Version="2.0.0" />
<PackageReference Include="OrchardCore.Theme.Targets" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading