From a6ef4c59a53b0428688b201546c4617c8942ab16 Mon Sep 17 00:00:00 2001 From: jtkech Date: Fri, 22 Dec 2023 01:28:43 +0100 Subject: [PATCH 1/3] FormLocationKey ArgumentNullException --- .../Http/Activities/HttpRequestEvent.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Http/Activities/HttpRequestEvent.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Http/Activities/HttpRequestEvent.cs index 9eb46001d4b..a1fdcec43cf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Http/Activities/HttpRequestEvent.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Http/Activities/HttpRequestEvent.cs @@ -55,8 +55,8 @@ public int TokenLifeSpan public string FormLocationKey { - get => GetProperty(); - set => SetProperty(value); + get => GetProperty(() => string.Empty); + set => SetProperty(value ?? string.Empty); } public override bool CanExecute(WorkflowExecutionContext workflowContext, ActivityContext activityContext) @@ -77,13 +77,10 @@ public override Task ExecuteAsync(WorkflowExecutionCont if (!workflowContext.Output.TryGetValue(WorkflowConstants.HttpFormLocationOutputKeyName, out var obj) || obj is not Dictionary formLocation) { - formLocation = new Dictionary(); + formLocation = []; } - // if no custom location-key was provided, we use empty string as the default key. - var location = FormLocationKey ?? string.Empty; - - formLocation[location] = GetLocationUrl(value); + formLocation[FormLocationKey] = GetLocationUrl(value); workflowContext.Output[WorkflowConstants.HttpFormLocationOutputKeyName] = formLocation; } From 2f594c5a944b8a3062d0aa068085ce85c278dbcd Mon Sep 17 00:00:00 2001 From: jtkech Date: Fri, 22 Dec 2023 03:09:45 +0100 Subject: [PATCH 2/3] Idem for Redirect To Form Location --- .../Activities/HttpRedirectToFormLocationTask.cs | 9 +++------ .../Views/Items/HttpRequestEvent.Fields.Edit.cshtml | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/Activities/HttpRedirectToFormLocationTask.cs b/src/OrchardCore.Modules/OrchardCore.Forms/Activities/HttpRedirectToFormLocationTask.cs index 5c69952bae9..b1e6d64b7d5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/Activities/HttpRedirectToFormLocationTask.cs +++ b/src/OrchardCore.Modules/OrchardCore.Forms/Activities/HttpRedirectToFormLocationTask.cs @@ -32,8 +32,8 @@ public override IEnumerable GetPossibleOutcomes(WorkflowExecutionContex public string FormLocationKey { - get => GetProperty(); - set => SetProperty(value); + get => GetProperty(() => string.Empty); + set => SetProperty(value ?? string.Empty); } public override Task ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext) @@ -41,10 +41,7 @@ public override Task ExecuteAsync(WorkflowExecutionCont if (workflowContext.Output.TryGetValue(WorkflowConstants.HttpFormLocationOutputKeyName, out var obj) && obj is Dictionary formLocations) { - // if no custom location-key was provided, we use empty string as the default key. - var location = FormLocationKey ?? string.Empty; - - if (formLocations.TryGetValue(location, out var path)) + if (formLocations.TryGetValue(FormLocationKey, out var path)) { _httpContextAccessor.HttpContext.Items[WorkflowConstants.FormOriginatedLocationItemsKey] = path; diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/HttpRequestEvent.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/HttpRequestEvent.Fields.Edit.cshtml index 7b5f64ad025..accc8340b22 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/HttpRequestEvent.Fields.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/HttpRequestEvent.Fields.Edit.cshtml @@ -41,7 +41,7 @@
- + @T["This key serves to differentiate the current form's location. Leave blank if the workflow handles a single form event."] From 51d0b264e69455ee2eb7b7bdbfd2af14c73dceec Mon Sep 17 00:00:00 2001 From: jtkech Date: Fri, 22 Dec 2023 04:45:14 +0100 Subject: [PATCH 3/3] UI hint tweaks --- .../Items/HttpRedirectToFormLocationTask.Fields.Edit.cshtml | 2 +- .../Views/Items/HttpRequestEvent.Fields.Edit.cshtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/HttpRedirectToFormLocationTask.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/HttpRedirectToFormLocationTask.Fields.Edit.cshtml index 0103d6f9622..287b87ea431 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/HttpRedirectToFormLocationTask.Fields.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Forms/Views/Items/HttpRedirectToFormLocationTask.Fields.Edit.cshtml @@ -6,5 +6,5 @@ - @T["This value needs to correspond with the Form Location Key value utilized in the HTTP request event settings. Leave blank if the workflow handles a single form event."] + @T["This key name should be equal to the 'Form Location Key' of the HTTP request event. Leave blank if the workflow only handles a single form."]
diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/HttpRequestEvent.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/HttpRequestEvent.Fields.Edit.cshtml index accc8340b22..1b1f4e79c6f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/HttpRequestEvent.Fields.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/HttpRequestEvent.Fields.Edit.cshtml @@ -44,7 +44,7 @@ - @T["This key serves to differentiate the current form's location. Leave blank if the workflow handles a single form event."] + @T["This key name is used to store and then retrieve the current form's location. Leave blank if the workflow doesn't handle any form or a single one."]