-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#10849 Liquid syntax support for CorrelateTask #12021
Conversation
Seems there's a breaking changes |
@hishamco no, there is not here you have recipe from OC before that PR, and you can test it with this PR, and see that, this feature has backward compatibility |
src/OrchardCore.Modules/OrchardCore.Workflows/Activities/CorrelateTask.cs
Outdated
Show resolved
Hide resolved
This pull request has merge conflicts. Please resolve those before requesting a review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sincerely apologize for us taking so much time here. I checked out the PR, going over old ones, and this would be quite useful.
How about other activities, see this comment? #10849 (comment)
Is triage still needed here, @Skrypt? And do you also want to review this?
src/OrchardCore.Modules/OrchardCore.Workflows/Activities/CorrelateTask.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/CorrelateTask.Fields.Edit.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/CorrelateTask.Fields.Edit.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/CorrelateTask.Fields.Edit.cshtml
Outdated
Show resolved
Hide resolved
@Piedone maybe we should take a look more often to PR marked with "need triage" on thursday meetings. I've been trying to make @sebastienros to take a look at those by marking these with that tag. I think I had no comment to add on the PR and it just needed triage. |
Sure, please bring them up. I think we only need to triage PRs on the meeting when there's something to discuss with the wider audience (this PR is like that, then?), i.e. you as a reviewer aren't sure. Please keep to these @lampersky:
|
…elateTask.Fields.Edit.cshtml Co-authored-by: Zoltán Lehóczky <[email protected]>
…elateTask.Fields.Edit.cshtml Co-authored-by: Zoltán Lehóczky <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MikeAlhayek @sebastienros could you please check this during the next triage too?
var value = Syntax switch { | ||
"Liquid" => await _expressionEvaluator.EvaluateAsync(Value, workflowContext, null), | ||
"JavaScript" => (await _scriptEvaluator.EvaluateAsync(Value, workflowContext, null))?.Trim(), | ||
_ => null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ => null | |
_ => throw new NotSupportedException($"The syntax {Syntax} isn't supported for CorrelateTask.") |
src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/CorrelateTask.Fields.Edit.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Activities/CorrelateTask.cs
Outdated
Show resolved
Hide resolved
@@ -28,14 +30,25 @@ public WorkflowExpression<string> Value | |||
set => SetProperty(value); | |||
} | |||
|
|||
public string Syntax | |||
{ | |||
get => GetProperty(() => "JavaScript"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the property name here is Synax and the value is JavaScript? Shouldn't the default value be set in the display driver instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For preexisting Tasks we need "JavaScript"
here, so they'll continue to run without any user interaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If enum is used, then we don't need this
src/OrchardCore.Modules/OrchardCore.Workflows/Activities/CorrelateTask.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Drivers/CorrelateTaskDisplayDriver.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/ViewModels/CorrelateTaskViewModel.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/CorrelateTask.Fields.Edit.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/CorrelateTask.Fields.Edit.cshtml
Outdated
Show resolved
Hide resolved
… into lampersky/fix10849
When you're done addressing all feedback of a review, click "Re-request review" in the top-right corner for each reviewer when you're ready for another round of review, so they know that you're done. |
@@ -10,12 +11,16 @@ namespace OrchardCore.Workflows.Activities | |||
public class CorrelateTask : TaskActivity<CorrelateTask> | |||
{ | |||
private readonly IWorkflowScriptEvaluator _scriptEvaluator; | |||
private readonly IWorkflowExpressionEvaluator _expressionEvaluator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private readonly IWorkflowExpressionEvaluator _expressionEvaluator; | |
private readonly IWorkflowExpressionEvaluator _expressionEvaluator; | |
protected readonly IStringLocalizer S; | ||
|
||
public CorrelateTask(IWorkflowScriptEvaluator scriptEvaluator, IStringLocalizer<CorrelateTask> localizer) | ||
public CorrelateTask(IWorkflowScriptEvaluator scriptEvaluator, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public CorrelateTask(IWorkflowScriptEvaluator scriptEvaluator, | |
public CorrelateTask( | |
IWorkflowScriptEvaluator scriptEvaluator, |
document.getElementById('@Html.IdFor(x => x.Syntax)').addEventListener("change", (e) => { | ||
const syntax = e.target.value; | ||
|
||
if (syntax == '@WorkflowScriptSyntax.JavaScript') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nameof() if faster than .ToString()
if (syntax == '@WorkflowScriptSyntax.JavaScript') { | |
if (syntax == '@nameof(WorkflowScriptSyntax.JavaScript)') { |
<div class="form-group mb-3" asp-validation-class-for="Syntax"> | ||
<label asp-for="Syntax" class="form-label">@T["Syntax"]</label> | ||
<select asp-for="Syntax" class="form-select"> | ||
<option value="@WorkflowScriptSyntax.JavaScript">@T["JavaScript"]</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<option value="@WorkflowScriptSyntax.JavaScript">@T["JavaScript"]</option> | |
<option value="@nameof(WorkflowScriptSyntax.JavaScript)">@T["JavaScript"]</option> |
<label asp-for="Syntax" class="form-label">@T["Syntax"]</label> | ||
<select asp-for="Syntax" class="form-select"> | ||
<option value="@WorkflowScriptSyntax.JavaScript">@T["JavaScript"]</option> | ||
<option value="@WorkflowScriptSyntax.Liquid">@T["Liquid"]</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<option value="@WorkflowScriptSyntax.Liquid">@T["Liquid"]</option> | |
<option value="@nameof(WorkflowScriptSyntax.Liquid)">@T["Liquid"]</option> |
@@ -0,0 +1,8 @@ | |||
namespace OrchardCore.Workflows.Models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please use file-scope name spaces?
using System; | ||
using OrchardCore.Workflows.Models; | ||
|
||
namespace OrchardCore.Workflows.Helpers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace OrchardCore.Workflows.Helpers; | |
namespace OrchardCore.Workflows.Helpers; | |
document.getElementById('liquid_hint').classList.add('d-none'); | ||
document.getElementById('javascript_hint').classList.remove('d-none'); | ||
} else { | ||
editor.setOption('mode', 'liquid'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a valid value for the editor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it is
<div class="form-group mb-3" asp-validation-class-for="Syntax"> | ||
<label asp-for="Syntax" class="form-label">@T["Syntax"]</label> | ||
<select asp-for="Syntax" class="form-select"> | ||
<option value="@WorkflowScriptSyntax.JavaScript">@T["JavaScript"]</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<option value="@WorkflowScriptSyntax.JavaScript">@T["JavaScript"]</option> | |
<option value="@nameof(WorkflowScriptSyntax.JavaScript)">@T["JavaScript"]</option> |
<label asp-for="Syntax" class="form-label">@T["Syntax"]</label> | ||
<select asp-for="Syntax" class="form-select"> | ||
<option value="@WorkflowScriptSyntax.JavaScript">@T["JavaScript"]</option> | ||
<option value="@WorkflowScriptSyntax.Liquid">@T["Liquid"]</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<option value="@WorkflowScriptSyntax.Liquid">@T["Liquid"]</option> | |
<option value="@nameof(WorkflowScriptSyntax.Liquid)">@T["Liquid"]</option> |
<option value="@WorkflowScriptSyntax.Liquid">@T["Liquid"]</option> | ||
</select> | ||
<span asp-validation-for="Syntax"></span> | ||
<span class="hint">@T["Choose between Liquid or JavaScript syntax."]</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is useful and can we removed
<span class="hint">@T["Choose between Liquid or JavaScript syntax."]</span> |
public enum WorkflowScriptSyntax | ||
{ | ||
JavaScript, | ||
Liquid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Liquid | |
Liquid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be the first enum with such convention, I've just checked and all enums in the project are without comma after last item, so I will leave it as is
It seems that this pull request didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please comment if you'd like to pick it up. |
@MikeAlhayek this is waiting for your review. |
fixes #10849
this is how it works:
correlateTaskLiquid.mp4
/cc @Skrypt