-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[FIX] cannot end a flowchart when a End is Then Activity in If #5899
Open
iio888
wants to merge
26
commits into
elsa-workflows:main
Choose a base branch
from
iio888:fix-end-flowchart
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−4
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b664160
Update End.cs
iio888 c8781b4
Update Flowchart.cs
iio888 489ed12
Create BreakWhileFlowchartWorkflow.cs
iio888 93c3417
Update BreakTests.cs
iio888 5eaf2dc
Create EndFlowchartWorkflow.cs
iio888 62d2345
Create EndTests.cs
iio888 6dd52ea
Merge branch 'main' into fix-end-flowchart
iio888 8f853b2
Clean Flowchart.cs
iio888 36ebf0d
Create EndSignal.cs
iio888 b461cc1
Send EndSignal in End
iio888 7d4fd32
Create EndSignalActivityExecutionContextExtensions.cs
iio888 c599a95
Change BreakSignal to EndSignal
iio888 7ae703f
Merge branch 'main' into fix-end-flowchart
iio888 822420e
Merge branch 'main' into fix-end-flowchart
iio888 c0390c6
Send EndSignal when Break
iio888 ff003f0
Prevent bubbling when received EndSignal
iio888 8a8afb2
Merge branch 'main' into fix-end-flowchart
sfmskywalker 09cffa1
Merge branch 'elsa-workflows:main' into fix-end-flowchart
iio888 7044f86
Remove Sending EndSignal in Break Activity
iio888 dca229e
Receive BreakSignal in Flowchart
iio888 184ca1e
Remove StopPropagation in BreakSignal
iio888 456ad94
Merge branch 'main' into fix-end-flowchart
iio888 c11ffae
Merge branch 'main' into fix-end-flowchart
iio888 9d6c4ff
Merge branch 'main' into fix-end-flowchart
sfmskywalker f0f7c0c
Fix spell error
iio888 1faec5b
Merge branch 'main' into fix-end-flowchart
iio888 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
14 changes: 14 additions & 0 deletions
14
src/modules/Elsa.Workflows.Core/Extensions/EndSignalActivityExecutionContextExtensions.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,14 @@ | ||
namespace Elsa.Workflows.Extensions; | ||
|
||
public static class EndSignalActivityExecutionContextExtensions | ||
{ | ||
/// <summary> | ||
/// Gets a value indicating whether the current activity is ending out of a flowchart. | ||
/// </summary> | ||
public static bool GetIsEnding(this ActivityExecutionContext context) => context.GetProperty<bool>("IsEnding"); | ||
|
||
/// <summary> | ||
/// Sets a value indicating whether the current activity is ending out of a flowchart. | ||
/// <summary> | ||
public static void SetIsEnding(this ActivityExecutionContext context) => context.SetProperty("IsEnding", true); | ||
} |
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.Workflows.Signals; | ||
|
||
public record EndSignal; |
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
31 changes: 31 additions & 0 deletions
31
...Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileFlowchartWorkflow.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,31 @@ | ||
using Elsa.Workflows.Activities.Flowchart.Models; | ||
using Elsa.Workflows.Activities; | ||
using Elsa.Workflows.Activities.Flowchart.Activities; | ||
using Elsa.Workflows.Contracts; | ||
|
||
namespaces Elsa.Workflows.IntegrationTests.Activities.Workflows; | ||
public class BreakWhileFlowchart : WorkflowBase | ||
{ | ||
protected override void Build(IWorkflowBuilder workflow) | ||
{ | ||
WtiteLine start = new("start"); | ||
WriteLine end = new("end"); | ||
If condition = new If(c => true) | ||
{ | ||
Then = new Break() | ||
}; | ||
|
||
workflow.Root = While.True(new Flowchart() | ||
{ | ||
Activities = | ||
{ | ||
start, condition, end | ||
}, | ||
Connections = | ||
{ | ||
new Connection(start, condition), | ||
new Connection(condition, end), | ||
} | ||
}); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
test/integration/Elsa.Workflows.IntegrationTests/Activities/End/EndFlowchartWorkflow.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,29 @@ | ||
using Elsa.Workflows.Activities.Flowchart.Models; | ||
using Elsa.Workflows.Activities; | ||
using Elsa.Workflows.Activities.Flowchart.Activities; | ||
using Elsa.Workflows.Contracts; | ||
|
||
namespace Elsa.Workflows.IntegrationTests.Activities.Workflows; | ||
public class EndFlowchartWorkflow : WorkflowBase | ||
{ | ||
protected override void Build(IWorkflowBuilder workflow) | ||
{ | ||
WriteLine start = new("start"); | ||
WriteLine end = new("end"); | ||
If condition = new(c => true) | ||
{ | ||
Then = new End() | ||
}; | ||
|
||
workflow.Root = new Flowchart() | ||
{ | ||
Activities = { | ||
start, condition, end | ||
}, | ||
Connections = { | ||
new Connection(start, condition), | ||
new Connection(condition, end), | ||
} | ||
}; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
test/integration/Elsa.Workflows.IntegrationTests/Activities/End/EndTests.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,29 @@ | ||
using Elsa.Testing.Shared; | ||
using Elsa.Workflows.Contracts; | ||
using Elsa.Workflows.IntegrationTests.Activities.Workflows; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Xunit; | ||
using Xunit.Abstraction; | ||
|
||
namespace Elsa.Workflows.IntegrationTests,Activities; | ||
public class EndTests | ||
{ | ||
private readonly IWorkflowRunner _workflowRunner; | ||
private readonly CapturingTextWriter _capturingTextWriter = new(); | ||
private readonly IServiceProvider _services; | ||
|
||
public EndTests(ITestOutputHelper testOutputHelper) | ||
{ | ||
_services = new TestApplicationBuilder(testOutputHelper).WithCapturingTextWriter(_capturingTextWriter).Build(); | ||
_workflowRunner = _services.GetRequiredService<IWorkflowRunner>(); | ||
} | ||
|
||
[Fact(DisplayName = "End a flowchart when the End is nested in If")] | ||
public async Task Test1() | ||
{ | ||
await _services.PopulateRegistriesAsync(); | ||
await _workflowRunner.RunAsync<EndFlowchartWorkflow>(); | ||
var lines = _capturingTextWriter.Lines.ToList(); | ||
Assert.Equal(new[] { "start" }, lines); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why does the Flowchart activity need to handle the Break signal?