mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Simplified step names and added ResetSiteAction skeleton.
This commit is contained in:
@@ -36,7 +36,7 @@ namespace Orchard.ImportExport.Controllers {
|
|||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public ActionResult Import() {
|
public ActionResult Import() {
|
||||||
var actions = _importActions.OrderBy(x => x.Priority).Select(x => new ImportActionViewModel {
|
var actions = _importActions.OrderByDescending(x => x.Priority).Select(x => new ImportActionViewModel {
|
||||||
Editor = x.BuildEditor(Services.New)
|
Editor = x.BuildEditor(Services.New)
|
||||||
}).Where(x => x != null).ToList();
|
}).Where(x => x != null).ToList();
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ namespace Orchard.ImportExport.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.Import, T("Not allowed to import.")))
|
if (!Services.Authorizer.Authorize(Permissions.Import, T("Not allowed to import.")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var actions = _importActions.OrderBy(x => x.Priority).ToList();
|
var actions = _importActions.OrderByDescending(x => x.Priority).ToList();
|
||||||
var viewModel = new ImportViewModel {
|
var viewModel = new ImportViewModel {
|
||||||
Actions = actions.Select(x => new ImportActionViewModel {
|
Actions = actions.Select(x => new ImportActionViewModel {
|
||||||
Editor = x.UpdateEditor(Services.New, this)
|
Editor = x.UpdateEditor(Services.New, this)
|
||||||
@@ -82,7 +82,7 @@ namespace Orchard.ImportExport.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Export() {
|
public ActionResult Export() {
|
||||||
var actions = _exportActions.OrderBy(x => x.Priority).Select(x => new ExportActionViewModel {
|
var actions = _exportActions.OrderByDescending(x => x.Priority).Select(x => new ExportActionViewModel {
|
||||||
Editor = x.BuildEditor(Services.New)
|
Editor = x.BuildEditor(Services.New)
|
||||||
}).Where(x => x != null).ToList();
|
}).Where(x => x != null).ToList();
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ namespace Orchard.ImportExport.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.Export, T("Not allowed to export.")))
|
if (!Services.Authorizer.Authorize(Permissions.Export, T("Not allowed to export.")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var actions = _exportActions.OrderBy(x => x.Priority).ToList();
|
var actions = _exportActions.OrderByDescending(x => x.Priority).ToList();
|
||||||
|
|
||||||
foreach (var action in actions) {
|
foreach (var action in actions) {
|
||||||
action.UpdateEditor(Services.New, this);
|
action.UpdateEditor(Services.New, this);
|
||||||
|
|||||||
@@ -71,8 +71,10 @@
|
|||||||
<Compile Include="Models\ExportOptions.cs" />
|
<Compile Include="Models\ExportOptions.cs" />
|
||||||
<Compile Include="Permissions.cs" />
|
<Compile Include="Permissions.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Providers\ExportActions\RecipeBuilder.cs" />
|
<Compile Include="Providers\ExportActions\BuildRecipeAction.cs" />
|
||||||
<Compile Include="Providers\ImportActions\UploadRecipe.cs" />
|
<Compile Include="Providers\ImportActions\ResetSiteAction.cs" />
|
||||||
|
<Compile Include="ViewModels\ResetSiteViewModel.cs" />
|
||||||
|
<Compile Include="Providers\ImportActions\UploadRecipeAction.cs" />
|
||||||
<Compile Include="Recipes\Builders\CustomStepsStep.cs" />
|
<Compile Include="Recipes\Builders\CustomStepsStep.cs" />
|
||||||
<Compile Include="Services\ImportAction.cs" />
|
<Compile Include="Services\ImportAction.cs" />
|
||||||
<Compile Include="Services\ExportAction.cs" />
|
<Compile Include="Services\ExportAction.cs" />
|
||||||
@@ -141,7 +143,10 @@
|
|||||||
<Content Include="Views\EditorTemplates\ExportSteps\CustomSteps.cshtml" />
|
<Content Include="Views\EditorTemplates\ExportSteps\CustomSteps.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\EditorTemplates\ExportActions\RecipeBuilder.cshtml" />
|
<Content Include="Views\EditorTemplates\ExportActions\BuildRecipe.cshtml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Views\EditorTemplates\ImportActions\ResetSite.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ using Orchard.Recipes.Services;
|
|||||||
using Orchard.Utility.Extensions;
|
using Orchard.Utility.Extensions;
|
||||||
|
|
||||||
namespace Orchard.ImportExport.Providers.ExportActions {
|
namespace Orchard.ImportExport.Providers.ExportActions {
|
||||||
public class RecipeBuilder : ExportAction {
|
public class BuildRecipeAction : ExportAction {
|
||||||
private readonly IEnumerable<IRecipeBuilderStep> _recipeBuilderSteps;
|
private readonly IEnumerable<IRecipeBuilderStep> _recipeBuilderSteps;
|
||||||
private readonly IImportExportService _importExportService;
|
private readonly IImportExportService _importExportService;
|
||||||
private readonly IRecipeParser _recipeParser;
|
private readonly IRecipeParser _recipeParser;
|
||||||
|
|
||||||
public RecipeBuilder(IEnumerable<IRecipeBuilderStep> recipeBuilderSteps, IImportExportService importExportService, IRecipeParser recipeParser) {
|
public BuildRecipeAction(IEnumerable<IRecipeBuilderStep> recipeBuilderSteps, IImportExportService importExportService, IRecipeParser recipeParser) {
|
||||||
_recipeBuilderSteps = recipeBuilderSteps;
|
_recipeBuilderSteps = recipeBuilderSteps;
|
||||||
_importExportService = importExportService;
|
_importExportService = importExportService;
|
||||||
_recipeParser = recipeParser;
|
_recipeParser = recipeParser;
|
||||||
@@ -24,7 +24,7 @@ namespace Orchard.ImportExport.Providers.ExportActions {
|
|||||||
RecipeBuilderSteps = new List<IRecipeBuilderStep>();
|
RecipeBuilderSteps = new List<IRecipeBuilderStep>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Name { get { return "RecipeBuilder"; } }
|
public override string Name { get { return "BuildRecipe"; } }
|
||||||
|
|
||||||
public IList<IRecipeBuilderStep> RecipeBuilderSteps { get; set; }
|
public IList<IRecipeBuilderStep> RecipeBuilderSteps { get; set; }
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ namespace Orchard.ImportExport.Providers.ExportActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
||||||
var builderSteps = _recipeBuilderSteps.OrderBy(x => x.Priority).Select(x => new ExportStepViewModel {
|
var builderSteps = _recipeBuilderSteps.OrderByDescending(x => x.Priority).Select(x => new ExportStepViewModel {
|
||||||
Name = x.Name,
|
Name = x.Name,
|
||||||
DisplayName = x.DisplayName,
|
DisplayName = x.DisplayName,
|
||||||
Description = x.Description,
|
Description = x.Description,
|
||||||
@@ -61,7 +61,7 @@ namespace Orchard.ImportExport.Providers.ExportActions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return shapeFactory.EditorTemplate(TemplateName: "ExportActions/RecipeBuilder", Model: viewModel, Prefix: Prefix);
|
return shapeFactory.EditorTemplate(TemplateName: "ExportActions/BuildRecipe", Model: viewModel, Prefix: Prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(ExportActionContext context) {
|
public override void Execute(ExportActionContext context) {
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ImportExport.Services;
|
||||||
|
using Orchard.ImportExport.ViewModels;
|
||||||
|
|
||||||
|
namespace Orchard.ImportExport.Providers.ImportActions {
|
||||||
|
public class ResetSiteAction : ImportAction {
|
||||||
|
|
||||||
|
public override string Name { get { return "ResetSite"; } }
|
||||||
|
|
||||||
|
public override int Priority {
|
||||||
|
get { return 500; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override dynamic BuildEditor(dynamic shapeFactory) {
|
||||||
|
return UpdateEditor(shapeFactory, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ResetSite { get; set; }
|
||||||
|
|
||||||
|
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
||||||
|
var viewModel = new ResetSiteViewModel();
|
||||||
|
if (updater != null) {
|
||||||
|
ResetSite = viewModel.ResetSite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shapeFactory.EditorTemplate(TemplateName: "ImportActions/ResetSite", Model: viewModel, Prefix: Prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Execute(ImportActionContext context) {
|
||||||
|
// Reset site.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,11 +8,11 @@ using Orchard.ImportExport.Services;
|
|||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
namespace Orchard.ImportExport.Providers.ImportActions {
|
namespace Orchard.ImportExport.Providers.ImportActions {
|
||||||
public class UploadRecipe : ImportAction {
|
public class UploadRecipeAction : ImportAction {
|
||||||
private readonly IOrchardServices _orchardServices;
|
private readonly IOrchardServices _orchardServices;
|
||||||
private readonly IImportExportService _importExportService;
|
private readonly IImportExportService _importExportService;
|
||||||
|
|
||||||
public UploadRecipe(IOrchardServices orchardServices, IImportExportService importExportService) {
|
public UploadRecipeAction(IOrchardServices orchardServices, IImportExportService importExportService) {
|
||||||
_orchardServices = orchardServices;
|
_orchardServices = orchardServices;
|
||||||
_importExportService = importExportService;
|
_importExportService = importExportService;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Orchard.ImportExport.ViewModels {
|
||||||
|
public class ResetSiteViewModel {
|
||||||
|
public bool ResetSite { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
@model Orchard.ImportExport.ViewModels.ImportViewModel
|
@model Orchard.ImportExport.ViewModels.ImportViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
Layout.Title = T("Import").ToString();
|
Layout.Title = T("Import").ToString();
|
||||||
|
}
|
||||||
using (Html.BeginFormAntiForgeryPost(Url.Action("Import", new { area = "Orchard.ImportExport" }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
@using (Html.BeginFormAntiForgeryPost(Url.Action("Import", new { area = "Orchard.ImportExport" }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||||
@Html.ValidationSummary();
|
@Html.ValidationSummary();
|
||||||
<p>@T("Choose a recipe file to import. Please consider {0} or backing up your data first.",
|
foreach(var action in Model.Actions) {
|
||||||
@Html.Link(T("exporting").Text, Url.Action("Export", "Admin", new { area = "Orchard.ImportExport" })))</p>
|
<div class="import-action">
|
||||||
<fieldset>
|
@Display(action.Editor)
|
||||||
<label for="RecipeFile">@T("Recipe File:")</label>
|
</div>
|
||||||
<input type="file" id="RecipeFile" size="64" name="RecipeFile" value="Browse..." />
|
}
|
||||||
</fieldset>
|
<button type="submit" class="primaryAction">@T("Import")</button>
|
||||||
<button type="submit" class="primaryAction">@T("Import")</button>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
@model Orchard.ImportExport.ViewModels.ResetSiteViewModel
|
||||||
|
<fieldset>
|
||||||
|
<div>
|
||||||
|
@Html.CheckBoxFor(m => m.ResetSite)
|
||||||
|
@Html.LabelFor(m => m.ResetSite, T("Reset Site").ToString(), new { @class = "forcheckbox" })
|
||||||
|
@Html.Hint(T("Check this option to completely clean your site before importing the uploaded recipe."))
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<p>
|
@model dynamic
|
||||||
|
<p>
|
||||||
@T("Choose a recipe file to import. Please consider {0} or backing up your data first.", @Html.Link(T("exporting").Text, Url.Action("Export", "Admin", new { area = "Orchard.ImportExport" })))
|
@T("Choose a recipe file to import. Please consider {0} or backing up your data first.", @Html.Link(T("exporting").Text, Url.Action("Export", "Admin", new { area = "Orchard.ImportExport" })))
|
||||||
</p>
|
</p>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
get { return T("Exports content items and content item definitions."); }
|
get { return T("Exports content items and content item definitions."); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Priority { get { return 10; } }
|
public override int Priority { get { return 20; } }
|
||||||
|
|
||||||
public IList<string> SchemaContentTypes { get; set; }
|
public IList<string> SchemaContentTypes { get; set; }
|
||||||
public IList<string> DataContentTypes { get; set; }
|
public IList<string> DataContentTypes { get; set; }
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
get { return T("Provides additional information about the recipe."); }
|
get { return T("Provides additional information about the recipe."); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Priority { get { return -10; } }
|
public override int Priority { get { return 1000; } }
|
||||||
|
|
||||||
public string RecipeName { get; set; }
|
public string RecipeName { get; set; }
|
||||||
public string RecipeDescription { get; set; }
|
public string RecipeDescription { get; set; }
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
get { return T("Exports settings."); }
|
get { return T("Exports settings."); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Priority { get { return 20; } }
|
public override int Priority { get { return 10; } }
|
||||||
|
|
||||||
public override dynamic BuildEditor(dynamic shapeFactory) {
|
public override dynamic BuildEditor(dynamic shapeFactory) {
|
||||||
return UpdateEditor(shapeFactory, null);
|
return UpdateEditor(shapeFactory, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user