Merge remote-tracking branch 'origin/develop/3.6.0' into develop/3.6.0

This commit is contained in:
Sipke Schoorstra 2025-09-15 18:53:02 +02:00
commit 4f4263e544
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F
4 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,28 @@
using System.Diagnostics;
using Elsa.Expressions.Contracts;
using Elsa.Expressions.Models;
using Elsa.Extensions;
using Elsa.Workflows.Memory;
using Elsa.Workflows.Models;
namespace Elsa.Workflows.Expressions;
/// <summary>
/// Handles Input expressions.
/// </summary>
public class InputExpressionHandler : IExpressionHandler
{
/// <inheritdoc />
public ValueTask<object?> EvaluateAsync(Expression expression, Type returnType, ExpressionExecutionContext context, ExpressionEvaluatorOptions options)
{
object? result = null;
var inputDefinition = expression.Value as InputDefinition;
if (inputDefinition != null)
{
result = context.GetInput(inputDefinition.Name);
}
return ValueTask.FromResult(result);
}
}

View file

@ -199,6 +199,9 @@ public class ActivityDescriber(IPropertyDefaultValueResolver defaultValueResolve
if (wrappedPropertyType == typeof(Variable))
return InputUIHints.VariablePicker;
if (wrappedPropertyType == typeof(WorkflowInput))
return InputUIHints.InputPicker;
if (wrappedPropertyType == typeof(Type))
return InputUIHints.TypePicker;

View file

@ -23,5 +23,6 @@ public static class InputUIHints
public const string SingleLine = "singleline";
public const string TypePicker = "type-picker";
public const string VariablePicker = "variable-picker";
public const string InputPicker = "input-picker";
public const string WorkflowDefinitionPicker = "workflow-definition-picker";
}

View file

@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Text.Json;
using Elsa.Expressions;
using Elsa.Expressions.Contracts;
@ -5,6 +6,7 @@ using Elsa.Expressions.Models;
using Elsa.Extensions;
using Elsa.Workflows.Expressions;
using Elsa.Workflows.Memory;
using Elsa.Workflows.Models;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Workflows.Management.Providers;
@ -20,6 +22,7 @@ public class DefaultExpressionDescriptorProvider : IExpressionDescriptorProvider
yield return CreateJsonDescriptor();
yield return CreateDelegateDescriptor();
yield return CreateVariableDescriptor();
yield return CreateInputDescriptor();
}
private ExpressionDescriptor CreateLiteralDescriptor()
@ -72,6 +75,33 @@ public class DefaultExpressionDescriptorProvider : IExpressionDescriptorProvider
);
}
private ExpressionDescriptor CreateInputDescriptor()
{
return CreateDescriptor<InputExpressionHandler>(
"Input",
"Input", // Displayed text in UI (input selection dropdown)
isBrowsable: true,
deserialize: context =>
{
var valueElement = context.JsonElement.TryGetProperty("value", out var v) ? v : default;
var valueString = valueElement.GetValue()?.ToString();
if (string.IsNullOrWhiteSpace(valueString)) return new Expression("Input", null);
try
{
var value = JsonSerializer.Deserialize(valueString, typeof(InputDefinition), context.Options);
return new Expression("Input", value);
}
catch (Exception)
{
return new Expression("Input", null);
}
}
);
}
private static ExpressionDescriptor CreateDescriptor<THandler>(
string expressionType,
string displayName,