| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using JetBrains.Annotations; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Workflows.Api.Endpoints.ActivityDescriptorOptions.Get; |
| | | 5 | | |
| | | 6 | | [PublicAPI] |
| | | 7 | | internal class Get : ElsaEndpoint<Request, Response> |
| | | 8 | | { |
| | | 9 | | private readonly IServiceProvider _serviceProvider; |
| | | 10 | | private readonly IActivityRegistryLookupService _registryLookup; |
| | | 11 | | private readonly IPropertyUIHandlerResolver _optionsResolver; |
| | | 12 | | |
| | | 13 | | /// <inheritdoc /> |
| | 1 | 14 | | public Get(IServiceProvider serviceProvider, IActivityRegistryLookupService registryLookup, IPropertyUIHandlerResolv |
| | | 15 | | { |
| | 1 | 16 | | _serviceProvider = serviceProvider; |
| | 1 | 17 | | _registryLookup = registryLookup; |
| | 1 | 18 | | _optionsResolver = optionsResolver; |
| | 1 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <inheritdoc /> |
| | | 22 | | public override void Configure() |
| | | 23 | | { |
| | 1 | 24 | | Post("/descriptors/activities/{activityTypeName}/options/{propertyName}"); |
| | 1 | 25 | | ConfigurePermissions("read:*", "read:activity-descriptors-options"); |
| | 1 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <inheritdoc /> |
| | | 29 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 30 | | { |
| | 0 | 31 | | var descriptor = request.Version == null ? await _registryLookup.FindAsync(request.ActivityTypeName) : await _re |
| | 0 | 32 | | if (descriptor == null) |
| | 0 | 33 | | await Send.NotFoundAsync(cancellationToken); |
| | | 34 | | |
| | 0 | 35 | | var propertyDescriptor = descriptor!.Inputs.FirstOrDefault(x => x.Name == request.PropertyName); |
| | | 36 | | |
| | 0 | 37 | | if(propertyDescriptor == null) |
| | | 38 | | { |
| | 0 | 39 | | await Send.NotFoundAsync(cancellationToken); |
| | 0 | 40 | | return; |
| | | 41 | | } |
| | | 42 | | |
| | 0 | 43 | | var inputOptions = await _optionsResolver.GetUIPropertiesAsync(propertyDescriptor.PropertyInfo!, request.Context |
| | | 44 | | |
| | 0 | 45 | | await Send.OkAsync(new Response(inputOptions), cancellationToken); |
| | 0 | 46 | | } |
| | | 47 | | } |