Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DeploymentStepDriverBase & DeploymentStepFieldsDriverBase #16874

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;

namespace OrchardCore.AdminMenu.Deployment;

public sealed class AdminMenuDeploymentStepDriver : DisplayDriver<DeploymentStep, AdminMenuDeploymentStep>
public sealed class AdminMenuDeploymentStepDriver
: DeploymentStepFieldsDriverBase<AdminMenuDeploymentStep>
{
public override Task<IDisplayResult> DisplayAsync(AdminMenuDeploymentStep step, BuildDisplayContext context)
public AdminMenuDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
return
CombineAsync(
View("AdminMenuDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("AdminMenuDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(AdminMenuDeploymentStep step, BuildEditorContext context)
{
return View("AdminMenuDeploymentStep_Fields_Edit", step).Location("Content");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@

namespace OrchardCore.ContentTypes.Deployment;

public sealed class ContentDefinitionDeploymentStepDriver : DisplayDriver<DeploymentStep, ContentDefinitionDeploymentStep>
public sealed class ContentDefinitionDeploymentStepDriver
: DeploymentStepFieldsDriverBase<ContentDefinitionDeploymentStep, ContentDefinitionStepViewModel>
{
public override Task<IDisplayResult> DisplayAsync(ContentDefinitionDeploymentStep step, BuildDisplayContext context)
public ContentDefinitionDeploymentStepDriver(IServiceProvider serviceProvider): base(serviceProvider)
{
return
CombineAsync(
View("ContentDefinitionDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("ContentDefinitionDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(ContentDefinitionDeploymentStep step, BuildEditorContext context)
public override IDisplayResult Edit(ContentDefinitionDeploymentStep step, Action<ContentDefinitionStepViewModel> intializeAction)
{
return Initialize<ContentDefinitionStepViewModel>("ContentDefinitionDeploymentStep_Fields_Edit", model =>
return base.Edit(step, model =>
{
model.ContentParts = step.ContentParts;
model.ContentTypes = step.ContentTypes;
model.IncludeAll = step.IncludeAll;
}).Location("Content");
});
}

public override async Task<IDisplayResult> UpdateAsync(ContentDefinitionDeploymentStep step, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@

namespace OrchardCore.ContentTypes.Deployment;

public sealed class DeleteContentDefinitionDeploymentStepDriver : DisplayDriver<DeploymentStep, DeleteContentDefinitionDeploymentStep>
public sealed class DeleteContentDefinitionDeploymentStepDriver
: DeploymentStepFieldsDriverBase<DeleteContentDefinitionDeploymentStep, DeleteContentDefinitionStepViewModel>
{
private static readonly char[] _separator = [' ', ','];

public override Task<IDisplayResult> DisplayAsync(DeleteContentDefinitionDeploymentStep step, BuildDisplayContext context)
public DeleteContentDefinitionDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
return
CombineAsync(
View("DeleteContentDefinitionDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("DeleteContentDefinitionDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(DeleteContentDefinitionDeploymentStep step, BuildEditorContext context)
public override IDisplayResult Edit(DeleteContentDefinitionDeploymentStep step, Action<DeleteContentDefinitionStepViewModel> intializeAction)
{
return Initialize<DeleteContentDefinitionStepViewModel>("DeleteContentDefinitionDeploymentStep_Fields_Edit", model =>
return base.Edit(step, model =>
{
model.ContentParts = string.Join(", ", step.ContentParts);
model.ContentTypes = string.Join(", ", step.ContentTypes);
}).Location("Content");
});
}

public override async Task<IDisplayResult> UpdateAsync(DeleteContentDefinitionDeploymentStep step, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@

namespace OrchardCore.ContentTypes.Deployment;

public sealed class ReplaceContentDefinitionDeploymentStepDriver : DisplayDriver<DeploymentStep, ReplaceContentDefinitionDeploymentStep>
public sealed class ReplaceContentDefinitionDeploymentStepDriver
: DeploymentStepFieldsDriverBase<ReplaceContentDefinitionDeploymentStep, ReplaceContentDefinitionStepViewModel>
{
public override Task<IDisplayResult> DisplayAsync(ReplaceContentDefinitionDeploymentStep step, BuildDisplayContext context)
public ReplaceContentDefinitionDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
return
CombineAsync(
View("ReplaceContentDefinitionDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("ReplaceContentDefinitionDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(ReplaceContentDefinitionDeploymentStep step, BuildEditorContext context)
public override IDisplayResult Edit(ReplaceContentDefinitionDeploymentStep step, Action<ReplaceContentDefinitionStepViewModel> intializeAction)
{
return Initialize<ReplaceContentDefinitionStepViewModel>("ReplaceContentDefinitionDeploymentStep_Fields_Edit", model =>
return base.Edit(step, model =>
{
model.ContentParts = step.ContentParts;
model.ContentTypes = step.ContentTypes;
model.IncludeAll = step.IncludeAll;
}).Location("Content");
});
}

public override async Task<IDisplayResult> UpdateAsync(ReplaceContentDefinitionDeploymentStep step, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using OrchardCore.ContentManagement;
using OrchardCore.Deployment;
Expand All @@ -7,34 +8,25 @@

namespace OrchardCore.Contents.Deployment.AddToDeploymentPlan;

public sealed class ContentItemDeploymentStepDriver : DisplayDriver<DeploymentStep, ContentItemDeploymentStep>
public sealed class ContentItemDeploymentStepDriver
: DeploymentStepFieldsDriverBase<ContentItemDeploymentStep, ContentItemDeploymentStepViewModel>
{
private readonly IContentManager _contentManager;

internal readonly IStringLocalizer S;

public ContentItemDeploymentStepDriver(IContentManager contentManager,
IStringLocalizer<ContentItemDeploymentStepDriver> stringLocalizer)
public ContentItemDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
_contentManager = contentManager;
S = stringLocalizer;
_contentManager = serviceProvider.GetService<IContentManager>();
S = serviceProvider.GetService<IStringLocalizer<ContentItemDeploymentStepDriver>>();
}

public override Task<IDisplayResult> DisplayAsync(ContentItemDeploymentStep step, BuildDisplayContext context)
public override IDisplayResult Edit(ContentItemDeploymentStep step, Action<ContentItemDeploymentStepViewModel> intializeAction)
{
return
CombineAsync(
View("ContentItemDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("ContentItemDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(ContentItemDeploymentStep step, BuildEditorContext context)
{
return Initialize<ContentItemDeploymentStepViewModel>("ContentItemDeploymentStep_Fields_Edit", model =>
return base.Edit(step, model =>
{
model.ContentItemId = step.ContentItemId;
}).Location("Content");
});
}

public override async Task<IDisplayResult> UpdateAsync(ContentItemDeploymentStep step, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@

namespace OrchardCore.Contents.Deployment;

public sealed class AllContentDeploymentStepDriver : DisplayDriver<DeploymentStep, AllContentDeploymentStep>
public sealed class AllContentDeploymentStepDriver
: DeploymentStepFieldsDriverBase<AllContentDeploymentStep, AllContentDeploymentStepViewModel>
{
public override Task<IDisplayResult> DisplayAsync(AllContentDeploymentStep step, BuildDisplayContext context)
public AllContentDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
return
CombineAsync(
View("AllContentDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("AllContentDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(AllContentDeploymentStep step, BuildEditorContext context)
public override IDisplayResult Edit(AllContentDeploymentStep step, Action<AllContentDeploymentStepViewModel> intializeAction)
{
return Initialize<AllContentDeploymentStepViewModel>("AllContentDeploymentStep_Fields_Edit", model =>
return base.Edit(step, model =>
{
model.ExportAsSetupRecipe = step.ExportAsSetupRecipe;
}).Location("Content");
});
}

public override async Task<IDisplayResult> UpdateAsync(AllContentDeploymentStep step, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@

namespace OrchardCore.Contents.Deployment;

public sealed class ContentDeploymentStepDriver : DisplayDriver<DeploymentStep, ContentDeploymentStep>
public sealed class ContentDeploymentStepDriver
: DeploymentStepFieldsDriverBase<ContentDeploymentStep, ContentDeploymentStepViewModel>
{
public override Task<IDisplayResult> DisplayAsync(ContentDeploymentStep step, BuildDisplayContext context)
public ContentDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
return
CombineAsync(
View("ContentDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("ContentDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(ContentDeploymentStep step, BuildEditorContext context)
public override IDisplayResult Edit(ContentDeploymentStep step, Action<ContentDeploymentStepViewModel> intializeAction)
{
return Initialize<ContentDeploymentStepViewModel>("ContentDeploymentStep_Fields_Edit", model =>
return base.Edit(step, model =>
{
model.ContentTypes = step.ContentTypes;
model.ExportAsSetupRecipe = step.ExportAsSetupRecipe;
}).Location("Content");
});
}

public override async Task<IDisplayResult> UpdateAsync(ContentDeploymentStep step, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;

namespace OrchardCore.Contents.Deployment.ExportContentToDeploymentTarget;

public sealed class ExportContentToDeploymentTargetDeploymentStepDriver : DisplayDriver<DeploymentStep, ExportContentToDeploymentTargetDeploymentStep>
public sealed class ExportContentToDeploymentTargetDeploymentStepDriver
: DeploymentStepFieldsDriverBase<ExportContentToDeploymentTargetDeploymentStep>
{
public override Task<IDisplayResult> DisplayAsync(ExportContentToDeploymentTargetDeploymentStep step, BuildDisplayContext context)
public ExportContentToDeploymentTargetDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
return
CombineAsync(
View("ExportContentToDeploymentTargetDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("ExportContentToDeploymentTargetDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(ExportContentToDeploymentTargetDeploymentStep step, BuildEditorContext context)
{
return View("ExportContentToDeploymentTargetDeploymentStep_Fields_Edit", step).Location("Content");
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.CustomSettings.Services;
using OrchardCore.CustomSettings.ViewModels;
using OrchardCore.Deployment;
Expand All @@ -6,32 +7,24 @@

namespace OrchardCore.CustomSettings.Deployment;

public sealed class CustomSettingsDeploymentStepDriver : DisplayDriver<DeploymentStep, CustomSettingsDeploymentStep>
public sealed class CustomSettingsDeploymentStepDriver
: DeploymentStepFieldsDriverBase<CustomSettingsDeploymentStep, CustomSettingsDeploymentStepViewModel>
{
private readonly CustomSettingsService _customSettingsService;

public CustomSettingsDeploymentStepDriver(CustomSettingsService customSettingsService)
public CustomSettingsDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
_customSettingsService = customSettingsService;
_customSettingsService = serviceProvider.GetService<CustomSettingsService>();
}

public override Task<IDisplayResult> DisplayAsync(CustomSettingsDeploymentStep step, BuildDisplayContext context)
public override IDisplayResult Edit(CustomSettingsDeploymentStep step, Action<CustomSettingsDeploymentStepViewModel> intializeAction)
{
return
CombineAsync(
View("CustomSettingsDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("CustomSettingsDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(CustomSettingsDeploymentStep step, BuildEditorContext context)
{
return Initialize<CustomSettingsDeploymentStepViewModel>("CustomSettingsDeploymentStep_Fields_Edit", async model =>
return base.Edit(step, async model =>
{
model.IncludeAll = step.IncludeAll;
model.SettingsTypeNames = step.SettingsTypeNames;
model.AllSettingsTypeNames = (await _customSettingsService.GetAllSettingsTypeNamesAsync()).ToArray();
}).Location("Content");
});
}

public override async Task<IDisplayResult> UpdateAsync(CustomSettingsDeploymentStep step, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Deployment.ViewModels;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;

namespace OrchardCore.Deployment.Deployment;

public sealed class DeploymentPlanDeploymentStepDriver : DisplayDriver<DeploymentStep, DeploymentPlanDeploymentStep>
public sealed class DeploymentPlanDeploymentStepDriver
: DeploymentStepFieldsDriverBase<DeploymentPlanDeploymentStep, DeploymentPlanDeploymentStepViewModel>
{
private readonly IDeploymentPlanService _deploymentPlanService;

public DeploymentPlanDeploymentStepDriver(IDeploymentPlanService deploymentPlanService)
public DeploymentPlanDeploymentStepDriver(IServiceProvider serviceProvider) : base(serviceProvider)
{
_deploymentPlanService = deploymentPlanService;
_deploymentPlanService = serviceProvider.GetService<IDeploymentPlanService>();
}

public override Task<IDisplayResult> DisplayAsync(DeploymentPlanDeploymentStep step, BuildDisplayContext context)
public override IDisplayResult Edit(DeploymentPlanDeploymentStep step, Action<DeploymentPlanDeploymentStepViewModel> intializeAction)
{
return
CombineAsync(
View("DeploymentPlanDeploymentStep_Fields_Summary", step).Location("Summary", "Content"),
View("DeploymentPlanDeploymentStep_Fields_Thumbnail", step).Location("Thumbnail", "Content")
);
}

public override IDisplayResult Edit(DeploymentPlanDeploymentStep step, BuildEditorContext context)
{
return Initialize<DeploymentPlanDeploymentStepViewModel>("DeploymentPlanDeploymentStep_Fields_Edit", async model =>
return base.Edit(step, async model =>
{
model.IncludeAll = step.IncludeAll;
model.DeploymentPlanNames = step.DeploymentPlanNames;
model.AllDeploymentPlanNames = (await _deploymentPlanService.GetAllDeploymentPlanNamesAsync()).ToArray();
}).Location("Content");
});
}

public override async Task<IDisplayResult> UpdateAsync(DeploymentPlanDeploymentStep step, UpdateEditorContext context)
Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public override void ConfigureServices(IServiceCollection services)
services.AddSingleton<IDeploymentTargetProvider, FileDownloadDeploymentTargetProvider>();

// Custom File deployment step
services.AddDeployment<CustomFileDeploymentSource, CustomFileDeploymentStep, CustomFileDeploymentStepDriver>();
services.AddDeployment<CustomFileDeploymentSource, CustomFileDeploymentStep, CustomFileDeploymentStepFieldsDriver>();

// Recipe File deployment step
services.AddDeploymentWithoutSource<RecipeFileDeploymentStep, RecipeFileDeploymentStepDriver>();
services.AddDeploymentWithoutSource<RecipeFileDeploymentStep, RecipeFileDeploymentStepFieldsDriver>();

services.AddIndexProvider<DeploymentPlanIndexProvider>();
services.AddDataMigration<Migrations>();
Expand Down

This file was deleted.

Loading