elsa-core/src/modules/Elsa.Http/UIHints/HttpEndpointPathUIHandler.cs

30 lines
996 B
C#
Raw Normal View History

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;
2023-12-29 07:51:13 +00:00
var basePath = options.Value.BasePath;
var completeBaseUrl = new Uri(baseUrl, basePath);
return new(new Dictionary<string, object>
{
[InputUIHints.SingleLine] = new SingleLineProps
{
AdornmentText = completeBaseUrl.ToString().TrimEnd('/') + '/'
},
});
}
}