mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Showing allowed modules with dependencies
This commit is contained in:
@@ -81,7 +81,7 @@ namespace Orchard.Modules.Controllers {
|
|||||||
|
|
||||||
IEnumerable<ModuleEntry> modules = _extensionManager.AvailableExtensions()
|
IEnumerable<ModuleEntry> modules = _extensionManager.AvailableExtensions()
|
||||||
.Where(extensionDescriptor => DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType) &&
|
.Where(extensionDescriptor => DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType) &&
|
||||||
ModuleIsAllowed(extensionDescriptor) &&
|
|
||||||
(string.IsNullOrEmpty(options.SearchText) || extensionDescriptor.Name.ToLowerInvariant().Contains(options.SearchText.ToLowerInvariant())))
|
(string.IsNullOrEmpty(options.SearchText) || extensionDescriptor.Name.ToLowerInvariant().Contains(options.SearchText.ToLowerInvariant())))
|
||||||
.OrderBy(extensionDescriptor => extensionDescriptor.Name)
|
.OrderBy(extensionDescriptor => extensionDescriptor.Name)
|
||||||
.Select(extensionDescriptor => new ModuleEntry { Descriptor = extensionDescriptor });
|
.Select(extensionDescriptor => new ModuleEntry { Descriptor = extensionDescriptor });
|
||||||
@@ -174,7 +174,7 @@ namespace Orchard.Modules.Controllers {
|
|||||||
var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate();
|
var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate();
|
||||||
|
|
||||||
IEnumerable<ModuleFeature> features = _featureManager.GetAvailableFeatures()
|
IEnumerable<ModuleFeature> features = _featureManager.GetAvailableFeatures()
|
||||||
.Where(f => !DefaultExtensionTypes.IsTheme(f.Extension.ExtensionType) && ModuleIsAllowed(f.Extension))
|
.Where(f => !DefaultExtensionTypes.IsTheme(f.Extension.ExtensionType))
|
||||||
.Select(f => new ModuleFeature {
|
.Select(f => new ModuleFeature {
|
||||||
Descriptor = f,
|
Descriptor = f,
|
||||||
IsEnabled = _shellDescriptor.Features.Any(sf => sf.Name == f.Id),
|
IsEnabled = _shellDescriptor.Features.Any(sf => sf.Name == f.Id),
|
||||||
@@ -184,7 +184,10 @@ namespace Orchard.Modules.Controllers {
|
|||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return View(new FeaturesViewModel { Features = features });
|
return View(new FeaturesViewModel {
|
||||||
|
Features = features,
|
||||||
|
IsAllowed = ModuleIsAllowed
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("Features")]
|
[HttpPost, ActionName("Features")]
|
||||||
|
@@ -1,10 +1,14 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Orchard.Environment.Configuration;
|
||||||
|
using Orchard.Environment.Extensions.Models;
|
||||||
using Orchard.Modules.Models;
|
using Orchard.Modules.Models;
|
||||||
|
|
||||||
namespace Orchard.Modules.ViewModels {
|
namespace Orchard.Modules.ViewModels {
|
||||||
public class FeaturesViewModel {
|
public class FeaturesViewModel {
|
||||||
public IEnumerable<ModuleFeature> Features { get; set; }
|
public IEnumerable<ModuleFeature> Features { get; set; }
|
||||||
public FeaturesBulkAction BulkAction { get; set; }
|
public FeaturesBulkAction BulkAction { get; set; }
|
||||||
|
public Func<ExtensionDescriptor, bool> IsAllowed { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FeaturesBulkAction {
|
public enum FeaturesBulkAction {
|
||||||
|
@@ -35,10 +35,14 @@
|
|||||||
<button type="submit" name="submit.BulkExecute" value="yes">@T("Execute")</button>
|
<button type="submit" name="submit.BulkExecute" value="yes">@T("Execute")</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="features summary-view switchable">@{
|
<ul class="features summary-view switchable">
|
||||||
|
@{
|
||||||
var featureGroups = Model.Features.OrderBy(f => f.Descriptor.Category, new DoghouseComparer("Core")).GroupBy(f => f.Descriptor.Category).ToList();
|
var featureGroups = Model.Features.OrderBy(f => f.Descriptor.Category, new DoghouseComparer("Core")).GroupBy(f => f.Descriptor.Category).ToList();
|
||||||
foreach (var featureGroup in featureGroups) {
|
foreach (var featureGroup in featureGroups) {
|
||||||
|
if (!featureGroup.Any(x => Model.IsAllowed(x.Descriptor.Extension))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var categoryName = LocalizedString.TextOrDefault(featureGroup.First().Descriptor.Category, T("Uncategorized"));
|
var categoryName = LocalizedString.TextOrDefault(featureGroup.First().Descriptor.Category, T("Uncategorized"));
|
||||||
var categoryClassName = string.Format("category {0}", Html.Encode(categoryName.ToString().HtmlClassify()));
|
var categoryClassName = string.Format("category {0}", Html.Encode(categoryName.ToString().HtmlClassify()));
|
||||||
if (featureGroup == featureGroups.First()) {
|
if (featureGroup == featureGroups.First()) {
|
||||||
@@ -48,11 +52,15 @@
|
|||||||
categoryClassName += " last";
|
categoryClassName += " last";
|
||||||
}
|
}
|
||||||
|
|
||||||
<li class="@categoryClassName">
|
<li class="@categoryClassName">
|
||||||
<h2>@categoryName</h2>
|
<h2>@categoryName</h2>
|
||||||
<ul>@{
|
<ul>
|
||||||
|
@{
|
||||||
var features = featureGroup.OrderBy(f => f.Descriptor.Name);
|
var features = featureGroup.OrderBy(f => f.Descriptor.Name);
|
||||||
foreach (var feature in features) {
|
foreach (var feature in features) {
|
||||||
|
if (!Model.IsAllowed(feature.Descriptor.Extension)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//hmmm...I feel like I've done this before...
|
//hmmm...I feel like I've done this before...
|
||||||
var featureId = feature.Descriptor.Id.AsFeatureId(n => T(n));
|
var featureId = feature.Descriptor.Id.AsFeatureId(n => T(n));
|
||||||
var featureName = string.IsNullOrEmpty(feature.Descriptor.Name) ? feature.Descriptor.Id : feature.Descriptor.Name;
|
var featureName = string.IsNullOrEmpty(feature.Descriptor.Name) ? feature.Descriptor.Id : feature.Descriptor.Name;
|
||||||
@@ -74,57 +82,59 @@
|
|||||||
var missingDependencies = feature.Descriptor.Dependencies
|
var missingDependencies = feature.Descriptor.Dependencies
|
||||||
.Where(d => !Model.Features.Any(f => f.Descriptor.Id.Equals(d, StringComparison.OrdinalIgnoreCase)));
|
.Where(d => !Model.Features.Any(f => f.Descriptor.Id.Equals(d, StringComparison.OrdinalIgnoreCase)));
|
||||||
var showDisable = categoryName.ToString() != "Core";
|
var showDisable = categoryName.ToString() != "Core";
|
||||||
var showEnable = !missingDependencies.Any() && feature.Descriptor.Id != "Orchard.Setup";
|
var showEnable = Model.IsAllowed(feature.Descriptor.Extension) && !missingDependencies.Any() && feature.Descriptor.Id != "Orchard.Setup";
|
||||||
|
|
||||||
<li class="@featureClassName" id="@featureId" title="@T("{0} is {1}", Html.AttributeEncode(featureName), featureState)">
|
<li class="@featureClassName" id="@featureId" title="@T("{0} is {1}", Html.AttributeEncode(featureName), featureState)">
|
||||||
<div class="summary">
|
<div class="summary">
|
||||||
<div class="properties">
|
<div class="properties">
|
||||||
<h3>
|
<h3>
|
||||||
@if ((showEnable && !feature.IsEnabled) || (showDisable && feature.IsEnabled)) {
|
@if ((showEnable && !feature.IsEnabled) || (showDisable && feature.IsEnabled)) {
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="featureIds" value="@feature.Descriptor.Id"/>
|
<input type="checkbox" name="featureIds" value="@feature.Descriptor.Id" />
|
||||||
|
@featureName
|
||||||
|
</label>
|
||||||
|
}
|
||||||
|
else {
|
||||||
@featureName
|
@featureName
|
||||||
</label>
|
}
|
||||||
}
|
</h3>
|
||||||
else {
|
<p class="description" title="@feature.Descriptor.Description">@feature.Descriptor.Description</p>
|
||||||
@featureName
|
@if (feature.Descriptor.Dependencies != null && feature.Descriptor.Dependencies.Any()) {
|
||||||
}
|
<div class="dependencies">
|
||||||
</h3>
|
<h4>@T("Depends on:")</h4>
|
||||||
<p class="description" title="@feature.Descriptor.Description">@feature.Descriptor.Description</p>
|
@Html.UnorderedList(dependencies,
|
||||||
@if (feature.Descriptor.Dependencies != null && feature.Descriptor.Dependencies.Any()) {
|
|
||||||
<div class="dependencies">
|
|
||||||
<h4>@T("Depends on:")</h4>
|
|
||||||
@Html.UnorderedList(dependencies,
|
|
||||||
(s, i) => Html.Link(string.IsNullOrEmpty(s.Descriptor.Name) ? s.Descriptor.Id : s.Descriptor.Name, string.Format("#{0}", s.Descriptor.Id.AsFeatureId(n => T(n)))),
|
(s, i) => Html.Link(string.IsNullOrEmpty(s.Descriptor.Name) ? s.Descriptor.Id : s.Descriptor.Name, string.Format("#{0}", s.Descriptor.Id.AsFeatureId(n => T(n)))),
|
||||||
"",
|
"",
|
||||||
"dependency",
|
"dependency",
|
||||||
"")
|
"")
|
||||||
</div>}
|
</div>}
|
||||||
@if (missingDependencies.Any()) {
|
@if (missingDependencies.Any()) {
|
||||||
<div class="missingdependencies">
|
<div class="missingdependencies">
|
||||||
<h4>@T("Missing:")</h4>
|
<h4>@T("Missing:")</h4>
|
||||||
@Html.UnorderedList(missingDependencies, (s, i) => MvcHtmlString.Create(s), "", "missingdependency", "")
|
@Html.UnorderedList(missingDependencies, (s, i) => MvcHtmlString.Create(s), "", "missingdependency", "")
|
||||||
</div>}
|
</div>}
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
@if (showDisable && feature.IsEnabled) {
|
@if (showDisable && feature.IsEnabled) {
|
||||||
var dependantsJoined = string.Join(", ", feature.DependentFeatures.Select(f => f.Name));
|
var dependantsJoined = string.Join(", ", feature.DependentFeatures.Select(f => f.Name));
|
||||||
<a href="#" data-feature-id="@feature.Descriptor.Id" data-feature-action="@FeaturesBulkAction.Disable" data-feature-force="true" data-feature-dependants="@dependantsJoined">@T("Disable")</a>
|
<a href="#" data-feature-id="@feature.Descriptor.Id" data-feature-action="@FeaturesBulkAction.Disable" data-feature-force="true" data-feature-dependants="@dependantsJoined">@T("Disable")</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (showEnable && !feature.IsEnabled) {
|
@if (showEnable && !feature.IsEnabled) {
|
||||||
<a href="#" data-feature-id="@feature.Descriptor.Id" data-feature-action="@FeaturesBulkAction.Enable" data-feature-force="true">@T("Enable")</a>
|
<a href="#" data-feature-id="@feature.Descriptor.Id" data-feature-action="@FeaturesBulkAction.Enable" data-feature-force="true">@T("Enable")</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (feature.NeedsUpdate) {
|
@if (feature.NeedsUpdate) {
|
||||||
<a href="#" data-feature-id="@feature.Descriptor.Id" data-feature-action="@FeaturesBulkAction.Update" data-feature-force="false">@T("Update")</a>
|
<a href="#" data-feature-id="@feature.Descriptor.Id" data-feature-action="@FeaturesBulkAction.Update" data-feature-force="false">@T("Update")</a>
|
||||||
}
|
}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</li>}
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
</li>}
|
</li>}
|
||||||
}</ul>
|
}
|
||||||
</li>}
|
</ul>}
|
||||||
}</ul>}
|
|
||||||
|
|
||||||
using (Script.Foot()) {
|
using (Script.Foot()) {
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
Reference in New Issue
Block a user