From 7cb228e710fbd76f88542e503d86ad2bb543af47 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 6 Jul 2021 11:06:13 +0200 Subject: [PATCH 1/4] Remove interfering demo headers sent from client --- src/designer/elsa-workflows-studio/src/index.html | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/designer/elsa-workflows-studio/src/index.html b/src/designer/elsa-workflows-studio/src/index.html index 1d3662fbb..3c7220ea4 100644 --- a/src/designer/elsa-workflows-studio/src/index.html +++ b/src/designer/elsa-workflows-studio/src/index.html @@ -15,6 +15,8 @@ + + @@ -30,11 +32,6 @@ service.register({ onRequest(request) { console.log('onRequest'); - request.headers = { - ...request.headers, - 'X-Client': 'Elsa Dashboard', - Authorization: 'Bearer secret-token' // For example, set a JWT value here. - }; return request; }, From ba9bb90cd4c14169fc9d92003bbd21f9628e5dec Mon Sep 17 00:00:00 2001 From: Jens Willmer Date: Tue, 6 Jul 2021 11:18:39 +0200 Subject: [PATCH 2/4] Fixed env var vor docker demo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ddb43259..eabba2930 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Check out the [Quickstart guides](https://elsa-workflows.github.io/elsa-core/doc A quick and easy way to give Elsa a spin is to run the following Docker command: ```bash -docker run -t -i -e ELSA__HTTP__BASEURL='http://localhost:13000' -p 13000:80 elsaworkflows/elsa-dashboard-and-server:latest +docker run -t -i -e ELSA__SERVER__BASEURL='http://localhost:13000' -p 13000:80 elsaworkflows/elsa-dashboard-and-server:latest ``` Then navigate to http://localhost:13000. From 709c7f7e598755309f6fb987d787b6c4478b256e Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 6 Jul 2021 12:04:50 +0200 Subject: [PATCH 3/4] Associate heartbeat workflow with a feature --- .../Extensions/ElsaOptionBuilderExtensions.cs | 3 +++ .../HeartbeatWorkflowsFeature.cs | 17 ++++++++++++ .../Startup.cs | 27 ++++++++++--------- .../appsettings.json | 1 + 4 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/HeartbeatWorkflowsFeature.cs diff --git a/src/core/Elsa.Core/Extensions/ElsaOptionBuilderExtensions.cs b/src/core/Elsa.Core/Extensions/ElsaOptionBuilderExtensions.cs index 3661d3476..3c033f2cb 100644 --- a/src/core/Elsa.Core/Extensions/ElsaOptionBuilderExtensions.cs +++ b/src/core/Elsa.Core/Extensions/ElsaOptionBuilderExtensions.cs @@ -14,6 +14,9 @@ namespace Elsa public static ElsaOptionsBuilder AddFeatures(this ElsaOptionsBuilder builder, IEnumerable assemblies, IConfiguration configuration, IEnumerable features) { + if (features == null!) // Null when configuration binding finds an empty array. + return builder; + var enabledFeatures = features.ToHashSet(); var startupTypesQuery = from assembly in assemblies diff --git a/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/HeartbeatWorkflowsFeature.cs b/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/HeartbeatWorkflowsFeature.cs new file mode 100644 index 000000000..6cfb6fd2d --- /dev/null +++ b/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/HeartbeatWorkflowsFeature.cs @@ -0,0 +1,17 @@ +using Elsa; +using Elsa.Attributes; +using Elsa.Services.Startup; +using ElsaDashboard.Samples.AspNetCore.Monolith.Workflows; +using Microsoft.Extensions.Configuration; + +namespace ElsaDashboard.Samples.AspNetCore.Monolith +{ + [Feature("Workflows:Heartbeat")] + public class HeartbeatWorkflowsFeature : StartupBase + { + public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration) + { + elsa.AddWorkflow(); + } + } +} \ No newline at end of file diff --git a/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/Startup.cs b/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/Startup.cs index cd0f94ee7..0941b4024 100644 --- a/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/Startup.cs +++ b/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/Startup.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using Elsa; using Elsa.Persistence.EntityFramework.Core.Extensions; using Elsa.Persistence.EntityFramework.Sqlite; @@ -22,26 +23,26 @@ namespace ElsaDashboard.Samples.AspNetCore.Monolith public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); - + // Elsa Server. var elsaSection = Configuration.GetSection("Elsa"); - + services .AddElsa(options => options - .UseEntityFrameworkPersistence(ef => ef.UseSqlite()) - .AddConsoleActivities() - .AddHttpActivities(elsaSection.GetSection("Server").Bind) - .AddEmailActivities(elsaSection.GetSection("Smtp").Bind) - .AddQuartzTemporalActivities() - .AddJavaScriptActivities() - .AddActivitiesFrom() - .AddWorkflowsFrom() + .UseEntityFrameworkPersistence(ef => ef.UseSqlite()) + .AddConsoleActivities() + .AddHttpActivities(elsaSection.GetSection("Server").Bind) + .AddEmailActivities(elsaSection.GetSection("Smtp").Bind) + .AddQuartzTemporalActivities() + .AddJavaScriptActivities() + .AddActivitiesFrom() + .AddFeatures(new[] { typeof(Startup) }, Configuration, elsaSection.GetSection("Features").Get>()) ); services .AddElsaSwagger() .AddElsaApiEndpoints(); - + // Allow arbitrary client browser apps to access the API. // In a production environment, make sure to allow only origins you trust. services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().WithExposedHeaders("Content-Disposition"))); @@ -72,9 +73,9 @@ namespace ElsaDashboard.Samples.AspNetCore.Monolith { // Elsa Server uses ASP.NET Core Controllers. endpoints.MapControllers(); - + endpoints.MapFallbackToPage("/_Host"); }); } } -} +} \ No newline at end of file diff --git a/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/appsettings.json b/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/appsettings.json index bdc4af7a8..2dd150d5b 100644 --- a/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/appsettings.json +++ b/src/samples/dashboard/aspnetcore/ElsaDashboard.Samples.AspNetCore.Monolith/appsettings.json @@ -8,6 +8,7 @@ }, "AllowedHosts": "*", "Elsa": { + "Features": [], "Server": { "BaseUrl": "https://localhost:15265", "BasePath": "/workflows" From 87c7cb08eccf5e6d46f2fbe20a57e48c2f7e0460 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 6 Jul 2021 13:14:02 +0200 Subject: [PATCH 4/4] Fix Redirect behavior See https://stackoverflow.com/questions/68217426/elsa-workflows-redirect-http-action-behavior --- .../Elsa.Activities.Http/Activities/Redirect/Redirect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activities/Elsa.Activities.Http/Activities/Redirect/Redirect.cs b/src/activities/Elsa.Activities.Http/Activities/Redirect/Redirect.cs index 129ee2262..ff0c9ac2b 100644 --- a/src/activities/Elsa.Activities.Http/Activities/Redirect/Redirect.cs +++ b/src/activities/Elsa.Activities.Http/Activities/Redirect/Redirect.cs @@ -42,7 +42,7 @@ namespace Elsa.Activities.Http if (response.HasStarted) return Fault(T["Response has already started"]!); - return new RedirectResult(_httpContextAccessor, Location, Permanent); + return Combine(new RedirectResult(_httpContextAccessor, Location, Permanent), Done()); } } } \ No newline at end of file