Skip to content

Commit a0ded8e

Browse files
authored
Merge pull request #519 from serverlessworkflow/feat-517-specify-workflow-operator
Added the posiblity to specify a target operator when creating a workflow/workflow instance.
2 parents 7d86e63 + fbaa891 commit a0ded8e

File tree

11 files changed

+485
-268
lines changed

11 files changed

+485
-268
lines changed

src/dashboard/Synapse.Dashboard/Components/CreateWorkflowInstanceDialog/CreateWorkflowInstanceDialog.razor

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@
4747
</Tab>
4848
</Tabs>
4949

50+
<div class="py-3">
51+
@if (Operators != null && Operators.Count() > 0)
52+
{
53+
<select class="form-select m-2" @onchange="OnSelectOperatorChanged">
54+
<option value="">Any Operator</option>
55+
@foreach (var op in Operators)
56+
{
57+
var name = op.GetName() + "." + op.GetNamespace();
58+
<option value="@name" selected="@(name == operatorName)">@name</option>
59+
}
60+
</select>
61+
}
62+
</div>
63+
5064
<div class="text-center">
5165
<Button Outline="true" Color="ButtonColor.Primary" class="m-auto mt-3 w-100" @onclick="async _ => await OnStartAsync()">
5266
<Icon Name="IconName.Play" />
@@ -61,10 +75,13 @@
6175
string payload = string.Empty;
6276
string modelName = string.Empty;
6377
EquatableDictionary<string, object>? input;
78+
string? operatorName;
6479

6580
[Parameter] public WorkflowDefinition? WorkflowDefinition { get; set; }
81+
[Parameter] public IEnumerable<Operator> Operators { get; set; } = [];
82+
[Parameter] public string? OperatorName { get; set; } = null;
6683
[Parameter] public EquatableDictionary<string, object>? Input { get; set; }
67-
[Parameter] public EventCallback<string> OnCreate { get; set; }
84+
[Parameter] public EventCallback<CreateWorkflowInstanceParameters> OnCreate { get; set; }
6885
[Parameter] public EventCallback<ProblemDetails> OnProblem { get; set; }
6986

7087
void OnValueChanged(object? value)
@@ -81,6 +98,7 @@
8198
{
8299
await base.OnParametersSetAsync();
83100
if (input != Input) input = Input;
101+
if (operatorName != OperatorName) operatorName = OperatorName;
84102
if (workflowDefinition != WorkflowDefinition)
85103
{
86104
workflowDefinition = WorkflowDefinition;
@@ -93,6 +111,11 @@
93111
}
94112
}
95113

114+
protected void OnSelectOperatorChanged(ChangeEventArgs e)
115+
{
116+
operatorName = e.Value?.ToString();
117+
}
118+
96119
async Task OnStartAsync()
97120
{
98121
if (schema != null)
@@ -111,7 +134,13 @@
111134
return;
112135
}
113136
}
114-
if (OnCreate.HasDelegate) await OnCreate.InvokeAsync(payload);
137+
if (OnCreate.HasDelegate)
138+
{
139+
await OnCreate.InvokeAsync(new CreateWorkflowInstanceParameters() {
140+
Input = payload,
141+
Operator = operatorName
142+
});
143+
}
115144
}
116145

117146
async Task LoadSchemaAsync()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright © 2024-Present The Synapse Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace Synapse.Dashboard.Components;
15+
16+
/// <summary>
17+
/// Represents the parameters for creating a new workflow instance.
18+
/// </summary>
19+
public record CreateWorkflowInstanceParameters
20+
{
21+
/// <summary>
22+
/// Gets/sets the workflow instance input.
23+
/// </summary>
24+
public string? Input { get; set; }
25+
26+
/// <summary>
27+
/// Gets/sets the workflow instance operator.
28+
/// </summary>
29+
public string? Operator { get; set; }
30+
}

src/dashboard/Synapse.Dashboard/Pages/Workflows/Create/State.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313

1414
using ServerlessWorkflow.Sdk.Models;
15+
using Synapse.Resources;
1516

1617
namespace Synapse.Dashboard.Pages.Workflows.Create;
1718

@@ -96,6 +97,16 @@ public record CreateWorkflowViewState
9697
/// </summary>
9798
public int ProblemStatus { get; set; } = 0;
9899

100+
/// <summary>
101+
/// Gets a <see cref="EquatableList{T}"/> that contains all <see cref="Operator"/>s
102+
/// </summary>
103+
public EquatableList<Operator>? Operators { get; set; }
104+
105+
/// <summary>
106+
/// Gets/sets the active operator filter
107+
/// </summary>
108+
public string? Operator { get; set; } = null;
109+
99110
/// <summary>
100111
/// Gets/sets the list of <see cref="ProblemDetails"/> errors that occurred when trying to save the resource, if any
101112
/// </summary>

0 commit comments

Comments
 (0)