diff --git a/src/modules/Elsa.Http/Activities/SendHttpRequestBase.cs b/src/modules/Elsa.Http/Activities/SendHttpRequestBase.cs index 41d7938081..1618927512 100644 --- a/src/modules/Elsa.Http/Activities/SendHttpRequestBase.cs +++ b/src/modules/Elsa.Http/Activities/SendHttpRequestBase.cs @@ -70,7 +70,11 @@ protected SendHttpRequestBase(string? source = default, int? line = default) : b /// /// The headers to send along with the request. /// - [Input(Description = "The headers to send along with the request.", Category = "Advanced")] + [Input( + Description = "The headers to send along with the request.", + UIHint = InputUIHints.JsonEditor, + Category = "Advanced" + )] public Input RequestHeaders { get; set; } = new(new HttpHeaders()); /// @@ -161,7 +165,7 @@ private HttpRequestMessage PrepareRequest(ActivityExecutionContext context) var addAuthorizationWithoutValidation = DisableAuthorizationHeaderValidation.GetOrDefault(context); if (!string.IsNullOrWhiteSpace(authorization)) - if(addAuthorizationWithoutValidation) + if (addAuthorizationWithoutValidation) request.Headers.TryAddWithoutValidation("Authorization", authorization); else request.Headers.Authorization = AuthenticationHeaderValue.Parse(authorization); diff --git a/src/modules/Elsa.Http/Activities/WriteHttpResponse.cs b/src/modules/Elsa.Http/Activities/WriteHttpResponse.cs index 154e07d74b..1b1c6b92ab 100644 --- a/src/modules/Elsa.Http/Activities/WriteHttpResponse.cs +++ b/src/modules/Elsa.Http/Activities/WriteHttpResponse.cs @@ -53,7 +53,11 @@ public WriteHttpResponse([CallerFilePath] string? source = default, [CallerLineN /// /// The headers to return along with the response. /// - [Input(Description = "The headers to send along with the response.", Category = "Advanced")] + [Input( + Description = "The headers to send along with the response.", + UIHint = InputUIHints.JsonEditor, + Category = "Advanced" + )] public Input ResponseHeaders { get; set; } = new(new HttpHeaders()); /// diff --git a/src/modules/Elsa.Workflows.Core/Features/WorkflowsFeature.cs b/src/modules/Elsa.Workflows.Core/Features/WorkflowsFeature.cs index 8bc33779cf..657195982b 100644 --- a/src/modules/Elsa.Workflows.Core/Features/WorkflowsFeature.cs +++ b/src/modules/Elsa.Workflows.Core/Features/WorkflowsFeature.cs @@ -19,6 +19,7 @@ using Elsa.Workflows.Services; using Elsa.Workflows.UIHints.CheckList; using Elsa.Workflows.UIHints.Dropdown; +using Elsa.Workflows.UIHints.JsonEditor; using Microsoft.Extensions.DependencyInjection; namespace Elsa.Workflows.Features; @@ -181,6 +182,7 @@ private void AddElsaCore(IServiceCollection services) // UI hints. .AddSingleton() .AddSingleton() + .AddSingleton() // Logging .AddLogging(); diff --git a/src/modules/Elsa.Workflows.Core/UIHints/Dropdown/StaticDropDownOptionsProvider.cs b/src/modules/Elsa.Workflows.Core/UIHints/Dropdown/StaticDropDownOptionsProvider.cs index 3aada9e722..b3a6971133 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/Dropdown/StaticDropDownOptionsProvider.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/Dropdown/StaticDropDownOptionsProvider.cs @@ -23,10 +23,10 @@ public class StaticDropDownOptionsProvider : IPropertyUIHandler var wrappedPropertyType = propertyInfo.PropertyType.IsGenericType && propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(Input<>) ? propertyInfo.PropertyType.GetGenericArguments()[0] : propertyInfo.PropertyType; - - if (!wrappedPropertyType.IsEnum) + + if (!wrappedPropertyType.IsEnum) return new(dictionary); - + var enumValues = Enum.GetValues(wrappedPropertyType).Cast().ToList(); var enumSelectListItems = enumValues.Select(x => new SelectListItem(x.ToString()!, x.ToString()!)).ToList(); var enumProps = new DropDownProps @@ -36,7 +36,6 @@ public class StaticDropDownOptionsProvider : IPropertyUIHandler dictionary[InputUIHints.DropDown] = enumProps; return new(dictionary); - } var selectListItems = (inputOptions as ICollection)?.Select(x => new SelectListItem(x, x)).ToList(); diff --git a/src/modules/Elsa.Workflows.Core/UIHints/JsonEditor/JsonCodeOptionsProvider.cs b/src/modules/Elsa.Workflows.Core/UIHints/JsonEditor/JsonCodeOptionsProvider.cs new file mode 100644 index 0000000000..efebacc1c6 --- /dev/null +++ b/src/modules/Elsa.Workflows.Core/UIHints/JsonEditor/JsonCodeOptionsProvider.cs @@ -0,0 +1,10 @@ +using System.Reflection; +using Elsa.Workflows.UIHints.CodeEditor; + +// ReSharper disable once CheckNamespace +namespace Elsa.CSharp.Activities; + +internal class JsonCodeOptionsProvider : CodeEditorOptionsProviderBase +{ + protected override string GetLanguage(PropertyInfo propertyInfo, object? context) => "json"; +} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/UIHints/JsonEditor/JsonEditorUIHintHandler.cs b/src/modules/Elsa.Workflows.Core/UIHints/JsonEditor/JsonEditorUIHintHandler.cs new file mode 100644 index 0000000000..c432d713c2 --- /dev/null +++ b/src/modules/Elsa.Workflows.Core/UIHints/JsonEditor/JsonEditorUIHintHandler.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using Elsa.CSharp.Activities; +using Elsa.Workflows.Contracts; + +namespace Elsa.Workflows.UIHints.JsonEditor; + +/// +public class JsonEditorUIHintHandler : IUIHintHandler +{ + /// + public string UIHint => InputUIHints.JsonEditor; + + /// + public ValueTask> GetPropertyUIHandlersAsync(PropertyInfo propertyInfo, CancellationToken cancellationToken) + { + return new(new[] { typeof(JsonCodeOptionsProvider) }); + } +} \ No newline at end of file