From aabf9ff2c2d627999e28d1dbf0fc6a3584261cf6 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 4 Apr 2021 15:31:40 +0200 Subject: [PATCH] Configure primitive activities --- .../Primitives/Correlate/Correlate.cs | 3 +- .../Primitives/SetContextId/SetContextId.cs | 3 +- .../Activities/Primitives/SetName/SetName.cs | 3 +- .../SetTransientVariable.cs | 3 +- .../Primitives/SetVariable/SetVariable.cs | 3 +- .../InterruptTrigger/InterruptTrigger.cs | 7 ++- .../Activities/SendSignal/SendSignal.cs | 7 ++- .../SignalReceived/SignalReceived.cs | 3 +- .../Workflows/RunWorkflow/RunWorkflow.cs | 55 ++++++++++++++++--- 9 files changed, 67 insertions(+), 20 deletions(-) diff --git a/src/core/Elsa.Core/Activities/Primitives/Correlate/Correlate.cs b/src/core/Elsa.Core/Activities/Primitives/Correlate/Correlate.cs index db2ff7765..1366a6480 100644 --- a/src/core/Elsa.Core/Activities/Primitives/Correlate/Correlate.cs +++ b/src/core/Elsa.Core/Activities/Primitives/Correlate/Correlate.cs @@ -1,5 +1,6 @@ using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Expressions; using Elsa.Services; // ReSharper disable once CheckNamespace @@ -15,7 +16,7 @@ namespace Elsa.Activities.Primitives )] public class Correlate : Activity { - [ActivityProperty(Hint = "An expression that evaluates to the value to store as the correlation ID.")] + [ActivityProperty(Hint = "An expression that evaluates to the value to store as the correlation ID.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public string Value { get; set; } = default!; protected override IActivityExecutionResult OnExecute() => Combine(Done(Value), new CorrelateResult(Value)); diff --git a/src/core/Elsa.Core/Activities/Primitives/SetContextId/SetContextId.cs b/src/core/Elsa.Core/Activities/Primitives/SetContextId/SetContextId.cs index cc44ec9ff..ca1bc400e 100644 --- a/src/core/Elsa.Core/Activities/Primitives/SetContextId/SetContextId.cs +++ b/src/core/Elsa.Core/Activities/Primitives/SetContextId/SetContextId.cs @@ -1,5 +1,6 @@ using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Expressions; using Elsa.Services; using Elsa.Services.Models; @@ -14,7 +15,7 @@ namespace Elsa.Activities.Primitives )] public class SetContextId : Activity { - [ActivityProperty(Hint = "The context ID to set.")] + [ActivityProperty(Hint = "The context ID to set.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public string ContextId { get; set; } = default!; protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context) diff --git a/src/core/Elsa.Core/Activities/Primitives/SetName/SetName.cs b/src/core/Elsa.Core/Activities/Primitives/SetName/SetName.cs index fdaee075f..fd60542ae 100644 --- a/src/core/Elsa.Core/Activities/Primitives/SetName/SetName.cs +++ b/src/core/Elsa.Core/Activities/Primitives/SetName/SetName.cs @@ -1,5 +1,6 @@ using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Expressions; using Elsa.Services; using Elsa.Services.Models; @@ -14,7 +15,7 @@ namespace Elsa.Activities.Primitives )] public class SetName : Activity { - [ActivityProperty(Hint = "The value to set as the workflow instance's name.")] + [ActivityProperty(Hint = "The value to set as the workflow instance's name.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public string? Value { get; set; } protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context) diff --git a/src/core/Elsa.Core/Activities/Primitives/SetTransientVariable/SetTransientVariable.cs b/src/core/Elsa.Core/Activities/Primitives/SetTransientVariable/SetTransientVariable.cs index 0a01c1618..2c98a65d5 100644 --- a/src/core/Elsa.Core/Activities/Primitives/SetTransientVariable/SetTransientVariable.cs +++ b/src/core/Elsa.Core/Activities/Primitives/SetTransientVariable/SetTransientVariable.cs @@ -1,5 +1,6 @@ using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Expressions; using Elsa.Services; using Elsa.Services.Models; @@ -17,7 +18,7 @@ namespace Elsa.Activities.Primitives [ActivityProperty(Hint = "The name of the transient variable to store the value into.")] public string VariableName { get; set; } = default!; - [ActivityProperty(Hint = "The value to store in the transient variable.")] + [ActivityProperty(Hint = "The value to store in the transient variable.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public object? Value { get; set; } protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context) diff --git a/src/core/Elsa.Core/Activities/Primitives/SetVariable/SetVariable.cs b/src/core/Elsa.Core/Activities/Primitives/SetVariable/SetVariable.cs index ec597c4b4..72c830c28 100644 --- a/src/core/Elsa.Core/Activities/Primitives/SetVariable/SetVariable.cs +++ b/src/core/Elsa.Core/Activities/Primitives/SetVariable/SetVariable.cs @@ -1,5 +1,6 @@ using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Expressions; using Elsa.Services; using Elsa.Services.Models; @@ -17,7 +18,7 @@ namespace Elsa.Activities.Primitives [ActivityProperty(Hint = "The name of the variable to store the value into.")] public string VariableName { get; set; } = default!; - [ActivityProperty(Hint = "The value to store in the variable.")] + [ActivityProperty(Hint = "The value to store in the variable.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public object? Value { get; set; } protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context) diff --git a/src/core/Elsa.Core/Activities/Signaling/Activities/InterruptTrigger/InterruptTrigger.cs b/src/core/Elsa.Core/Activities/Signaling/Activities/InterruptTrigger/InterruptTrigger.cs index 857c1e2e1..0e4fc905f 100644 --- a/src/core/Elsa.Core/Activities/Signaling/Activities/InterruptTrigger/InterruptTrigger.cs +++ b/src/core/Elsa.Core/Activities/Signaling/Activities/InterruptTrigger/InterruptTrigger.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Expressions; using Elsa.Persistence; using Elsa.Services; using Elsa.Services.Models; @@ -27,13 +28,13 @@ namespace Elsa.Activities.Signaling _workflowInstanceManager = workflowInstanceStore; } - [ActivityProperty(Hint = "The ID of the workflow instance to resume.")] + [ActivityProperty(Hint = "The ID of the workflow instance to resume.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public string WorkflowInstanceId { get; set; } = default!; - [ActivityProperty(Hint = "The ID of the blocking activity to trigger.")] + [ActivityProperty(Hint = "The ID of the blocking activity to trigger.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public string BlockingActivityId { get; set; } = default!; - [ActivityProperty(Hint = "An optional input to pass to the blocking activity.")] + [ActivityProperty(Hint = "An optional input to pass to the blocking activity.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public object? Input { get; set; } = default!; protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context) diff --git a/src/core/Elsa.Core/Activities/Signaling/Activities/SendSignal/SendSignal.cs b/src/core/Elsa.Core/Activities/Signaling/Activities/SendSignal/SendSignal.cs index ebac40d11..97d3d4f40 100644 --- a/src/core/Elsa.Core/Activities/Signaling/Activities/SendSignal/SendSignal.cs +++ b/src/core/Elsa.Core/Activities/Signaling/Activities/SendSignal/SendSignal.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Elsa.Activities.Signaling.Services; using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Expressions; using Elsa.Services; using Elsa.Services.Models; @@ -25,13 +26,13 @@ namespace Elsa.Activities.Signaling _signaler = signaler; } - [ActivityProperty(Hint = "An expression that evaluates to the name of the signal to trigger.")] + [ActivityProperty(Hint = "An expression that evaluates to the name of the signal to trigger.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public string Signal { get; set; } = default!; - [ActivityProperty(Hint = "An expression that evaluates to the correlation ID to use when signaling.")] + [ActivityProperty(Hint = "An expression that evaluates to the correlation ID to use when signaling.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public string? CorrelationId { get; set; } - [ActivityProperty(Hint = "An expression that evaluates to an input value when triggering the signal.")] + [ActivityProperty(Hint = "An expression that evaluates to an input value when triggering the signal.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public object? Input { get; set; } protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context) diff --git a/src/core/Elsa.Core/Activities/Signaling/Activities/SignalReceived/SignalReceived.cs b/src/core/Elsa.Core/Activities/Signaling/Activities/SignalReceived/SignalReceived.cs index 8c38a78dd..59e588ae0 100644 --- a/src/core/Elsa.Core/Activities/Signaling/Activities/SignalReceived/SignalReceived.cs +++ b/src/core/Elsa.Core/Activities/Signaling/Activities/SignalReceived/SignalReceived.cs @@ -2,6 +2,7 @@ using System; using Elsa.Activities.Signaling.Models; using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Expressions; using Elsa.Services; using Elsa.Services.Models; @@ -18,7 +19,7 @@ namespace Elsa.Activities.Signaling )] public class SignalReceived : Activity { - [ActivityProperty(Hint = "The name of the signal to wait for.")] + [ActivityProperty(Hint = "The name of the signal to wait for.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] public string Signal { get; set; } = default!; protected override bool OnCanExecute(ActivityExecutionContext context) diff --git a/src/core/Elsa.Core/Activities/Workflows/RunWorkflow/RunWorkflow.cs b/src/core/Elsa.Core/Activities/Workflows/RunWorkflow/RunWorkflow.cs index e891db1c8..8144ea28d 100644 --- a/src/core/Elsa.Core/Activities/Workflows/RunWorkflow/RunWorkflow.cs +++ b/src/core/Elsa.Core/Activities/Workflows/RunWorkflow/RunWorkflow.cs @@ -4,6 +4,8 @@ using System.Threading; using System.Threading.Tasks; using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Design; +using Elsa.Expressions; using Elsa.Models; using Elsa.Services; using Elsa.Services.Models; @@ -27,13 +29,50 @@ namespace Elsa.Activities.Workflows _workflowRegistry = workflowRegistry; } - [ActivityProperty] public string? WorkflowDefinitionId { get; set; } = default!; - [ActivityProperty] public string? TenantId { get; set; } = default!; - [ActivityProperty] public object? Input { get; set; } - [ActivityProperty] public string? CorrelationId { get; set; } - [ActivityProperty] public string? ContextId { get; set; } - [ActivityProperty] public Variables? CustomAttributes { get; set; } = default!; - [ActivityProperty] public RunWorkflowMode Mode { get; set; } + [ActivityProperty( + Label = "Workflow Definition", + Hint = "The workflow definition ID to run.", + SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid } + )] + public string? WorkflowDefinitionId { get; set; } = default!; + + [ActivityProperty( + Label = "Tenant ID", + Hint = "The tenant ID to which the workflow to run belongs.", + Category = PropertyCategories.Advanced, + SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid } + )] + public string? TenantId { get; set; } = default!; + + [ActivityProperty(Hint = "Optional input to send to the workflow to run.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] + public object? Input { get; set; } + + [ActivityProperty( + Label = "Correlation ID", + Hint = "The correlation ID to associate with the workflow to run.", + Category = PropertyCategories.Advanced, + SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid } + )] + public string? CorrelationId { get; set; } + + [ActivityProperty( + Label = "Context ID", + Hint = "The context ID to associate with the workflow to run.", + Category = PropertyCategories.Advanced, + SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid } + )] + public string? ContextId { get; set; } + + [ActivityProperty( + UIHint = ActivityPropertyUIHints.Json, + Hint = "Optional custom attributes to associate with the workflow to run.", + Category = PropertyCategories.Advanced)] + public Variables? CustomAttributes { get; set; } = default!; + + [ActivityProperty( + Hint = "Fire And Forget: run the child workflow and continue the current one. Blocking: Run the child workflow and suspend the current one until the child workflow finishes.", + SupportedSyntaxes = new[] { SyntaxNames.Literal, SyntaxNames.JavaScript, SyntaxNames.Liquid })] + public RunWorkflowMode Mode { get; set; } public string ChildWorkflowInstanceId { @@ -47,7 +86,7 @@ namespace Elsa.Activities.Workflows var workflowBlueprint = await FindWorkflowBlueprintAsync(cancellationToken); var workflowInstance = await _startsWorkflow.StartWorkflowAsync(workflowBlueprint!, TenantId, Input, CorrelationId, ContextId, cancellationToken); var workflowStatus = workflowInstance.WorkflowStatus; - + ChildWorkflowInstanceId = workflowInstance.Id; return Mode switch