Skip to content

Commit

Permalink
Adds All Features deployment step (#1034)
Browse files Browse the repository at this point in the history
Fixes #1032
  • Loading branch information
Chris Payne authored and sebastienros committed Sep 28, 2017
1 parent 16022f8 commit 4e987d0
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using OrchardCore.Deployment;
using OrchardCore.Features.Services;

namespace OrchardCore.Features.Deployment
{
public class AllFeaturesDeploymentSource : IDeploymentSource
{
private readonly IModuleService _moduleService;

public AllFeaturesDeploymentSource(IModuleService moduleService)
{
_moduleService = moduleService;
}

public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result)
{
var allFeaturesState = step as AllFeaturesDeploymentStep;

if (allFeaturesState == null)
{
return;
}

var features = await _moduleService.GetAvailableFeaturesAsync();

result.Steps.Add(new JObject(
new JProperty("name", "Feature"),
new JProperty("enable", features.Where(f => f.IsEnabled).Select(f => f.Descriptor.Id).ToArray()),
new JProperty("disable", features.Where(f => !f.IsEnabled).Select(f => f.Descriptor.Id).ToArray())
));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using OrchardCore.Deployment;

namespace OrchardCore.Features.Deployment
{
/// <summary>
/// Adds enabled and disabled features to a <see cref="DeploymentPlanResult"/>.
/// </summary>
public class AllFeaturesDeploymentStep : DeploymentStep
{
public AllFeaturesDeploymentStep()
{
Name = "AllFeatures";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;

namespace OrchardCore.Features.Deployment
{
public class AllFeaturesDeploymentStepDriver : DisplayDriver<DeploymentStep, AllFeaturesDeploymentStep>
{
public override IDisplayResult Display(AllFeaturesDeploymentStep step)
{
return
Combine(
Shape("AllFeaturesDeploymentStep_Summary", step).Location("Summary", "Content"),
Shape("AllFeaturesDeploymentStep_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(AllFeaturesDeploymentStep step)
{
return Shape("AllFeaturesDeploymentStep_Edit", step).Location("Content");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Deployment.Abstractions\OrchardCore.Deployment.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Module.Targets\OrchardCore.Module.Targets.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Mvc.Abstractions\OrchardCore.Mvc.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Admin.Abstractions\OrchardCore.Admin.Abstractions.csproj" />
Expand All @@ -18,4 +19,16 @@
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement.Abstractions\OrchardCore.ResourceManagement.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Views\Items\AllFeaturesDeploymentStep.Edit.cshtml">
<PackagePath>assets\$(PackageId)\</PackagePath>
</None>
<None Update="Views\Items\AllFeaturesDeploymentStep.Summary.cshtml">
<PackagePath>assets\$(PackageId)\</PackagePath>
</None>
<None Update="Views\Items\AllFeaturesDeploymentStep.Thumbnail.cshtml">
<PackagePath>assets\$(PackageId)\</PackagePath>
</None>
</ItemGroup>

</Project>
10 changes: 9 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.Features/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System;
using Microsoft.AspNetCore.Builder;
using OrchardCore.Modules;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Environment.Navigation;
using OrchardCore.Features.Deployment;
using OrchardCore.Features.Recipes.Executors;
using OrchardCore.Features.Services;
using OrchardCore.Recipes;
Expand All @@ -22,6 +25,11 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IPermissionProvider, Permissions>();
services.AddScoped<IModuleService, ModuleService>();
services.AddScoped<INavigationProvider, AdminMenu>();


services.AddTransient<IDeploymentSource, AllFeaturesDeploymentSource>();
services.AddSingleton<IDeploymentStepFactory>(new DeploymentStepFactory<AllFeaturesDeploymentStep>());
services.AddScoped<IDisplayDriver<DeploymentStep>, AllFeaturesDeploymentStepDriver>();
}

public override void Configure(IApplicationBuilder builder, IRouteBuilder routes, IServiceProvider serviceProvider)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@model dynamic

<h5>@T["All Features"]</h5>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@model dynamic

<h5>@T["All Features"]</h5>

<span class="hint">@T["Adds all features and their state to the plan."]</span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@model dynamic

<h4 class="card-title">@T["All Features"]</h4>
<p>@T["Exports the state of all features."]</p>

0 comments on commit 4e987d0

Please sign in to comment.