Skip to content

Commit

Permalink
Add UI hints for HTTP endpoint and single line fields
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sfmskywalker committed Dec 28, 2023
1 parent 5202b39 commit 5d936ad
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Elsa.Api.Client.Shared.UIHints.SingleLine;

/// <summary>
/// Provides additional options for the SingleLine input field.
/// </summary>
public class SingleLineProps
{
/// <summary>
/// Gets or sets adornment text.
/// </summary>
public string? AdornmentText { get; set; }
}
7 changes: 6 additions & 1 deletion src/modules/Elsa.Http/Activities/HttpEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Elsa.Extensions;
using Elsa.Http.Bookmarks;
using Elsa.Http.Contracts;
using Elsa.Http.UIHints;
using Elsa.Workflows;
using Elsa.Workflows.Attributes;
using Elsa.Workflows.UIHints;
Expand Down Expand Up @@ -34,7 +35,11 @@ public HttpEndpoint([CallerFilePath] string? source = default, [CallerLineNumber
/// <summary>
/// The path to associate with the workflow.
/// </summary>
[Input(Description = "The path to associate with the workflow.")]
[Input(
Description = "The path to associate with the workflow.",
UIHint = InputUIHints.SingleLine,
UIHandler = typeof(HttpEndpointPathUIHandler)
)]
public Input<string> Path { get; set; } = default!;

/// <summary>
Expand Down
30 changes: 30 additions & 0 deletions src/modules/Elsa.Http/UIHints/HttpEndpointPathUIHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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('/') + '/'
},
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Elsa.Workflows.UIHints.SingleLine;

/// <summary>
/// Provides additional options for the SingleLine input field.
/// </summary>
public class SingleLineProps
{
/// <summary>
/// Gets or sets adornment text.
/// </summary>
public string? AdornmentText { get; set; }
}

0 comments on commit 5d936ad

Please sign in to comment.