diff --git a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/DropDownOptionsProviderBase.cs b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/DropDownOptionsProviderBase.cs new file mode 100644 index 000000000..3d68c217d --- /dev/null +++ b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/DropDownOptionsProviderBase.cs @@ -0,0 +1,35 @@ +using System.Reflection; + +namespace Elsa.Workflows.UIHints.CheckList; + +/// +/// A base class for providing options to populate a checklist UI component. This class is intended to be inherited to implement +/// custom checklist data logic by overriding the `GetItemsAsync` method. +/// +public abstract class CheckListOptionsProviderBase : IPropertyUIHandler +{ + /// + public async ValueTask> GetUIPropertiesAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken = default) + { + var items = await GetItemsAsync(propertyInfo, context, cancellationToken); + var props = new CheckListProps + { + CheckList = new() + { + Items = items.ToList() + } + }; + + var options = new Dictionary + { + [InputUIHints.CheckList] = props + }; + + return options; + } + + /// + /// Implement this to provide items to the dropdown list. + /// + protected abstract ValueTask> GetItemsAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/StaticCheckListOptionsProvider.cs b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/StaticCheckListOptionsProvider.cs index 38426e266..52ede3106 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/StaticCheckListOptionsProvider.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/StaticCheckListOptionsProvider.cs @@ -25,7 +25,7 @@ public class StaticCheckListOptionsProvider : IPropertyUIHandler var props = new CheckListProps { - CheckList = new CheckList + CheckList = new() { Items = selectListItems.ToList() } diff --git a/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs b/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs index f6e169575..71bf63fe0 100644 --- a/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs +++ b/src/modules/Elsa.Workflows.Management/Features/WorkflowManagementFeature.cs @@ -41,8 +41,8 @@ namespace Elsa.Workflows.Management.Features; [DependsOn(typeof(WorkflowsFeature))] [DependsOn(typeof(WorkflowDefinitionsFeature))] [DependsOn(typeof(WorkflowInstancesFeature))] -[PublicAPI] -public class WorkflowManagementFeature : FeatureBase +[UsedImplicitly] +public class WorkflowManagementFeature(IModule module) : FeatureBase(module) { private const string PrimitivesCategory = "Primitives"; private const string LookupsCategory = "Lookups"; @@ -56,11 +56,6 @@ public class WorkflowManagementFeature : FeatureBase private LogPersistenceMode LogPersistenceMode { get; set; } = LogPersistenceMode.Include; private bool IsReadOnlyMode { get; set; } - /// - public WorkflowManagementFeature(IModule module) : base(module) - { - } - /// /// A set of activity types to make available to the system. /// diff --git a/src/modules/Elsa.Workflows.Runtime/Services/TaskReporter.cs b/src/modules/Elsa.Workflows.Runtime/Services/TaskReporter.cs index 560276b7e..54f86614f 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/TaskReporter.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/TaskReporter.cs @@ -11,9 +11,9 @@ public class TaskReporter(IBookmarkQueue bookmarkQueue, IStimulusHasher stimulus private static readonly string ActivityTypeName = ActivityTypeNameHelper.GenerateTypeName(); /// - public async Task ReportCompletionAsync(string taskId, object? result = default, CancellationToken cancellationToken = default) + public async Task ReportCompletionAsync(string taskId, object? result = null, CancellationToken cancellationToken = default) { - var stimulus = new RunTaskStimulus(taskId, default!); + var stimulus = new RunTaskStimulus(taskId, null!); var input = new Dictionary { @@ -24,7 +24,7 @@ public class TaskReporter(IBookmarkQueue bookmarkQueue, IStimulusHasher stimulus { ActivityTypeName = ActivityTypeName, StimulusHash = stimulusHasher.Hash(ActivityTypeName, stimulus), - Options = new ResumeBookmarkOptions + Options = new() { Input = input } diff --git a/src/modules/Elsa/Extensions/DependencyInjectionExtensions.cs b/src/modules/Elsa/Extensions/DependencyInjectionExtensions.cs index 51805f5a2..53b363962 100644 --- a/src/modules/Elsa/Extensions/DependencyInjectionExtensions.cs +++ b/src/modules/Elsa/Extensions/DependencyInjectionExtensions.cs @@ -15,10 +15,10 @@ public static class ModuleExtensions /// /// Creates a new Elsa module and adds the to it. /// - public static IModule AddElsa(this IServiceCollection services, Action? configure = default) + public static IModule AddElsa(this IServiceCollection services, Action? configure = null) { var module = services.GetOrCreateModule(); - module.Configure(app => app.Configurator = configure); + module.Configure(app => app.Configurator += configure); module.Apply(); return module; @@ -27,7 +27,7 @@ public static class ModuleExtensions /// /// Configures the Elsa module. /// - public static IModule ConfigureElsa(this IServiceCollection services, Action? configure = default) + public static IModule ConfigureElsa(this IServiceCollection services, Action? configure = null) { var module = services.GetOrCreateModule(); diff --git a/src/modules/Elsa/Features/AppFeature.cs b/src/modules/Elsa/Features/AppFeature.cs index 0a72a3396..775b19981 100644 --- a/src/modules/Elsa/Features/AppFeature.cs +++ b/src/modules/Elsa/Features/AppFeature.cs @@ -8,13 +8,8 @@ namespace Elsa.Features; /// A wrapper for invoking application-specific configuration, ensuring it is invoked lastly. /// [DependsOn(typeof(ElsaFeature))] -public class AppFeature : FeatureBase +public class AppFeature(IModule module) : FeatureBase(module) { - /// - public AppFeature(IModule module) : base(module) - { - } - /// /// The configurator to invoke. ///