mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding Recipes manager screen
--HG-- branch : 1.x extra : rebase_source : 40b859a2e2fbae6d64aa5b092dd725241a4522b9
This commit is contained in:
@@ -14,7 +14,9 @@ namespace Orchard.Modules {
|
||||
builder.AddImageSet("modules")
|
||||
.Add(T("Modules"), "9", menu => menu.Action("Features", "Admin", new {area = "Orchard.Modules"}).Permission(Permissions.ManageFeatures)
|
||||
.Add(T("Features"), "0", item => item.Action("Features", "Admin", new {area = "Orchard.Modules"}).Permission(Permissions.ManageFeatures).LocalNav())
|
||||
.Add(T("Installed"), "1", item => item.Action("Index", "Admin", new {area = "Orchard.Modules"}).Permission(StandardPermissions.SiteOwner).LocalNav()));
|
||||
.Add(T("Installed"), "1", item => item.Action("Index", "Admin", new { area = "Orchard.Modules" }).Permission(StandardPermissions.SiteOwner).LocalNav())
|
||||
.Add(T("Recipes"), "2", item => item.Action("Recipes", "Admin", new { area = "Orchard.Modules" }).Permission(StandardPermissions.SiteOwner).LocalNav())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@ using Orchard.Modules.Events;
|
||||
using Orchard.Modules.Models;
|
||||
using Orchard.Modules.Services;
|
||||
using Orchard.Modules.ViewModels;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Navigation;
|
||||
@@ -28,6 +30,8 @@ namespace Orchard.Modules.Controllers {
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
private readonly IFeatureManager _featureManager;
|
||||
private readonly IRecipeHarvester _recipeHarvester;
|
||||
private readonly IRecipeManager _recipeManager;
|
||||
private readonly ShellDescriptor _shellDescriptor;
|
||||
|
||||
public AdminController(
|
||||
@@ -38,6 +42,8 @@ namespace Orchard.Modules.Controllers {
|
||||
IReportsCoordinator reportsCoordinator,
|
||||
IExtensionManager extensionManager,
|
||||
IFeatureManager featureManager,
|
||||
IRecipeHarvester recipeHarvester,
|
||||
IRecipeManager recipeManager,
|
||||
ShellDescriptor shellDescriptor,
|
||||
IShapeFactory shapeFactory)
|
||||
{
|
||||
@@ -48,6 +54,8 @@ namespace Orchard.Modules.Controllers {
|
||||
_reportsCoordinator = reportsCoordinator;
|
||||
_extensionManager = extensionManager;
|
||||
_featureManager = featureManager;
|
||||
_recipeHarvester = recipeHarvester;
|
||||
_recipeManager = recipeManager;
|
||||
_shellDescriptor = shellDescriptor;
|
||||
Shape = shapeFactory;
|
||||
|
||||
@@ -97,6 +105,59 @@ namespace Orchard.Modules.Controllers {
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult Recipes() {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage modules")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
IEnumerable<ModuleEntry> modules = _extensionManager.AvailableExtensions()
|
||||
.Where(extensionDescriptor => DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType))
|
||||
.OrderBy(extensionDescriptor => extensionDescriptor.Name)
|
||||
.Select(extensionDescriptor => new ModuleEntry { Descriptor = extensionDescriptor });
|
||||
|
||||
var viewModel = new RecipesViewModel();
|
||||
|
||||
if (_recipeHarvester != null) {
|
||||
viewModel.Modules = modules.Select(x => new ModuleRecipesViewModel {
|
||||
Module = x,
|
||||
Recipes = _recipeHarvester.HarvestRecipes(x.Descriptor.Id).ToList()
|
||||
})
|
||||
.Where(x => x.Recipes.Any());
|
||||
}
|
||||
|
||||
return View(viewModel);
|
||||
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Recipes")]
|
||||
public ActionResult RecipesPOST(string moduleId, string name) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage modules")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
ModuleEntry module = _extensionManager.AvailableExtensions()
|
||||
.Where(extensionDescriptor => extensionDescriptor.Id == moduleId)
|
||||
.Select(extensionDescriptor => new ModuleEntry { Descriptor = extensionDescriptor }).FirstOrDefault();
|
||||
|
||||
if (module == null) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Recipe recipe = _recipeHarvester.HarvestRecipes(module.Descriptor.Id).FirstOrDefault(x => x.Name == name);
|
||||
|
||||
if (recipe == null) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
try {
|
||||
_recipeManager.Execute(recipe);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Logger.Error(e, "Error while executing recipe {0} in {1}", moduleId, name);
|
||||
Services.Notifier.Error(T("Recipes contains {0} unsupported module installation steps.", recipe.Name));
|
||||
}
|
||||
|
||||
return RedirectToAction("Recipes");
|
||||
|
||||
}
|
||||
public ActionResult Features() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageFeatures, T("Not allowed to manage features")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
@@ -20,6 +20,11 @@
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkProfile />
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -65,6 +70,7 @@
|
||||
<Compile Include="Services\IModuleService.cs" />
|
||||
<Compile Include="Models\ModuleEntry.cs" />
|
||||
<Compile Include="Models\ModuleFeature.cs" />
|
||||
<Compile Include="ViewModels\RecipesViewModel.cs" />
|
||||
<Compile Include="ViewModels\FeaturesViewModel.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -108,6 +114,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\ModuleEntry.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Admin\Recipes.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Modules.Models;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
public class RecipesViewModel {
|
||||
public IEnumerable<ModuleRecipesViewModel> Modules { get; set; }
|
||||
}
|
||||
|
||||
public class ModuleRecipesViewModel {
|
||||
public ModuleEntry Module { get; set; }
|
||||
public IEnumerable<Recipe> Recipes { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
@using Orchard.Utility.Extensions
|
||||
@model Orchard.Modules.ViewModels.RecipesViewModel
|
||||
|
||||
@{
|
||||
Layout.Title = T("Recipes");
|
||||
}
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
if (Model.Modules.Any()) {
|
||||
<ul class="contentItems">
|
||||
@foreach (var moduleEntry in Model.Modules.OrderBy(m => m.Module.Descriptor.Name)) {
|
||||
var module = moduleEntry.Module;
|
||||
var descriptor = module.Descriptor;
|
||||
|
||||
<li>
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<h2>@descriptor.Name<span> - @T("Version: {0}", !string.IsNullOrEmpty(descriptor.Version) ? descriptor.Version : T("1.0").ToString())</span></h2>
|
||||
|
||||
@*@if (!string.IsNullOrEmpty(descriptor.Description)) {
|
||||
<p>@descriptor.Description</p>
|
||||
}*@
|
||||
|
||||
@foreach (var recipe in moduleEntry.Recipes) {
|
||||
<br/>
|
||||
<div>
|
||||
<h4>@recipe.Name.CamelFriendly() - @Html.ActionLink(T("Execute").Text, "Recipes", "Admin", new {area = "Orchard.Modules", moduleId = descriptor.Id, name = recipe.Name}, new {itemprop = "UnsafeUrl"})</h4>
|
||||
<p>@(!string.IsNullOrEmpty(recipe.Description) ? recipe.Description : T("No description").ToString())</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
else {
|
||||
<p>@T("No modules available").ToString()</p>
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user