A little cleanup in the feature management UI

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-05-17 09:50:36 -07:00
parent 542e343e84
commit 4cda9282d7
2 changed files with 6 additions and 9 deletions

View File

@@ -1,6 +1,4 @@
using System; using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Web.Mvc; using System.Web.Mvc;
using Orchard.Localization; using Orchard.Localization;
@@ -26,7 +24,7 @@ namespace Orchard.Modules.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ManageModules, T("Not allowed to manage modules"))) if (!Services.Authorizer.Authorize(Permissions.ManageModules, T("Not allowed to manage modules")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var modules = _moduleService.GetInstalledModules(); var modules = _moduleService.GetInstalledModules().ToList();
return View(new ModulesIndexViewModel {Modules = modules}); return View(new ModulesIndexViewModel {Modules = modules});
} }
@@ -48,7 +46,7 @@ namespace Orchard.Modules.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ManageFeatures, T("Not allowed to manage features"))) if (!Services.Authorizer.Authorize(Permissions.ManageFeatures, T("Not allowed to manage features")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var features = _moduleService.GetAvailableFeatures(); var features = _moduleService.GetAvailableFeatures().ToList();
return View(new FeaturesViewModel {Features = features}); return View(new FeaturesViewModel {Features = features});
} }

View File

@@ -48,11 +48,10 @@ namespace Orchard.Modules.Services {
} }
public IEnumerable<IModuleFeature> GetAvailableFeatures() { public IEnumerable<IModuleFeature> GetAvailableFeatures() {
var enabledFeatures = _shellDescriptorManager.GetShellDescriptor().EnabledFeatures.ToList(); var enabledFeatures = _shellDescriptorManager.GetShellDescriptor().EnabledFeatures;
return GetInstalledModules() return GetInstalledModules()
.SelectMany(m => _extensionManager.LoadFeatures(m.Features)) .SelectMany(m => _extensionManager.LoadFeatures(m.Features))
.Select(f => AssembleModuleFromDescriptor(f, enabledFeatures.FirstOrDefault(sf => string.Equals(sf.Name, f.Descriptor.Name, StringComparison.OrdinalIgnoreCase)) != null)) .Select(f => AssembleModuleFromDescriptor(f, enabledFeatures.FirstOrDefault(sf => string.Equals(sf.Name, f.Descriptor.Name, StringComparison.OrdinalIgnoreCase)) != null));
.ToList();
} }
public IEnumerable<Feature> GetAvailableFeaturesByModule(string moduleName) { public IEnumerable<Feature> GetAvailableFeaturesByModule(string moduleName) {
@@ -71,7 +70,7 @@ namespace Orchard.Modules.Services {
public void DisableFeatures(IEnumerable<string> featureNames) { public void DisableFeatures(IEnumerable<string> featureNames) {
var shellDescriptor = _shellDescriptorManager.GetShellDescriptor(); var shellDescriptor = _shellDescriptorManager.GetShellDescriptor();
var enabledFeatures = shellDescriptor.EnabledFeatures.ToList(); var enabledFeatures = shellDescriptor.EnabledFeatures.ToList();
var features = GetAvailableFeatures(); var features = GetAvailableFeatures().ToList();
foreach (var featureName in featureNames) { foreach (var featureName in featureNames) {
var feature = featureName; var feature = featureName;