From 0eb01c01f359329d2818b6e278317285aa75a60b Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 5 Mar 2024 07:31:59 +0100 Subject: [PATCH] Add SearchTerm to Workflow Definitions List API client (#5035) * Refactor search filtering and move ListWorkflowDefinitionsRequest file Updated the searching mechanism in `WorkflowDefinitionFilter.cs` by validating that Name and Description are not null before performing the search. In `ListWorkflowDefinitionsRequest.cs`, the file was moved from the Responses namespace to Requests and a new property `SearchTerm` was added, allowing filtering of workflow definitions by their name, ID or description. * Update code style settings for csproj The .DotSettings file for the project has been adjusted with changes to code naming rules and settings migration. These modifications adjust policies for naming conventions of Instance and Static fields, enhancing code style conformance. Also, an additional settings migration rule has been applied. * Add 'issue/*' branch to GitHub actions workflow The GitHub actions workflow has been updated to include the 'issue/*' branch. This ensures that any changes made in the 'issue/*' branches will trigger the workflow and any associated tests or builds, improving the overall continuous integration process. * Remove Skip and Take methods from SqlServerDialect The mentioned functions have been removed from SqlServerDialect class in the Elsa.Dapper module. The base class provides the correct default implementation for the SQL Server dialect. --- .github/workflows/packages.yml | 1 + build/_build.csproj.DotSettings | 5 ++++- .../ListWorkflowDefinitionsRequest.cs | 8 +++++++- src/modules/Elsa.Dapper/Dialects/SqlServerDialect.cs | 5 ----- .../Filters/WorkflowDefinitionFilter.cs | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) rename src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/{Responses => Requests}/ListWorkflowDefinitionsRequest.cs (85%) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 1e6a9c51e..d6226e7af 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -5,6 +5,7 @@ on: branches: - 'main' - 'feature/*' + - 'issue/*' - 'enhancement/*' - 'patch/*' - 'fix/*' diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings index eb3f4c27c..c815d363e 100644 --- a/build/_build.csproj.DotSettings +++ b/build/_build.csproj.DotSettings @@ -17,6 +17,8 @@ False <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> True True True @@ -25,4 +27,5 @@ True True True - True + True + True diff --git a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Responses/ListWorkflowDefinitionsRequest.cs b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Requests/ListWorkflowDefinitionsRequest.cs similarity index 85% rename from src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Responses/ListWorkflowDefinitionsRequest.cs rename to src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Requests/ListWorkflowDefinitionsRequest.cs index 9f928d19d..cc18d3f94 100644 --- a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Responses/ListWorkflowDefinitionsRequest.cs +++ b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Requests/ListWorkflowDefinitionsRequest.cs @@ -2,7 +2,8 @@ using Elsa.Api.Client.Resources.WorkflowDefinitions.Enums; using Elsa.Api.Client.Shared.Models; using Refit; -namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses; +namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Requests +; /// /// Represents a request to list workflow definitions. @@ -42,6 +43,11 @@ public class ListWorkflowDefinitionsRequest /// [AliasAs("label")] public string[]? Labels { get; set; } + + /// + /// The search term used to filter workflow definitions by their name, ID or description. + /// + public string? SearchTerm { get; set; } /// /// The field to order by. diff --git a/src/modules/Elsa.Dapper/Dialects/SqlServerDialect.cs b/src/modules/Elsa.Dapper/Dialects/SqlServerDialect.cs index 665de65c5..f0733c7ee 100644 --- a/src/modules/Elsa.Dapper/Dialects/SqlServerDialect.cs +++ b/src/modules/Elsa.Dapper/Dialects/SqlServerDialect.cs @@ -7,9 +7,4 @@ namespace Elsa.Dapper.Dialects; /// public class SqlServerDialect : SqlDialectBase { - /// - public override string Skip(int count) => $"Offset {count} Rows"; - - /// - public override string Take(int count) => $"fetch next {count} rows only"; } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Management/Filters/WorkflowDefinitionFilter.cs b/src/modules/Elsa.Workflows.Management/Filters/WorkflowDefinitionFilter.cs index 407328999..29de80ad8 100644 --- a/src/modules/Elsa.Workflows.Management/Filters/WorkflowDefinitionFilter.cs +++ b/src/modules/Elsa.Workflows.Management/Filters/WorkflowDefinitionFilter.cs @@ -78,7 +78,7 @@ public class WorkflowDefinitionFilter if (filter.Name != null) queryable = queryable.Where(x => x.Name == filter.Name); if (filter.Names != null) queryable = queryable.Where(x => filter.Names.Contains(x.Name!)); if (filter.UsableAsActivity != null) queryable = queryable.Where(x => x.Options.UsableAsActivity == filter.UsableAsActivity); - if (!string.IsNullOrWhiteSpace(filter.SearchTerm)) queryable = queryable.Where(x => x.Name.Contains(filter.SearchTerm) || x.Description.Contains(filter.SearchTerm) || x.Id == filter.SearchTerm || x.DefinitionId == filter.SearchTerm); + if (!string.IsNullOrWhiteSpace(filter.SearchTerm)) queryable = queryable.Where(x => x.Name!.Contains(filter.SearchTerm) || x.Description!.Contains(filter.SearchTerm) || x.Id == filter.SearchTerm || x.DefinitionId == filter.SearchTerm); return queryable; }