From f609013a7947d045a9571164c4168e18bfaae80e Mon Sep 17 00:00:00 2001 From: Matthew Knibbs Date: Wed, 1 Jan 2025 16:46:23 +0000 Subject: [PATCH] Adds SQL UIHints handler and provider. --- .../Features/WorkflowsFeature.cs | 3 +++ .../Elsa.Workflows.Core/UIHints/InputUIHints.cs | 1 + .../UIHints/SqlEditor/SqlCodeOptionsProvider.cs | 10 ++++++++++ .../UIHints/SqlEditor/SqlEditorUIHintHandler.cs | 16 ++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 src/modules/Elsa.Workflows.Core/UIHints/SqlEditor/SqlCodeOptionsProvider.cs create mode 100644 src/modules/Elsa.Workflows.Core/UIHints/SqlEditor/SqlEditorUIHintHandler.cs diff --git a/src/modules/Elsa.Workflows.Core/Features/WorkflowsFeature.cs b/src/modules/Elsa.Workflows.Core/Features/WorkflowsFeature.cs index 6720e3e7a..2faa301fb 100644 --- a/src/modules/Elsa.Workflows.Core/Features/WorkflowsFeature.cs +++ b/src/modules/Elsa.Workflows.Core/Features/WorkflowsFeature.cs @@ -23,6 +23,7 @@ using Elsa.Workflows.Services; using Elsa.Workflows.UIHints.CheckList; using Elsa.Workflows.UIHints.Dropdown; using Elsa.Workflows.UIHints.JsonEditor; +using Elsa.Workflows.UIHints.SqlEditor; using Microsoft.Extensions.DependencyInjection; namespace Elsa.Workflows.Features; @@ -229,11 +230,13 @@ public class WorkflowsFeature : FeatureBase .AddScoped() .AddScoped() .AddScoped() + .AddScoped() // UI property handlers. .AddScoped() .AddScoped() .AddScoped() + .AddScoped() // Logger state generators. .AddSingleton(WorkflowLoggerStateGenerator) diff --git a/src/modules/Elsa.Workflows.Core/UIHints/InputUIHints.cs b/src/modules/Elsa.Workflows.Core/UIHints/InputUIHints.cs index 8465e1bbf..6616ea606 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/InputUIHints.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/InputUIHints.cs @@ -21,5 +21,6 @@ public static class InputUIHints public const string OutputPicker = "output-picker"; public const string OutcomePicker = "outcome-picker"; public const string JsonEditor = "json-editor"; + public const string SqlEditor = "sql-editor"; public const string DynamicOutcomes = "dynamic-outcomes"; } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/UIHints/SqlEditor/SqlCodeOptionsProvider.cs b/src/modules/Elsa.Workflows.Core/UIHints/SqlEditor/SqlCodeOptionsProvider.cs new file mode 100644 index 000000000..588ea20cf --- /dev/null +++ b/src/modules/Elsa.Workflows.Core/UIHints/SqlEditor/SqlCodeOptionsProvider.cs @@ -0,0 +1,10 @@ +using System.Reflection; +using Elsa.Workflows.UIHints.CodeEditor; + +// ReSharper disable once CheckNamespace +namespace Elsa.Workflows.UIHints.SqlEditor; + +internal class SqlCodeOptionsProvider : CodeEditorOptionsProviderBase +{ + protected override string GetLanguage(PropertyInfo propertyInfo, object? context) => "sql"; +} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/UIHints/SqlEditor/SqlEditorUIHintHandler.cs b/src/modules/Elsa.Workflows.Core/UIHints/SqlEditor/SqlEditorUIHintHandler.cs new file mode 100644 index 000000000..642bc6878 --- /dev/null +++ b/src/modules/Elsa.Workflows.Core/UIHints/SqlEditor/SqlEditorUIHintHandler.cs @@ -0,0 +1,16 @@ +using System.Reflection; + +namespace Elsa.Workflows.UIHints.SqlEditor; + +/// +public class SqlEditorUIHintHandler : IUIHintHandler +{ + /// + public string UIHint => InputUIHints.SqlEditor; + + /// + public ValueTask> GetPropertyUIHandlersAsync(PropertyInfo propertyInfo, CancellationToken cancellationToken) + { + return new([typeof(SqlCodeOptionsProvider)]); + } +} \ No newline at end of file