From e5d497c53967534d4e1aec68d5fdc3f42a051bc3 Mon Sep 17 00:00:00 2001 From: axeleron007 Date: Wed, 2 Jun 2021 14:14:24 +0300 Subject: [PATCH] The Webhooks functionality implementation All functionality for the Webhooks is implemented like: list, create, edit, delete --- .../Endpoints/WebhookDefinitions/Delete.cs | 45 +++++++ .../Endpoints/WebhookDefinitions/Get.cs | 10 +- .../Endpoints/WebhookDefinitions/Models.cs | 3 +- .../Endpoints/WebhookDefinitions/Post.cs | 10 +- .../InitializingWebhookDefinitionStore.cs | 3 - .../Models/WebhookDefinition.cs | 1 - .../Models/WebhookDefinition.cs | 2 - .../Models/WebhookDefinitionSummary.cs | 2 - .../WebhookDefinitionConfiguration.cs | 1 - .../EntityFrameworkWebhookDefinitionStore.cs | 41 +------ .../Migrations/20210531210636_Initial.cs | 4 +- .../Migrations/WebhookContextModelSnapshot.cs | 4 - .../Migrations/20210531210716_Initial.cs | 3 +- .../Migrations/20210531210754_Initial.cs | 3 +- .../Migrations/WebhookContextModelSnapshot.cs | 4 +- .../Migrations/20210531210732_Initial.cs | 3 +- .../Services/DatabaseInitializer.cs | 7 +- .../Documents/WebhookDefinitionDocument.cs | 2 +- .../Indexes/WebhookDefinitionIndex.cs | 4 +- .../Migrations.cs | 2 +- .../Stores/YesSqlWebhookDefinitionStore.cs | 5 +- .../elsa-workflows-studio/src/components.d.ts | 24 +--- .../elsa-webhook-definition-editor-screen.tsx | 110 +++++++----------- .../elsa-webhook-save-button.tsx | 62 ---------- .../elsa-webhook-save-button/readme.md | 38 ------ .../elsa-webhook-definitions-list-screen.tsx | 16 +-- .../elsa-workflow-settings-modal.tsx | 2 +- .../elsa-workflow-definitions-list-screen.tsx | 2 +- .../src/data/webhook-editor.tsx | 4 +- .../src/models/webhook/domain.ts | 9 +- .../src/models/webhook/events.ts | 1 - .../src/models/webhook/view.ts | 2 +- .../src/services/elsa-client.ts | 19 ++- 33 files changed, 137 insertions(+), 311 deletions(-) create mode 100644 src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Delete.cs delete mode 100644 src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-save-button/elsa-webhook-save-button.tsx delete mode 100644 src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-save-button/readme.md diff --git a/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Delete.cs b/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Delete.cs new file mode 100644 index 000000000..701ddb6a7 --- /dev/null +++ b/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Delete.cs @@ -0,0 +1,45 @@ +using System.Threading; +using System.Threading.Tasks; +using Elsa.Persistence.Specifications; +using Elsa.Webhooks.Abstractions.Models; +using Elsa.Webhooks.Abstractions.Persistence; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; + +namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions +{ + [ApiController] + [ApiVersion("1")] + [Route("v{apiVersion:apiVersion}/webhook-definitions/{id}")] + [Produces("application/json")] + public class Delete : ControllerBase + { + private readonly IWebhookDefinitionStore _webhookDefinitionStore; + + public Delete(IWebhookDefinitionStore webhookDefinitionStore) + { + _webhookDefinitionStore = webhookDefinitionStore; + } + + [HttpDelete] + [ProducesResponseType(StatusCodes.Status202Accepted)] + [SwaggerOperation( + Summary = "Deletes a webhook definition.", + Description = "Deletes a webhook definition.", + OperationId = "WebhookDefinitions.Delete", + Tags = new[] { "WebhookDefinitions" }) + ] + public async Task Handle(string id, CancellationToken cancellationToken) + { + var webhookDefinition = !string.IsNullOrWhiteSpace(id) ? await _webhookDefinitionStore.FindAsync(new EntityIdSpecification(id), cancellationToken) : default; + + if (webhookDefinition != null) + { + await _webhookDefinitionStore.DeleteAsync(webhookDefinition, cancellationToken); + } + + return Accepted(); + } + } +} \ No newline at end of file diff --git a/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Get.cs b/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Get.cs index 1bd1112ee..64e1666ea 100644 --- a/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Get.cs +++ b/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Get.cs @@ -16,7 +16,7 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions { [ApiController] [ApiVersion("1")] - [Route("v{apiVersion:apiVersion}/webhook-definitions/{webhookDefinitionId}")] + [Route("v{apiVersion:apiVersion}/webhook-definitions/{webhookId}")] [Produces(MediaTypeNames.Application.Json)] public class Get : Controller { @@ -30,8 +30,8 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions } [HttpGet] - [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(WorkflowDefinition))] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(WorkflowDefinitionExample))] + [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(WebhookDefinition))] + [SwaggerResponseExample(StatusCodes.Status200OK, typeof(WebhookDefinitionExample))] [ProducesResponseType(StatusCodes.Status404NotFound)] [SwaggerOperation( Summary = "Returns a single webhook definition.", @@ -39,9 +39,9 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions OperationId = "WebhookDefinitions.GetByDefinition", Tags = new[] { "WebhookDefinitions" }) ] - public async Task Handle(string webhookDefinitionId, CancellationToken cancellationToken = default) + public async Task Handle(string webhookId, CancellationToken cancellationToken = default) { - var webhookDefinition = await _webhookDefinitionStore.FindAsync(new EntityIdSpecification(webhookDefinitionId), cancellationToken); + var webhookDefinition = await _webhookDefinitionStore.FindAsync(new EntityIdSpecification(webhookId), cancellationToken); return webhookDefinition == null ? (IActionResult) NotFound() : Json(webhookDefinition, _serializerSettingsProvider.GetSettings()); } } diff --git a/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Models.cs b/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Models.cs index 0f29db0cd..1e930b692 100644 --- a/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Models.cs +++ b/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Models.cs @@ -2,8 +2,7 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions { public sealed record SaveRequest { - //public string? Id { get; init; } - public string? WebhookDefinitionId { get; init; } + public string? Id { get; init; } public string? Path { get; init; } public string? Name { get; init; } public string? Description { get; init; } diff --git a/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Post.cs b/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Post.cs index 57c99b8ff..a96ebfc45 100644 --- a/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Post.cs +++ b/src/activities/webhooks/Elsa.Activities.Webhooks/Endpoints/WebhookDefinitions/Post.cs @@ -36,15 +36,15 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions ] public async Task> Handle([FromBody] SaveRequest request, [FromRoute] ApiVersion apiVersion, CancellationToken cancellationToken) { - var webhookDefinitionId = request.WebhookDefinitionId; - var webhookDefinition = !string.IsNullOrWhiteSpace(webhookDefinitionId) ? await _webhookDefinitionStore.FindAsync(new EntityIdSpecification(webhookDefinitionId), cancellationToken) : default; + var webhookId = request.Id; + var webhookDefinition = !string.IsNullOrWhiteSpace(webhookId) ? await _webhookDefinitionStore.FindAsync(new EntityIdSpecification(webhookId), cancellationToken) : default; if (webhookDefinition == null) { webhookDefinition = new WebhookDefinition(); - if (!string.IsNullOrWhiteSpace(webhookDefinitionId)) - webhookDefinition.DefinitionId = webhookDefinitionId; + if (!string.IsNullOrWhiteSpace(webhookId)) + webhookDefinition.Id = webhookId; } webhookDefinition.Name = request.Name?.Trim(); @@ -55,7 +55,7 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions await _webhookDefinitionStore.SaveAsync(webhookDefinition, cancellationToken); - return CreatedAtAction("Handle", "Get", new { definitionId = webhookDefinition.DefinitionId, apiVersion = apiVersion.ToString() }, webhookDefinition); + return CreatedAtAction("Handle", "Get", new { id = webhookDefinition.Id, apiVersion = apiVersion.ToString() }, webhookDefinition); } } } \ No newline at end of file diff --git a/src/activities/webhooks/Elsa.Activities.Webhooks/Persistence/Decorators/InitializingWebhookDefinitionStore.cs b/src/activities/webhooks/Elsa.Activities.Webhooks/Persistence/Decorators/InitializingWebhookDefinitionStore.cs index a72b57915..b7ec25434 100644 --- a/src/activities/webhooks/Elsa.Activities.Webhooks/Persistence/Decorators/InitializingWebhookDefinitionStore.cs +++ b/src/activities/webhooks/Elsa.Activities.Webhooks/Persistence/Decorators/InitializingWebhookDefinitionStore.cs @@ -66,9 +66,6 @@ namespace Elsa.Activities.Webhooks.Persistence.Decorators { if (string.IsNullOrWhiteSpace(webhookDefinition.Id)) webhookDefinition.Id = _idGenerator.Generate(); - - if (string.IsNullOrWhiteSpace(webhookDefinition.DefinitionId)) - webhookDefinition.DefinitionId = _idGenerator.Generate(); return webhookDefinition; } diff --git a/src/activities/webhooks/Elsa.Webhooks.Abstractions/Models/WebhookDefinition.cs b/src/activities/webhooks/Elsa.Webhooks.Abstractions/Models/WebhookDefinition.cs index 4933df8f9..4e3e02339 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Abstractions/Models/WebhookDefinition.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Abstractions/Models/WebhookDefinition.cs @@ -5,7 +5,6 @@ namespace Elsa.Webhooks.Abstractions.Models public class WebhookDefinition : IEntity, ITenantScope { public string Id { get; set; } = default!; - public string DefinitionId { get; set; } = default!; public string? TenantId { get; set; } public string Name { get; set; } = default!; public string Path { get; set; } = default!; diff --git a/src/activities/webhooks/Elsa.Webhooks.Client/Models/WebhookDefinition.cs b/src/activities/webhooks/Elsa.Webhooks.Client/Models/WebhookDefinition.cs index e7f6d616d..9ba0181ec 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Client/Models/WebhookDefinition.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Client/Models/WebhookDefinition.cs @@ -8,8 +8,6 @@ namespace Elsa.Webhooks.Client.Models { [DataMember(Order = 1)] public string Id { get; set; } = default!; - [DataMember(Order = 2)] public string DefinitionId { get; set; } = default!; - [DataMember(Order = 3)] public string? TenantId { get; set; } [DataMember(Order = 4)] public string Name { get; set; } = default!; diff --git a/src/activities/webhooks/Elsa.Webhooks.Client/Models/WebhookDefinitionSummary.cs b/src/activities/webhooks/Elsa.Webhooks.Client/Models/WebhookDefinitionSummary.cs index c08c7e464..bc6de3b25 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Client/Models/WebhookDefinitionSummary.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Client/Models/WebhookDefinitionSummary.cs @@ -6,8 +6,6 @@ namespace Elsa.Webhooks.Client.Models { [DataMember(Order = 1)] public string Id { get; set; } = default!; - [DataMember(Order = 2)] public string DefinitionId { get; set; } = default!; - [DataMember(Order = 3)] public string? TenantId { get; set; } [DataMember(Order = 4)] public string Name { get; set; } = default!; diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Core/Configuration/WebhookDefinitionConfiguration.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Core/Configuration/WebhookDefinitionConfiguration.cs index c2ca936e4..7bb663eea 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Core/Configuration/WebhookDefinitionConfiguration.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Core/Configuration/WebhookDefinitionConfiguration.cs @@ -8,7 +8,6 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.Core.Configuration { public void Configure(EntityTypeBuilder builder) { - builder.HasIndex(x => new { x.DefinitionId}).HasDatabaseName($"IX_{nameof(WebhookDefinition)}_{nameof(WebhookDefinition.DefinitionId)}").IsUnique(); builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(WebhookDefinition)}_{nameof(WebhookDefinition.TenantId)}"); builder.HasIndex(x => x.Path).HasDatabaseName($"IX_{nameof(WebhookDefinition)}_{nameof(WebhookDefinition.Path)}"); builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(WebhookDefinition)}_{nameof(WebhookDefinition.Name)}"); diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Core/Stores/EntityFrameworkWebhookDefinitionStore.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Core/Stores/EntityFrameworkWebhookDefinitionStore.cs index d8d7219d7..ca7c35488 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Core/Stores/EntityFrameworkWebhookDefinitionStore.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Core/Stores/EntityFrameworkWebhookDefinitionStore.cs @@ -1,15 +1,12 @@ using System; using System.Linq.Expressions; -using AutoMapper; -using Elsa.Persistence.EntityFramework.Core.Services; using Elsa.Persistence.EntityFramework.Core.Stores; using Elsa.Persistence.Specifications; using Elsa.Serialization; using Elsa.Webhooks.Abstractions.Models; using Elsa.Webhooks.Abstractions.Persistence; using Elsa.Webhooks.Persistence.EntityFramework.Core.Services; - -//using Elsa.Webhooks.Persistence.EntityFramework.Core.Services; +using AutoMapper; namespace Elsa.Webhooks.Persistence.EntityFramework.Core.Stores { @@ -23,41 +20,5 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.Core.Stores } protected override Expression> MapSpecification(ISpecification specification) => AutoMapSpecification(specification); - - //protected override void OnSaving(WebhookContext dbContext, WebhookDefinition entity) - //{ - // //var data = new - // //{ - // // entity.Activities, - // // entity.Connections, - // // entity.Variables, - // // entity.ContextOptions, - // // entity.CustomAttributes - // //}; - - // //var json = _contentSerializer.Serialize(data); - // //dbContext.Entry(entity).Property("Data").CurrentValue = json; - //} - - //protected override void OnLoading(WebhookContext dbContext, WebhookDefinition entity) - //{ - // //var data = new - // //{ - // // entity.Activities, - // // entity.Connections, - // // entity.Variables, - // // entity.ContextOptions, - // // entity.CustomAttributes - // //}; - - // //var json = (string)dbContext.Entry(entity).Property("Data").CurrentValue; - // //data = JsonConvert.DeserializeAnonymousType(json, data, DefaultContentSerializer.CreateDefaultJsonSerializationSettings()); - - // //entity.Activities = data.Activities; - // //entity.Connections = data.Connections; - // //entity.Variables = data.Variables; - // //entity.ContextOptions = data.ContextOptions; - // //entity.CustomAttributes = data.CustomAttributes; - //} } } \ No newline at end of file diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.MySql/Migrations/20210531210636_Initial.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.MySql/Migrations/20210531210636_Initial.cs index 4de72540d..fc6b18131 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.MySql/Migrations/20210531210636_Initial.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.MySql/Migrations/20210531210636_Initial.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace Elsa.Webhooks.Persistence.EntityFramework.MySql.Migrations { @@ -15,8 +15,6 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.MySql.Migrations { Id = table.Column(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), - DefinitionId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), TenantId = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column(type: "longtext", nullable: false) diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.MySql/Migrations/WebhookContextModelSnapshot.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.MySql/Migrations/WebhookContextModelSnapshot.cs index 856bda6cd..ce17cfb59 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.MySql/Migrations/WebhookContextModelSnapshot.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.MySql/Migrations/WebhookContextModelSnapshot.cs @@ -21,10 +21,6 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.MySql.Migrations b.Property("Id") .HasColumnType("varchar(255)"); - b.Property("DefinitionId") - .IsRequired() - .HasColumnType("longtext"); - b.Property("Description") .HasColumnType("longtext"); diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.PostgreSql/Migrations/20210531210716_Initial.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.PostgreSql/Migrations/20210531210716_Initial.cs index 2fa692908..78777ce59 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.PostgreSql/Migrations/20210531210716_Initial.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.PostgreSql/Migrations/20210531210716_Initial.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace Elsa.Webhooks.Persistence.EntityFramework.PostgreSql.Migrations { @@ -11,7 +11,6 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.PostgreSql.Migrations columns: table => new { Id = table.Column(type: "text", nullable: false), - DefinitionId = table.Column(type: "text", nullable: false), TenantId = table.Column(type: "text", nullable: true), Name = table.Column(type: "text", nullable: false), Path = table.Column(type: "text", nullable: false), diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/20210531210754_Initial.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/20210531210754_Initial.cs index 1e0d231c6..af1e4c8b6 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/20210531210754_Initial.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/20210531210754_Initial.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace Elsa.Webhooks.Persistence.EntityFramework.SqlServer.Migrations { @@ -11,7 +11,6 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.SqlServer.Migrations columns: table => new { Id = table.Column(type: "nvarchar(450)", nullable: false), - DefinitionId = table.Column(type: "nvarchar(max)", nullable: false), TenantId = table.Column(type: "nvarchar(max)", nullable: true), Name = table.Column(type: "nvarchar(max)", nullable: false), Path = table.Column(type: "nvarchar(max)", nullable: false), diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/WebhookContextModelSnapshot.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/WebhookContextModelSnapshot.cs index 765884df5..f0693c94b 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/WebhookContextModelSnapshot.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/WebhookContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using Elsa.Webhooks.Persistence.EntityFramework.Core; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -15,7 +15,7 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.SqlServer.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("ProductVersion", "5.0.6") + .HasAnnotation("ProductVersion", "5.0.6") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("Elsa.Webhooks.Abstractions.Models.WebhookDefinition", b => diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Sqlite/Migrations/20210531210732_Initial.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Sqlite/Migrations/20210531210732_Initial.cs index bfbc095ec..67dee91b1 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Sqlite/Migrations/20210531210732_Initial.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.Sqlite/Migrations/20210531210732_Initial.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace Elsa.Webhooks.Persistence.EntityFramework.Sqlite.Migrations { @@ -11,7 +11,6 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.Sqlite.Migrations columns: table => new { Id = table.Column(type: "TEXT", nullable: false), - DefinitionId = table.Column(type: "TEXT", nullable: false), TenantId = table.Column(type: "TEXT", nullable: true), Name = table.Column(type: "TEXT", nullable: false), Path = table.Column(type: "TEXT", nullable: false), diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.MongoDb/Services/DatabaseInitializer.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.MongoDb/Services/DatabaseInitializer.cs index e208b5006..9eef18fe0 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.MongoDb/Services/DatabaseInitializer.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.MongoDb/Services/DatabaseInitializer.cs @@ -27,12 +27,11 @@ namespace Elsa.Webhooks.Persistence.MongoDb.Services { var builder = Builders.IndexKeys; var tenantKeysDefinition = builder.Ascending(x => x.TenantId); - var definitionIdKeysDefinition = builder.Ascending(x => x.DefinitionId); var nameKeysDefinition = builder.Ascending(x => x.Name); - var webhookDefinitionIdDefinition = builder.Ascending(x => x.DefinitionId); + var webhookIdDefinition = builder.Ascending(x => x.Id); var collection = _mongoContext.WebhookDefinitions; - await CreateIndexesAsync(_mongoContext.WebhookDefinitions, cancellationToken, tenantKeysDefinition, definitionIdKeysDefinition, nameKeysDefinition); - await collection.Indexes.CreateOneAsync(new CreateIndexModel(webhookDefinitionIdDefinition, new CreateIndexOptions { Unique = true }), cancellationToken: cancellationToken); + await CreateIndexesAsync(_mongoContext.WebhookDefinitions, cancellationToken, tenantKeysDefinition, webhookIdDefinition, nameKeysDefinition); + await collection.Indexes.CreateOneAsync(new CreateIndexModel(webhookIdDefinition, new CreateIndexOptions { Unique = true }), cancellationToken: cancellationToken); } private async Task CreateIndexesAsync(IMongoCollection collection, CancellationToken cancellationToken, params IndexKeysDefinition[] definitions) diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Documents/WebhookDefinitionDocument.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Documents/WebhookDefinitionDocument.cs index e0298677c..9a2bd98a5 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Documents/WebhookDefinitionDocument.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Documents/WebhookDefinitionDocument.cs @@ -4,7 +4,7 @@ namespace Elsa.Webhooks.Persistence.YesSql.Documents { public class WebhookDefinitionDocument : YesSqlDocument { - public string DefinitionId { get; set; } = default!; + public string Id { get; set; } = default!; public string? TenantId { get; set; } public string? Name { get; set; } public string? Path { get; set; } diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Indexes/WebhookDefinitionIndex.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Indexes/WebhookDefinitionIndex.cs index 8cf31a3e2..f851dacac 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Indexes/WebhookDefinitionIndex.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Indexes/WebhookDefinitionIndex.cs @@ -6,7 +6,7 @@ namespace Elsa.Webhooks.Persistence.YesSql.Indexes { public class WebhookDefinitionIndex : MapIndex { - public string DefinitionId { get; set; } = default!; + public string Id { get; set; } = default!; public string? TenantId { get; set; } public bool IsEnabled { get; set; } } @@ -21,7 +21,7 @@ namespace Elsa.Webhooks.Persistence.YesSql.Indexes .Map( webhookDefinition => new WebhookDefinitionIndex { - DefinitionId = webhookDefinition.DefinitionId, + Id = webhookDefinition.Id, TenantId = webhookDefinition.TenantId, IsEnabled = webhookDefinition.IsEnabled } diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Migrations.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Migrations.cs index a2479ab52..d0a4c2f8f 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Migrations.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Migrations.cs @@ -11,8 +11,8 @@ namespace Elsa.Webhooks.Persistence.YesSql { SchemaBuilder.CreateMapIndexTable( table => table + .Column(nameof(WebhookDefinitionIndex.Id)) .Column(nameof(WebhookDefinitionIndex.TenantId)) - .Column(nameof(WebhookDefinitionIndex.DefinitionId)) .Column(nameof(WebhookDefinitionIndex.IsEnabled)), CollectionNames.WebhookDefinitions); diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Stores/YesSqlWebhookDefinitionStore.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Stores/YesSqlWebhookDefinitionStore.cs index fa291350f..eb54c3b55 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Stores/YesSqlWebhookDefinitionStore.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Stores/YesSqlWebhookDefinitionStore.cs @@ -23,14 +23,13 @@ namespace Elsa.Webhooks.Persistence.YesSql.Stores { } - protected override async Task FindDocumentAsync(ISession session, WebhookDefinition entity, CancellationToken cancellationToken) => await Query(session, x => x.DefinitionId == entity.Id).FirstOrDefaultAsync(); + protected override async Task FindDocumentAsync(ISession session, WebhookDefinition entity, CancellationToken cancellationToken) => await Query(session, x => x.Id == entity.Id).FirstOrDefaultAsync(); protected override IQuery MapSpecification(ISession session, ISpecification specification) { return specification switch { - EntityIdSpecification s => Query(session, x => x.DefinitionId == s.Id), - //VersionOptionsSpecification s => Query(session), + EntityIdSpecification s => Query(session, x => x.Id == s.Id), _ => AutoMapSpecification(session, specification) }; } diff --git a/src/designer/elsa-workflows-studio/src/components.d.ts b/src/designer/elsa-workflows-studio/src/components.d.ts index 0c56b491a..cf6fbf17c 100644 --- a/src/designer/elsa-workflows-studio/src/components.d.ts +++ b/src/designer/elsa-workflows-studio/src/components.d.ts @@ -195,19 +195,15 @@ export namespace Components { } interface ElsaWebhookDefinitionEditorScreen { "getServerUrl": () => Promise; - "getWebhookDefinitionId": () => Promise; + "getWebhookId": () => Promise; "monacoLibPath": string; "serverUrl": string; - "webhookDefinitionId": string; + "webhookId": string; } interface ElsaWebhookDefinitionsListScreen { "history"?: RouterHistory; "serverUrl": string; } - interface ElsaWebhookSaveButton { - "saving": boolean; - "webhookDefinition": WebhookDefinition; - } interface ElsaWorkflowBlueprintViewerScreen { "getServerUrl": () => Promise; "serverUrl": string; @@ -476,12 +472,6 @@ declare global { prototype: HTMLElsaWebhookDefinitionsListScreenElement; new (): HTMLElsaWebhookDefinitionsListScreenElement; }; - interface HTMLElsaWebhookSaveButtonElement extends Components.ElsaWebhookSaveButton, HTMLStencilElement { - } - var HTMLElsaWebhookSaveButtonElement: { - prototype: HTMLElsaWebhookSaveButtonElement; - new (): HTMLElsaWebhookSaveButtonElement; - }; interface HTMLElsaWorkflowBlueprintViewerScreenElement extends Components.ElsaWorkflowBlueprintViewerScreen, HTMLStencilElement { } var HTMLElsaWorkflowBlueprintViewerScreenElement: { @@ -579,7 +569,6 @@ declare global { "elsa-webhook-definition-editor-notifications": HTMLElsaWebhookDefinitionEditorNotificationsElement; "elsa-webhook-definition-editor-screen": HTMLElsaWebhookDefinitionEditorScreenElement; "elsa-webhook-definitions-list-screen": HTMLElsaWebhookDefinitionsListScreenElement; - "elsa-webhook-save-button": HTMLElsaWebhookSaveButtonElement; "elsa-workflow-blueprint-viewer-screen": HTMLElsaWorkflowBlueprintViewerScreenElement; "elsa-workflow-definition-editor-notifications": HTMLElsaWorkflowDefinitionEditorNotificationsElement; "elsa-workflow-definition-editor-screen": HTMLElsaWorkflowDefinitionEditorScreenElement; @@ -776,17 +765,12 @@ declare namespace LocalJSX { "monacoLibPath"?: string; "onWebhookSaved"?: (event: CustomEvent) => void; "serverUrl"?: string; - "webhookDefinitionId"?: string; + "webhookId"?: string; } interface ElsaWebhookDefinitionsListScreen { "history"?: RouterHistory; "serverUrl"?: string; } - interface ElsaWebhookSaveButton { - "onSaveClicked"?: (event: CustomEvent) => void; - "saving"?: boolean; - "webhookDefinition"?: WebhookDefinition; - } interface ElsaWorkflowBlueprintViewerScreen { "serverUrl"?: string; "workflowDefinitionId"?: string; @@ -871,7 +855,6 @@ declare namespace LocalJSX { "elsa-webhook-definition-editor-notifications": ElsaWebhookDefinitionEditorNotifications; "elsa-webhook-definition-editor-screen": ElsaWebhookDefinitionEditorScreen; "elsa-webhook-definitions-list-screen": ElsaWebhookDefinitionsListScreen; - "elsa-webhook-save-button": ElsaWebhookSaveButton; "elsa-workflow-blueprint-viewer-screen": ElsaWorkflowBlueprintViewerScreen; "elsa-workflow-definition-editor-notifications": ElsaWorkflowDefinitionEditorNotifications; "elsa-workflow-definition-editor-screen": ElsaWorkflowDefinitionEditorScreen; @@ -924,7 +907,6 @@ declare module "@stencil/core" { "elsa-webhook-definition-editor-notifications": LocalJSX.ElsaWebhookDefinitionEditorNotifications & JSXBase.HTMLAttributes; "elsa-webhook-definition-editor-screen": LocalJSX.ElsaWebhookDefinitionEditorScreen & JSXBase.HTMLAttributes; "elsa-webhook-definitions-list-screen": LocalJSX.ElsaWebhookDefinitionsListScreen & JSXBase.HTMLAttributes; - "elsa-webhook-save-button": LocalJSX.ElsaWebhookSaveButton & JSXBase.HTMLAttributes; "elsa-workflow-blueprint-viewer-screen": LocalJSX.ElsaWorkflowBlueprintViewerScreen & JSXBase.HTMLAttributes; "elsa-workflow-definition-editor-notifications": LocalJSX.ElsaWorkflowDefinitionEditorNotifications & JSXBase.HTMLAttributes; "elsa-workflow-definition-editor-screen": LocalJSX.ElsaWorkflowDefinitionEditorScreen & JSXBase.HTMLAttributes; diff --git a/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-definition-editor-screen/elsa-webhook-definition-editor-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-definition-editor-screen/elsa-webhook-definition-editor-screen.tsx index 20c706686..48d544f5d 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-definition-editor-screen/elsa-webhook-definition-editor-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-definition-editor-screen/elsa-webhook-definition-editor-screen.tsx @@ -6,11 +6,12 @@ import {createElsaClient, SaveWebhookDefinitionRequest} from "../../../../servic import {pluginManager} from '../../../../services/plugin-manager'; import state from '../../../../utils/store'; import Tunnel, {WebhookEditorState} from '../../../../data/webhook-editor'; -//import {ActivityContextMenuState, WorkflowDesignerMode} from "../../../designers/tree/elsa-designer-tree/models"; -import {MonacoValueChangedArgs} from "../../../controls/elsa-monaco/elsa-monaco"; -import {MarkerSeverity} from "monaco-editor"; import {checkBox, FormContext, selectField, SelectOption, textArea, textInput} from "../../../../utils/forms"; -//import {registerClickOutside} from "stencil-click-outside"; + +interface VariableDefinition { + name?: string; + value?: string +} @Component({ tag: 'elsa-webhook-definition-editor-screen', @@ -23,14 +24,15 @@ export class ElsaWebhookDefinitionEditorScreen { } @Event() webhookSaved: EventEmitter; - @Prop({attribute: 'webhook-definition-id', reflect: true}) webhookDefinitionId: string; + @Prop({attribute: 'webhook-definition-id', reflect: true}) webhookId: string; @Prop({attribute: 'server-url', reflect: true}) serverUrl: string; @Prop({attribute: 'monaco-lib-path', reflect: true}) monacoLibPath: string; + //@Prop() webhookDefinitionInternal: WebhookDefinition; @State() webhookDefinition: WebhookDefinition; - @State() webhookModel: WebhookModel; @State() saving: boolean; @State() saved: boolean; @State() networkError: string; + monacoEditor: HTMLElsaMonacoElement; formContext: FormContext; el: HTMLElement; @@ -40,20 +42,26 @@ export class ElsaWebhookDefinitionEditorScreen { } @Method() - async getWebhookDefinitionId(): Promise { - return this.webhookDefinition.definitionId; + async getWebhookId(): Promise { + return this.webhookDefinition.id; } - @Watch('webhookDefinitionId') - async webhookDefinitionIdChangedHandler(newValue: string) { - const webhookDefinitionId = newValue; - let webhookDefinition: WebhookDefinition = ElsaWebhookDefinitionEditorScreen.createWebhookDefinition(); - webhookDefinition.definitionId = webhookDefinitionId; - const client = createElsaClient(this.serverUrl); + @Watch('webhookDefinition') + handleWebhookDefinitionChanged(newValue: WebhookDefinition) { + this.webhookDefinition = {...newValue}; + this.formContext = new FormContext(this.webhookDefinition, newValue => this.webhookDefinition = newValue); + } - if (webhookDefinitionId && webhookDefinitionId.length > 0) { + @Watch('webhookId') + async webhookIdChangedHandler(newValue: string) { + const webhookId = newValue; + let webhookDefinition: WebhookDefinition = ElsaWebhookDefinitionEditorScreen.createWebhookDefinition(); + webhookDefinition.id = webhookId; + const client = createElsaClient(this.serverUrl); + debugger + if (webhookId && webhookId.length > 0) { try { - webhookDefinition = await client.webhookDefinitionsApi.getByDefinition(webhookDefinitionId); + webhookDefinition = await client.webhookDefinitionsApi.getByWebhookId(webhookId); } catch { console.warn(`The specified webhook definition does not exist. Creating a new one.`) } @@ -62,21 +70,10 @@ export class ElsaWebhookDefinitionEditorScreen { this.updateWebhookDefinition(webhookDefinition); } - //@Watch('webhookDefinition') - //handleWebhookDefinitionChanged(newValue: WebhookDefinition) { -// this.webhookDefinition = {...newValue}; - //this.formContext = new FormContext(this.webhookDefinition, newValue => this.webhookDefinition = newValue); - //} - @Watch("serverUrl") async serverUrlChangedHandler(newValue: string) { } - @Watch("monacoLibPath") - async monacoLibPathChangedHandler(newValue: string) { - state.monacoLibPath = newValue; - } - //@Listen('webhook-changed') //async webhookChangedHandler(event: CustomEvent) { //const webhookModel = event.detail; @@ -85,26 +82,20 @@ export class ElsaWebhookDefinitionEditorScreen { async componentWillLoad() { await this.serverUrlChangedHandler(this.serverUrl); - await this.webhookDefinitionIdChangedHandler(this.webhookDefinitionId); - await this.monacoLibPathChangedHandler(this.monacoLibPath); + await this.webhookIdChangedHandler(this.webhookId); + await this.handleWebhookDefinitionChanged(this.webhookDefinition); } - updateWebhookDefinition(value: WebhookDefinition) { - this.webhookDefinition = value; - //this.webhookModel = this.mapWorkflowModel(value); - } + async saveWebhook() { - async saveWebhook(webhookModel?: WebhookModel) { if (!this.serverUrl || this.serverUrl.length == 0) return; - webhookModel = webhookModel || this.webhookModel; - const client = createElsaClient(this.serverUrl); let webhookDefinition = this.webhookDefinition; const request: SaveWebhookDefinitionRequest = { - webhookDefinitionId: webhookDefinition.definitionId || this.webhookDefinitionId, + webhookId: webhookDefinition.id || this.webhookId, name: webhookDefinition.name, path: webhookDefinition.path, description: webhookDefinition.description, @@ -112,58 +103,37 @@ export class ElsaWebhookDefinitionEditorScreen { isEnabled: webhookDefinition.isEnabled, }; - //this.saving = !publish; - //this.publishing = publish; - try { webhookDefinition = await client.webhookDefinitionsApi.save(request); this.webhookDefinition = webhookDefinition; - this.saving = false; setTimeout(() => this.saved = false, 500); this.webhookSaved.emit(webhookDefinition); - } catch (e) { - console.error(e); - this.saving = false; - this.saved = false; + } + catch (e) { + console.error(e); this.networkError = e.message; setTimeout(() => this.networkError = null, 10000); } } - async onSaveClicked(e: Event) { - e.preventDefault(); - `debugger` - await this.saveWebhook(); + updateWebhookDefinition(value: WebhookDefinition) { + this.webhookDefinition = value; } - onMonacoValueChanged(e: MonacoValueChangedArgs) { - // Don't try and parse JSON if it contains errors. - const errorCount = e.markers.filter(x => x.severity == MarkerSeverity.Error).length; - - if (errorCount > 0) - return; - - const newValue = e.value; - let data = this.webhookDefinition.variables ? this.webhookDefinition.variables.data || {} : {}; - - try { - data = newValue.indexOf('{') >= 0 ? JSON.parse(newValue) : {}; - } catch (e) { - } finally { - this.webhookDefinition = {...this.webhookDefinition, variables: {data: data}}; - } - } + async onSaveClicked(e: Event) { + e.preventDefault(); + await this.saveWebhook(); + } render() { const tunnelState: WebhookEditorState = { serverUrl: this.serverUrl, - webhookDefinitionId: this.webhookDefinition.definitionId + webhookId: this.webhookDefinition.id }; return ( this.el = el}> -
this.onSaveClicked(e)}>
@@ -232,9 +202,7 @@ export class ElsaWebhookDefinitionEditorScreen { private static createWebhookDefinition(): WebhookDefinition { return { - definitionId: null, - //version: 1, - //activities: [], + id: null, }; } } diff --git a/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-save-button/elsa-webhook-save-button.tsx b/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-save-button/elsa-webhook-save-button.tsx deleted file mode 100644 index c11ef293e..000000000 --- a/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-save-button/elsa-webhook-save-button.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import {Component, Host, h, Prop, State, Event, EventEmitter, Watch} from '@stencil/core'; -import {enter, leave, toggle} from 'el-transition' -import {registerClickOutside} from "stencil-click-outside"; -import {WebhookDefinition} from "../../../../models/webhook"; -import {createElsaClient} from "../../../../services/elsa-client"; -import Tunnel from '../../../../data/workflow-editor'; - -@Component({ - tag: 'elsa-webhook-save-button', - shadow: false, -}) -export class ElsaWebhookSaveButton { - - @Prop() webhookDefinition: WebhookDefinition; - @Prop() saving: boolean; - @Event({bubbles: true}) saveClicked: EventEmitter; - - //menu: HTMLElement; - - onSaveClick() { - this.saveClicked.emit(); - //leave(this.menu); - } - - render() { - return ( - - - {this.saving ? this.renderSavingButton() : this.renderSaveButton()} - - - - - ); - } - - renderSaveButton() { - return ( - ); - } - - renderSavingButton() { - return ( - ); - } -} - -Tunnel.injectProps(ElsaWebhookSaveButton, ['serverUrl']); diff --git a/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-save-button/readme.md b/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-save-button/readme.md deleted file mode 100644 index 3de3323f1..000000000 --- a/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-editor/elsa-webhook-save-button/readme.md +++ /dev/null @@ -1,38 +0,0 @@ -# elsa-webhook-save-button - - - - - - -## Properties - -| Property | Attribute | Description | Type | Default | -| ------------------- | --------- | ----------- | ------------------- | ----------- | -| `saving` | `saving` | | `boolean` | `undefined` | -| `webhookDefinition` | -- | | `WebhookDefinition` | `undefined` | - - -## Events - -| Event | Description | Type | -| ------------- | ----------- | ------------------ | -| `saveClicked` | | `CustomEvent` | - - -## Dependencies - -### Depends on - -- context-consumer - -### Graph -```mermaid -graph TD; - elsa-webhook-save-button --> context-consumer - style elsa-webhook-save-button fill:#f9f,stroke:#333,stroke-width:4px -``` - ----------------------------------------------- - -*Built with [StencilJS](https://stenciljs.com/)* diff --git a/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-list/else-webhook-definitions-screen/elsa-webhook-definitions-list-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-list/else-webhook-definitions-screen/elsa-webhook-definitions-list-screen.tsx index 4ee3d0c6e..7b410b82a 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-list/else-webhook-definitions-screen/elsa-webhook-definitions-list-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/webhook-definition-list/else-webhook-definitions-screen/elsa-webhook-definitions-list-screen.tsx @@ -27,7 +27,7 @@ export class ElsaWebhookDefinitionsListScreen { return; const elsaClient = this.createClient(); - await elsaClient.webhookDefinitionsApi.delete(webhookDefinition.definitionId); + await elsaClient.webhookDefinitionsApi.delete(webhookDefinition.id); await this.loadWebhookDefinitions(); } @@ -43,12 +43,11 @@ export class ElsaWebhookDefinitionsListScreen { } render() { - const webhookDefinitions = this.webhookDefinitions.items; - const groupings = collection.groupBy(webhookDefinitions, 'definitionId'); + const webhookDefinitions = this.webhookDefinitions; + const list = collection.orderBy(webhookDefinitions, 'name'); return (
- {this.webhookDefinitions.items.length}
@@ -64,9 +63,9 @@ export class ElsaWebhookDefinitionsListScreen { - {collection.map(groupings, group => { - const names = collection.orderBy(group, 'name', 'desc'); - const webhookDefinition: WebhookDefinitionSummary = names[0]; + {collection.map(list, item => { + + const webhookDefinition: WebhookDefinitionSummary = item; let webhookDisplayName = webhookDefinition.name; if (!webhookDisplayName || webhookDisplayName.trim().length == 0) @@ -75,7 +74,8 @@ export class ElsaWebhookDefinitionsListScreen { if (!webhookDisplayName || webhookDisplayName.trim().length == 0) webhookDisplayName = 'Untitled'; - const editUrl = `/webhook-definitions/${webhookDefinition.definitionId}`; + debugger + const editUrl = `/webhook-definitions/${webhookDefinition.id}`; const editIcon = ( diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-settings-modal/elsa-workflow-settings-modal.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-settings-modal/elsa-workflow-settings-modal.tsx index 64a35b265..ad9432b21 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-settings-modal/elsa-workflow-settings-modal.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-settings-modal/elsa-workflow-settings-modal.tsx @@ -31,7 +31,7 @@ export class ElsaWorkflowDefinitionSettingsModal { this.formContext = new FormContext(this.workflowDefinitionInternal, newValue => this.workflowDefinitionInternal = newValue); } - componentWillLoad() { + componentWillLoad() { this.handleWorkflowDefinitionChanged(this.workflowDefinition); } diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-list/elsa-workflow-definitions-screen/elsa-workflow-definitions-list-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-list/elsa-workflow-definitions-screen/elsa-workflow-definitions-list-screen.tsx index 2508a8841..7157c1711 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-list/elsa-workflow-definitions-screen/elsa-workflow-definitions-list-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-list/elsa-workflow-definitions-screen/elsa-workflow-definitions-list-screen.tsx @@ -44,7 +44,7 @@ export class ElsaWorkflowDefinitionsListScreen { render() { const workflowDefinitions = this.workflowDefinitions.items; - const groupings = collection.groupBy(workflowDefinitions, 'definitionId'); + const groupings = collection.groupBy(workflowDefinitions, 'id'); return (
diff --git a/src/designer/elsa-workflows-studio/src/data/webhook-editor.tsx b/src/designer/elsa-workflows-studio/src/data/webhook-editor.tsx index 4e975fc1c..c5b5d106c 100644 --- a/src/designer/elsa-workflows-studio/src/data/webhook-editor.tsx +++ b/src/designer/elsa-workflows-studio/src/data/webhook-editor.tsx @@ -2,13 +2,13 @@ import {createProviderConsumer} from "@stencil/state-tunnel"; import {h} from "@stencil/core"; export interface WebhookEditorState { - webhookDefinitionId: string; + webhookId: string; serverUrl: string; } export default createProviderConsumer( { - webhookDefinitionId: null, + webhookId: null, serverUrl: null }, (subscribe, child) => () diff --git a/src/designer/elsa-workflows-studio/src/models/webhook/domain.ts b/src/designer/elsa-workflows-studio/src/models/webhook/domain.ts index 9de4b54b5..fbc3e86a5 100644 --- a/src/designer/elsa-workflows-studio/src/models/webhook/domain.ts +++ b/src/designer/elsa-workflows-studio/src/models/webhook/domain.ts @@ -2,27 +2,20 @@ import {Map} from '../../utils/utils'; export interface WebhookDefinition { id?: string; - definitionId?: string; tenantId?: string; name?: string; path?: string; description?: string; payloadTypeName?: string; isEnabled?: boolean; - variables?: Variables; } export interface WebhookDefinitionSummary { id?: string; - definitionId?: string; tenantId?: string; name?: string; path?: string; description?: string; payloadTypeName?: string; isEnabled?: boolean; -} - -export interface Variables { - data: Map; - } \ No newline at end of file +} \ No newline at end of file diff --git a/src/designer/elsa-workflows-studio/src/models/webhook/events.ts b/src/designer/elsa-workflows-studio/src/models/webhook/events.ts index 1e4de912c..6180d2d05 100644 --- a/src/designer/elsa-workflows-studio/src/models/webhook/events.ts +++ b/src/designer/elsa-workflows-studio/src/models/webhook/events.ts @@ -1,5 +1,4 @@ export const EventTypes = { - //ShowWorkflowSettings: 'show-workflow-settings', UpdateWebhook: 'update-webhook', WebhookModelChanged: 'webhook-model-changed', WebhookSaved: 'webhook-saved', diff --git a/src/designer/elsa-workflows-studio/src/models/webhook/view.ts b/src/designer/elsa-workflows-studio/src/models/webhook/view.ts index fd14b9c65..3eb35ef88 100644 --- a/src/designer/elsa-workflows-studio/src/models/webhook/view.ts +++ b/src/designer/elsa-workflows-studio/src/models/webhook/view.ts @@ -1,2 +1,2 @@ export interface WebhookModel { - } \ No newline at end of file +} \ No newline at end of file diff --git a/src/designer/elsa-workflows-studio/src/services/elsa-client.ts b/src/designer/elsa-workflows-studio/src/services/elsa-client.ts index c4edbc10e..7a8f35794 100644 --- a/src/designer/elsa-workflows-studio/src/services/elsa-client.ts +++ b/src/designer/elsa-workflows-studio/src/services/elsa-client.ts @@ -23,12 +23,11 @@ export const createElsaClient = function (serverUrl: string): ElsaClient { const httpClient = axios.create(config); return { - activitiesApi: { + activitiesApi: { list: async () => { const response = await httpClient.get>('v1/activities'); - debugger; return response.data; - } + } }, workflowDefinitionsApi: { list: async (page?: number, pageSize?: number, versionOptions?: VersionOptions) => { @@ -83,16 +82,16 @@ export const createElsaClient = function (serverUrl: string): ElsaClient { const response = await httpClient.get>(`v1/webhook-definitions`); return response.data; }, - getByDefinition: async (definitionId: string) => { - const response = await httpClient.get(`v1/webhook-definitions/${definitionId}`); + getByWebhookId: async (webhookId: string) => { + const response = await httpClient.get(`v1/webhook-definitions/${webhookId}`); return response.data; }, save: async request => { const response = await httpClient.post('v1/webhook-definitions', request); return response.data; }, - delete: async definitionId => { - await httpClient.delete(`v1/webhook-definitions/${definitionId}`); + delete: async webhookId => { + await httpClient.delete(`v1/webhook-definitions/${webhookId}`); }, }, workflowRegistryApi: { @@ -226,11 +225,11 @@ export interface WebhookDefinitionsApi { list(page?: number, pageSize?: number): Promise>; - getByDefinition(definitionId: string): Promise; + getByWebhookId(webhookId: string): Promise; save(request: SaveWebhookDefinitionRequest): Promise; - delete(definitionId: string): Promise; + delete(webhookId: string): Promise; } export interface WorkflowRegistryApi { @@ -296,7 +295,7 @@ export interface SaveWorkflowDefinitionRequest { } export interface SaveWebhookDefinitionRequest { - webhookDefinitionId?: string; + webhookId?: string; name?: string; path?: string; description?: string;