-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor workflow import process with enhanced result handling (#360)
* Refactor workflow import process with enhanced result handling Introduced detailed workflow import result tracking through new models, including success and failure differentiation. Enhanced feedback mechanisms in UI based on import outcomes, providing clear success, warning, and error messages. Streamlined `ImportFilesAsync` to return structured results, improving code maintainability and user experience. * Update Snackbar behavior for workflow import results Adjusted Snackbar messages to include a consistent variant style and dynamic visibility durations based on import failures. Enhanced feedback clarity by removing file names from messages and introducing a helper function to configure Snackbar options. * Refactor workflow import logic for better readability. Replaced redundant variables and improved method returns to avoid side effects and ensure clarity. Enhanced error handling and added filtering for unnecessary zip entries (e.g., "__MACOSX"). These changes improve maintainability and robustness of the import logic.
- Loading branch information
1 parent
c0773bb
commit 5478948
Showing
8 changed files
with
150 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/modules/Elsa.Studio.Workflows.Core/Domain/Models/ImportOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Elsa.Api.Client.Resources.WorkflowDefinitions.Models; | ||
|
||
namespace Elsa.Studio.Workflows.Domain.Models; | ||
|
||
public class ImportOptions | ||
{ | ||
public int MaxAllowedSize { get; set; } = 1024 * 1024 * 10; // 10 MB | ||
public string? DefinitionId { get; set; } | ||
public Func<WorkflowDefinition, Task>? ImportedCallback { get; set; } | ||
public Func<Exception, Task> ErrorCallback { get; set; } | ||
} |
3 changes: 3 additions & 0 deletions
3
src/modules/Elsa.Studio.Workflows.Core/Domain/Models/WorkflowImportFailure.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Elsa.Studio.Workflows.Domain.Models; | ||
|
||
public record WorkflowImportFailure(string ErrorMessage, WorkflowImportFailureType FailureType); |
7 changes: 7 additions & 0 deletions
7
src/modules/Elsa.Studio.Workflows.Core/Domain/Models/WorkflowImportFailureType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Elsa.Studio.Workflows.Domain.Models; | ||
|
||
public enum WorkflowImportFailureType | ||
{ | ||
Exception, | ||
InvalidSchema | ||
} |
11 changes: 11 additions & 0 deletions
11
src/modules/Elsa.Studio.Workflows.Core/Domain/Models/WorkflowImportResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Elsa.Api.Client.Resources.WorkflowDefinitions.Models; | ||
|
||
namespace Elsa.Studio.Workflows.Domain.Models; | ||
|
||
public class WorkflowImportResult | ||
{ | ||
public string FileName { get; set; } | ||
public WorkflowDefinition? WorkflowDefinition { get; set; } | ||
public WorkflowImportFailure? Failure { get; set; } | ||
public bool IsSuccess => Failure == null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters