Skip to content
Merged
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
Expand Up @@ -47,6 +47,20 @@
</Tab>
</Tabs>

<div class="py-3">
@if (Operators != null && Operators.Count() > 0)
{
<select class="form-select m-2" @onchange="OnSelectOperatorChanged">
<option value="">Any Operator</option>
@foreach (var op in Operators)
{
var name = op.GetName() + "." + op.GetNamespace();
<option value="@name" selected="@(name == operatorName)">@name</option>
}
</select>
}
</div>

<div class="text-center">
<Button Outline="true" Color="ButtonColor.Primary" class="m-auto mt-3 w-100" @onclick="async _ => await OnStartAsync()">
<Icon Name="IconName.Play" />
Expand All @@ -61,10 +75,13 @@
string payload = string.Empty;
string modelName = string.Empty;
EquatableDictionary<string, object>? input;
string? operatorName;

[Parameter] public WorkflowDefinition? WorkflowDefinition { get; set; }
[Parameter] public IEnumerable<Operator> Operators { get; set; } = [];
[Parameter] public string? OperatorName { get; set; } = null;
[Parameter] public EquatableDictionary<string, object>? Input { get; set; }
[Parameter] public EventCallback<string> OnCreate { get; set; }
[Parameter] public EventCallback<CreateWorkflowInstanceParameters> OnCreate { get; set; }
[Parameter] public EventCallback<ProblemDetails> OnProblem { get; set; }

void OnValueChanged(object? value)
Expand All @@ -81,6 +98,7 @@
{
await base.OnParametersSetAsync();
if (input != Input) input = Input;
if (operatorName != OperatorName) operatorName = OperatorName;
if (workflowDefinition != WorkflowDefinition)
{
workflowDefinition = WorkflowDefinition;
Expand All @@ -93,6 +111,11 @@
}
}

protected void OnSelectOperatorChanged(ChangeEventArgs e)
{
operatorName = e.Value?.ToString();
}

async Task OnStartAsync()
{
if (schema != null)
Expand All @@ -111,7 +134,13 @@
return;
}
}
if (OnCreate.HasDelegate) await OnCreate.InvokeAsync(payload);
if (OnCreate.HasDelegate)
{
await OnCreate.InvokeAsync(new CreateWorkflowInstanceParameters() {
Input = payload,
Operator = operatorName
});
}
}

async Task LoadSchemaAsync()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright © 2024-Present The Synapse Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Synapse.Dashboard.Components;

/// <summary>
/// Represents the parameters for creating a new workflow instance.
/// </summary>
public record CreateWorkflowInstanceParameters
{
/// <summary>
/// Gets/sets the workflow instance input.
/// </summary>
public string? Input { get; set; }

/// <summary>
/// Gets/sets the workflow instance operator.
/// </summary>
public string? Operator { get; set; }
}
11 changes: 11 additions & 0 deletions src/dashboard/Synapse.Dashboard/Pages/Workflows/Create/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.

using ServerlessWorkflow.Sdk.Models;
using Synapse.Resources;

namespace Synapse.Dashboard.Pages.Workflows.Create;

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

/// <summary>
/// Gets a <see cref="EquatableList{T}"/> that contains all <see cref="Operator"/>s
/// </summary>
public EquatableList<Operator>? Operators { get; set; }

/// <summary>
/// Gets/sets the active operator filter
/// </summary>
public string? Operator { get; set; } = null;

/// <summary>
/// Gets/sets the list of <see cref="ProblemDetails"/> errors that occurred when trying to save the resource, if any
/// </summary>
Expand Down
Loading