mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Features list display link to update schema if available
--HG-- branch : dev
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
using Orchard.Data.Migration;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Modules.ViewModels;
|
using Orchard.Modules.ViewModels;
|
||||||
using Orchard.Mvc.Results;
|
using Orchard.Mvc.Results;
|
||||||
@@ -11,10 +12,12 @@ using Orchard.Utility.Extensions;
|
|||||||
namespace Orchard.Modules.Controllers {
|
namespace Orchard.Modules.Controllers {
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
private readonly IModuleService _moduleService;
|
private readonly IModuleService _moduleService;
|
||||||
|
private readonly IDataMigrationManager _dataMigrationManager;
|
||||||
|
|
||||||
public AdminController(IOrchardServices services, IModuleService moduleService) {
|
public AdminController(IOrchardServices services, IModuleService moduleService, IDataMigrationManager dataMigrationManager) {
|
||||||
Services = services;
|
Services = services;
|
||||||
_moduleService = moduleService;
|
_moduleService = moduleService;
|
||||||
|
_dataMigrationManager = dataMigrationManager;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +71,9 @@ namespace Orchard.Modules.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var features = _moduleService.GetAvailableFeatures().ToList();
|
var features = _moduleService.GetAvailableFeatures().ToList();
|
||||||
return View(new FeaturesViewModel {Features = features});
|
var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate();
|
||||||
|
|
||||||
|
return View(new FeaturesViewModel { Features = features, FeaturesThatNeedUpdate = featuresThatNeedUpdate });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@@ -96,5 +101,24 @@ namespace Orchard.Modules.Controllers {
|
|||||||
|
|
||||||
return RedirectToAction("Features");
|
return RedirectToAction("Features");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult Update(string id, bool? force) {
|
||||||
|
if ( !Services.Authorizer.Authorize(Permissions.ManageFeatures, T("Not allowed to manage features")) )
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
|
if ( string.IsNullOrEmpty(id) )
|
||||||
|
return new NotFoundResult();
|
||||||
|
|
||||||
|
try {
|
||||||
|
_dataMigrationManager.Update(id);
|
||||||
|
Services.Notifier.Information(T("The feature {0} was updated succesfuly", id));
|
||||||
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
|
Services.Notifier.Error(T("An error occured while updating the feature {0}: {1}", id, ex.Message));
|
||||||
|
}
|
||||||
|
|
||||||
|
return RedirectToAction("Features");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,6 @@ using Orchard.Mvc.ViewModels;
|
|||||||
namespace Orchard.Modules.ViewModels {
|
namespace Orchard.Modules.ViewModels {
|
||||||
public class FeaturesViewModel : BaseViewModel {
|
public class FeaturesViewModel : BaseViewModel {
|
||||||
public IEnumerable<IModuleFeature> Features { get; set; }
|
public IEnumerable<IModuleFeature> Features { get; set; }
|
||||||
|
public IEnumerable<string> FeaturesThatNeedUpdate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
//hmmm...I feel like I've done this before...
|
//hmmm...I feel like I've done this before...
|
||||||
var featureId = feature.Descriptor.Name.AsFeatureId(n => T(n));
|
var featureId = feature.Descriptor.Name.AsFeatureId(n => T(n));
|
||||||
var featureState = feature.IsEnabled ? "enabled" : "disabled";
|
var featureState = feature.IsEnabled ? "enabled" : "disabled";
|
||||||
var featureClassName = string.Format("feature {0}", featureState);
|
var featureClassName = string.Format("feature {0}", featureState + (Model.FeaturesThatNeedUpdate.Contains(feature.Descriptor.Name) ? " update" : String.Empty));
|
||||||
if (feature == features.First())
|
if (feature == features.First())
|
||||||
featureClassName += " first";
|
featureClassName += " first";
|
||||||
if (feature == features.Last())
|
if (feature == features.Last())
|
||||||
@@ -65,7 +65,15 @@
|
|||||||
<%: Html.Hidden("force", true)%>
|
<%: Html.Hidden("force", true)%>
|
||||||
<button type="submit"><%: T("Enable") %></button><%
|
<button type="submit"><%: T("Enable") %></button><%
|
||||||
}
|
}
|
||||||
} %>
|
}
|
||||||
|
if(Model.FeaturesThatNeedUpdate.Contains(feature.Descriptor.Name)){
|
||||||
|
using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Update", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) { %>
|
||||||
|
<%: Html.Hidden("id", feature.Descriptor.Name, new { id = "" })%>
|
||||||
|
<%: Html.Hidden("force", true)%>
|
||||||
|
<button type="submit" class="update"><%: T("Update") %></button><%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
</div><%
|
</div><%
|
||||||
} %>
|
} %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -110,6 +110,16 @@
|
|||||||
top:.4em;
|
top:.4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.update {
|
||||||
|
margin-left:.5em;
|
||||||
|
}
|
||||||
|
.features .update.feature {
|
||||||
|
background:#ecc;
|
||||||
|
}
|
||||||
|
.features.summary-view .update.feature {
|
||||||
|
border-color:#e77;
|
||||||
|
}
|
||||||
|
|
||||||
.cathedral {
|
.cathedral {
|
||||||
bottom:0;
|
bottom:0;
|
||||||
font-size:.8em;
|
font-size:.8em;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Orchard.Data.Migration.Generator;
|
|
||||||
using Orchard.Data.Migration.Interpreters;
|
using Orchard.Data.Migration.Interpreters;
|
||||||
using Orchard.Data.Migration.Records;
|
using Orchard.Data.Migration.Records;
|
||||||
using Orchard.Data.Migration.Schema;
|
using Orchard.Data.Migration.Schema;
|
||||||
@@ -20,20 +19,17 @@ namespace Orchard.Data.Migration {
|
|||||||
private readonly IRepository<DataMigrationRecord> _dataMigrationRepository;
|
private readonly IRepository<DataMigrationRecord> _dataMigrationRepository;
|
||||||
private readonly IExtensionManager _extensionManager;
|
private readonly IExtensionManager _extensionManager;
|
||||||
private readonly IDataMigrationInterpreter _interpreter;
|
private readonly IDataMigrationInterpreter _interpreter;
|
||||||
private readonly ISchemaCommandGenerator _generator;
|
|
||||||
|
|
||||||
public DataMigrationManager(
|
public DataMigrationManager(
|
||||||
IEnumerable<IDataMigration> dataMigrations,
|
IEnumerable<IDataMigration> dataMigrations,
|
||||||
IRepository<DataMigrationRecord> dataMigrationRepository,
|
IRepository<DataMigrationRecord> dataMigrationRepository,
|
||||||
IExtensionManager extensionManager,
|
IExtensionManager extensionManager,
|
||||||
IDataMigrationInterpreter interpreter,
|
IDataMigrationInterpreter interpreter
|
||||||
ISchemaCommandGenerator generator
|
|
||||||
) {
|
) {
|
||||||
_dataMigrations = dataMigrations;
|
_dataMigrations = dataMigrations;
|
||||||
_dataMigrationRepository = dataMigrationRepository;
|
_dataMigrationRepository = dataMigrationRepository;
|
||||||
_extensionManager = extensionManager;
|
_extensionManager = extensionManager;
|
||||||
_interpreter = interpreter;
|
_interpreter = interpreter;
|
||||||
_generator = generator;
|
|
||||||
|
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user