-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Export specific workflow #11939
Export specific workflow #11939
Conversation
@Skrypt Can you review this PR? |
Could you please share a GIF screenshot shows how to export the workflow and import it then |
try mp4 file msedge_qghN7nTjmh.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format the code, there are many things to fix
@@ -127,7 +131,7 @@ public async Task<IActionResult> Index(WorkflowTypeIndexOptions options, PagerPa | |||
|
|||
var workflowTypeIds = workflowTypes.Select(x => x.WorkflowTypeId).ToList(); | |||
var workflowGroups = (await _session.QueryIndex<WorkflowIndex>(x => x.WorkflowTypeId.IsIn(workflowTypeIds)) | |||
.ListAsync()) | |||
.ListAsync()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not reeolved, there's double tabs here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
var deploymentPlanResult = new DeploymentPlanResult(fileBuilder, recipeDescriptor); | ||
var data = new JArray(); | ||
deploymentPlanResult.Steps.Add(new JObject( | ||
new JProperty("name", "WorkflowType"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add intendation
foreach (var workflow in await _workflowTypeStore.GetAsync(itemIds)) | ||
{ | ||
var objectData = JObject.FromObject(workflow); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
objectData.Remove(nameof(workflow.Id)); | ||
data.Add(objectData); | ||
} | ||
await deploymentPlanResult.FinalizeAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line before
} | ||
await deploymentPlanResult.FinalizeAsync(); | ||
ZipFile.CreateFromDirectory(fileBuilder.Folder, archiveFileName); | ||
return archiveFileName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line before
await deploymentPlanResult.FinalizeAsync(); | ||
ZipFile.CreateFromDirectory(fileBuilder.Folder, archiveFileName); | ||
return archiveFileName; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line
@@ -207,6 +218,44 @@ public async Task<IActionResult> BulkEdit(WorkflowTypeIndexOptions options, IEnu | |||
return RedirectToAction(nameof(Index)); | |||
} | |||
|
|||
private async Task<string> ExportWorkflows(params int[] itemIds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the private methods at the end
{ | ||
return Forbid(); | ||
} | ||
var resultFileName = await ExportWorkflows(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add line before
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please double check the format for the entire PR before you request a review to save time
Thanks for your contribution again
@@ -127,7 +131,7 @@ public async Task<IActionResult> Index(WorkflowTypeIndexOptions options, PagerPa | |||
|
|||
var workflowTypeIds = workflowTypes.Select(x => x.WorkflowTypeId).ToList(); | |||
var workflowGroups = (await _session.QueryIndex<WorkflowIndex>(x => x.WorkflowTypeId.IsIn(workflowTypeIds)) | |||
.ListAsync()) | |||
.ListAsync()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not reeolved, there's double tabs here
: Url.IsLocalUrl(viewModel.ReturnUrl) | ||
? (IActionResult)this.Redirect(viewModel.ReturnUrl, true) | ||
: RedirectToAction(nameof(Index)); | ||
? (IActionResult)this.Redirect(viewModel.ReturnUrl, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original version of this place has 3 spaces indented, and the automatic indent should be 4, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this space is extra, not resolved yet!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this space is extra, not resolved yet!
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/OrchardCore.Workflows.csproj
Show resolved
Hide resolved
@@ -46,6 +46,7 @@ | |||
@T["Actions"] | |||
</button> | |||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bulk-action-menu-button"> | |||
<li><a class="dropdown-item" href="javascript:void(0)" data-action="Export" data-title="@T["Bulk Action"]" >Export</a></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems there's n extra space ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we going to do here?
src/OrchardCore.Modules/OrchardCore.Workflows/Views/WorkflowType/Index.cshtml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpicks, but almost done.
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
…rkflowTypeDeploymentSource.cs Co-authored-by: Zoltán Lehóczky <[email protected]>
…flowTypeController.cs Co-authored-by: Zoltán Lehóczky <[email protected]>
@hyzx86, I've reviewed the changes related to the Processing Logic for
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hishamco up to you, please approve/merge if suitable.
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Outdated
Show resolved
Hide resolved
…flowTypeController.cs
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Deployment/AllWorkflowTypeDeploymentSource.cs
Outdated
Show resolved
Hide resolved
…rkflowTypeDeploymentSource.cs
@hishamco when you see this, you can just clone the fork and commit to it directly, no need to suffer through self-approved code suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
private readonly IUpdateModelAccessor _updateModelAccessor; | ||
private readonly IShapeFactory _shapeFactory; | ||
private readonly JsonSerializerOptions _documentJsonSerializerOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field _documentJsonSerializerOptions
should be renamed to _jsonSerializerOptions
to match its usage throughout the class.
- private readonly JsonSerializerOptions _documentJsonSerializerOptions;
+ private readonly JsonSerializerOptions _jsonSerializerOptions;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
private readonly JsonSerializerOptions _documentJsonSerializerOptions; | |
private readonly JsonSerializerOptions _jsonSerializerOptions; |
IStringLocalizer<WorkflowTypeController> stringLocalizer, | ||
IHtmlLocalizer<WorkflowTypeController> htmlLocalizer, | ||
IUpdateModelAccessor updateModelAccessor) | ||
IUpdateModelAccessor updateModelAccessor, | ||
IOptions<DocumentJsonSerializerOptions> jsonSerializerOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor parameter should be named documentJsonSerializerOptions
to match the field it initializes.
- IOptions<DocumentJsonSerializerOptions> jsonSerializerOptions)
+ IOptions<DocumentJsonSerializerOptions> documentJsonSerializerOptions)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
IOptions<DocumentJsonSerializerOptions> jsonSerializerOptions) | |
IOptions<DocumentJsonSerializerOptions> documentJsonSerializerOptions) |
_updateModelAccessor = updateModelAccessor; | ||
_shapeFactory = shapeFactory; | ||
S = stringLocalizer; | ||
H = htmlLocalizer; | ||
_documentJsonSerializerOptions = jsonSerializerOptions.Value.SerializerOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assignment to _documentJsonSerializerOptions
should use the corrected field name _jsonSerializerOptions
.
- _documentJsonSerializerOptions = jsonSerializerOptions.Value.SerializerOptions;
+ _jsonSerializerOptions = documentJsonSerializerOptions.Value.SerializerOptions;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
_documentJsonSerializerOptions = jsonSerializerOptions.Value.SerializerOptions; | |
_jsonSerializerOptions = documentJsonSerializerOptions.Value.SerializerOptions; |
@@ -192,6 +198,9 @@ public async Task<IActionResult> BulkEdit(WorkflowTypeIndexOptions options, IEnu | |||
{ | |||
case WorkflowTypeBulkAction.None: | |||
break; | |||
case WorkflowTypeBulkAction.Export: | |||
return await ExportWorkflows(itemIds.ToArray()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid duplicate calls to ExportWorkflows
. Ensure that the method is called only once per action to prevent performance issues.
- return await ExportWorkflows(itemIds.ToArray());
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
return await ExportWorkflows(itemIds.ToArray()); |
public async Task<IActionResult> Export(int id) | ||
{ | ||
if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageWorkflows)) | ||
{ | ||
return Forbid(); | ||
} | ||
|
||
return await ExportWorkflows(id); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Export
method should be decorated with the [HttpGet]
attribute since it is handling a GET request, not a POST.
+ [HttpGet]
public async Task<IActionResult> Export(int id)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
public async Task<IActionResult> Export(int id) | |
{ | |
if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageWorkflows)) | |
{ | |
return Forbid(); | |
} | |
return await ExportWorkflows(id); | |
} | |
[HttpGet] | |
public async Task<IActionResult> Export(int id) | |
{ | |
if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageWorkflows)) | |
{ | |
return Forbid(); | |
} | |
return await ExportWorkflows(id); | |
} |
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Controllers/WorkflowTypeController.cs
Show resolved
Hide resolved
I remember one time ago I accidentally overridden someone else commits :( |
Export the specified workflow from the workflow management interface