-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds All Features deployment step (#1034)
Fixes #1032
- Loading branch information
1 parent
16022f8
commit 4e987d0
Showing
8 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/OrchardCore.Modules/OrchardCore.Features/Deployment/AllFeaturesDeploymentSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
)); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/OrchardCore.Modules/OrchardCore.Features/Deployment/AllFeaturesDeploymentStep.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/OrchardCore.Modules/OrchardCore.Features/Deployment/AllFeaturesDeploymentStepDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...rchardCore.Modules/OrchardCore.Features/Views/Items/AllFeaturesDeploymentStep.Edit.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@model dynamic | ||
|
||
<h5>@T["All Features"]</h5> |
5 changes: 5 additions & 0 deletions
5
...ardCore.Modules/OrchardCore.Features/Views/Items/AllFeaturesDeploymentStep.Summary.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
4 changes: 4 additions & 0 deletions
4
...dCore.Modules/OrchardCore.Features/Views/Items/AllFeaturesDeploymentStep.Thumbnail.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |