Update workflow revert to return summary and location
Enhanced the Revert endpoint to return a summary of the newly created workflow definition and include its location. Adjusted the API contract and endpoint configuration accordingly.
This commit is contained in:
parent
59bc7bc6a2
commit
dc4f904108
|
|
@ -209,6 +209,7 @@ public interface IWorkflowDefinitionsApi
|
|||
/// <param name="definitionId">The definition ID of the workflow definition to revert.</param>
|
||||
/// <param name="version">The version to revert to.</param>
|
||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||
/// <returns>A summary view of the newly created workflow definition version.</returns>
|
||||
[Post("/workflow-definitions/{definitionId}/revert/{version}")]
|
||||
Task RevertVersionAsync(string definitionId, int version, CancellationToken cancellationToken = default);
|
||||
Task<WorkflowDefinitionSummary> RevertVersionAsync(string definitionId, int version, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ using Elsa.Abstractions;
|
|||
using Elsa.Workflows.Management.Contracts;
|
||||
using Elsa.Workflows.Management.Filters;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
||||
namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.GetById;
|
||||
|
||||
|
|
@ -12,6 +13,7 @@ internal class GetById(IWorkflowDefinitionStore store, IWorkflowDefinitionLinker
|
|||
{
|
||||
Get("/workflow-definitions/by-id/{id}");
|
||||
ConfigurePermissions("read:workflow-definitions");
|
||||
Options(x => x.WithName("GetWorkflowDefinitionById"));
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Elsa.Workflows.Api.Constants;
|
|||
using Elsa.Workflows.Api.Requirements;
|
||||
using Elsa.Workflows.Management.Contracts;
|
||||
using Elsa.Workflows.Management.Filters;
|
||||
using Elsa.Workflows.Management.Models;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
|
|
@ -46,8 +47,12 @@ internal class RevertVersion(IWorkflowDefinitionManager workflowDefinitionManage
|
|||
return;
|
||||
}
|
||||
|
||||
await workflowDefinitionManager.RevertVersionAsync(definitionId, version, cancellationToken);
|
||||
var newDefinition = await workflowDefinitionManager.RevertVersionAsync(definitionId, version, cancellationToken);
|
||||
var newDefinitionSummary = WorkflowDefinitionSummary.FromDefinition(newDefinition);
|
||||
|
||||
await SendOkAsync(cancellationToken);
|
||||
await SendCreatedAtAsync("GetWorkflowDefinitionById", new
|
||||
{
|
||||
id = newDefinition.Id
|
||||
}, newDefinitionSummary, cancellation: cancellationToken);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue