elsa-core/src/modules/Elsa.Http/UIHints/HttpEndpointPathUIHandler.cs
Sipke Schoorstra 5d936ad34c Add UI hints for HTTP endpoint and single line fields
Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions.
2023-12-28 20:52:04 +01:00

30 lines
1,014 B
C#

using System.Reflection;
using Elsa.Http.Options;
using Elsa.Workflows.Contracts;
using Elsa.Workflows.UIHints;
using Elsa.Workflows.UIHints.SingleLine;
using Microsoft.Extensions.Options;
namespace Elsa.Http.UIHints;
/// <summary>
/// Provides additional options for the Path input field.
/// </summary>
public class HttpEndpointPathUIHandler(IOptions<HttpActivityOptions> options) : IPropertyUIHandler
{
/// <inheritdoc />
public ValueTask<IDictionary<string, object>> GetUIPropertiesAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken = default)
{
var baseUrl = options.Value.BaseUrl;
var apiRoutePrefix = options.Value.ApiRoutePrefix;
var completeBaseUrl = new Uri(baseUrl, apiRoutePrefix);
return new(new Dictionary<string, object>
{
[InputUIHints.SingleLine] = new SingleLineProps
{
AdornmentText = completeBaseUrl.ToString().TrimEnd('/') + '/'
},
});
}
}