Skip to content
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

Cleanup workflow activities #14597

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace OrchardCore.Email.Workflows.Activities
{
public class EmailTask : TaskActivity
public class EmailTask : TaskActivity<EmailTask>
{
private readonly ISmtpService _smtpService;
private readonly IWorkflowExpressionEvaluator _expressionEvaluator;
Expand All @@ -29,8 +29,8 @@ HtmlEncoder htmlEncoder
_htmlEncoder = htmlEncoder;
}

public override string Name => nameof(EmailTask);
public override LocalizedString DisplayText => S["Email Task"];

public override LocalizedString Category => S["Messaging"];

public WorkflowExpression<string> Author
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OrchardCore.Forms.Workflows.Activities
{
public class AddModelValidationErrorTask : TaskActivity
public class AddModelValidationErrorTask : TaskActivity<AddModelValidationErrorTask>
{
private readonly IUpdateModelAccessor _updateModelAccessor;
protected readonly IStringLocalizer S;
Expand All @@ -22,8 +22,6 @@ IStringLocalizer<AddModelValidationErrorTask> localizer
S = localizer;
}

public override string Name => nameof(AddModelValidationErrorTask);

public override LocalizedString DisplayText => S["Add Model Validation Error Task"];

public override LocalizedString Category => S["Validation"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace OrchardCore.Forms.Workflows.Activities
{
public class BindModelStateTask : TaskActivity
public class BindModelStateTask : TaskActivity<BindModelStateTask>
{
private readonly IUpdateModelAccessor _updateModelAccessor;
private readonly IHttpContextAccessor _httpContextAccessor;
Expand All @@ -26,8 +26,6 @@ IStringLocalizer<BindModelStateTask> localizer
S = localizer;
}

public override string Name => nameof(BindModelStateTask);

public override LocalizedString DisplayText => S["Bind Model State Task"];

public override LocalizedString Category => S["Validation"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace OrchardCore.Forms.Workflows.Activities
{
public class ValidateAntiforgeryTokenTask : TaskActivity
public class ValidateAntiforgeryTokenTask : TaskActivity<ValidateAntiforgeryTokenTask>
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IAntiforgery _antiforgery;
Expand All @@ -26,8 +26,6 @@ IStringLocalizer<ValidateAntiforgeryTokenTask> localizer
S = localizer;
}

public override string Name => nameof(ValidateAntiforgeryTokenTask);

public override LocalizedString DisplayText => S["Validate Antiforgery Token Task"];

public override LocalizedString Category => S["Validation"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace OrchardCore.Forms.Workflows.Activities
{
// TODO: Add the ability to configure various types of validators.
public class ValidateFormFieldTask : TaskActivity
public class ValidateFormFieldTask : TaskActivity<ValidateFormFieldTask>
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IUpdateModelAccessor _updateModelAccessor;
Expand All @@ -27,8 +27,6 @@ IStringLocalizer<ValidateFormFieldTask> localizer
S = localizer;
}

public override string Name => nameof(ValidateFormFieldTask);

public override LocalizedString DisplayText => S["Validate Form Field Task"];

public override LocalizedString Category => S["Validation"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OrchardCore.Forms.Workflows.Activities
{
public class ValidateFormTask : TaskActivity
public class ValidateFormTask : TaskActivity<ValidateFormTask>
{
private readonly IUpdateModelAccessor _updateModelAccessor;
protected readonly IStringLocalizer S;
Expand All @@ -22,8 +22,6 @@ IStringLocalizer<ValidateFormTask> localizer
S = localizer;
}

public override string Name => nameof(ValidateFormTask);

public override LocalizedString DisplayText => S["Validate Form Task"];

public override LocalizedString Category => S["Validation"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace OrchardCore.Notifications.Activities;

public class NotifyContentOwnerTask : NotifyUserTaskActivity
public class NotifyContentOwnerTask : NotifyUserTaskActivity<NotifyContentOwnerTask>
{
private readonly ISession _session;

Expand All @@ -35,8 +35,6 @@ ISession session
_session = session;
}

public override string Name => nameof(NotifyContentOwnerTask);

public override LocalizedString DisplayText => S["Notify Content's Owner Task"];

protected override async Task<IEnumerable<IUser>> GetUsersAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace OrchardCore.Notifications.Activities;

public class NotifyUserTask : NotifyUserTaskActivity
public class NotifyUserTask : NotifyUserTaskActivity<NotifyUserTask>
{
public NotifyUserTask(
INotificationService notificationCoordinator,
Expand All @@ -27,8 +27,6 @@ IStringLocalizer<NotifyUserTask> localizer
{
}

public override string Name => nameof(NotifyUserTask);

public override LocalizedString DisplayText => S["Notify User Task"];

protected override Task<IEnumerable<IUser>> GetUsersAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,19 @@ protected virtual async Task<INotificationMessage> GetMessageAsync(WorkflowExecu

abstract protected Task<IEnumerable<IUser>> GetUsersAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext);
}

public abstract class NotifyUserTaskActivity<TActivity> : NotifyUserTaskActivity where TActivity : ITask
{
protected NotifyUserTaskActivity(
INotificationService notificationService,
IWorkflowExpressionEvaluator expressionEvaluator,
HtmlEncoder htmlEncoder,
ILogger logger,
IStringLocalizer localizer)
: base(notificationService, expressionEvaluator, htmlEncoder, logger, localizer)
{
}

// The technical name of the activity. Within a workflow definition, activities make use of this name.
public override string Name => typeof(TActivity).Name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace OrchardCore.ReCaptcha.Workflows
{
public class ValidateReCaptchaTask : TaskActivity
public class ValidateReCaptchaTask : TaskActivity<ValidateReCaptchaTask>
{
private readonly ReCaptchaService _reCaptchaService;
private readonly IUpdateModelAccessor _updateModelAccessor;
Expand All @@ -26,8 +26,6 @@ IStringLocalizer<ValidateReCaptchaTask> localizer
S = localizer;
}

public override string Name => nameof(ValidateReCaptchaTask);

public override LocalizedString DisplayText => S["Validate ReCaptcha Task"];

public override LocalizedString Category => S["Validation"];
Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Sms/Activities/SmsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace OrchardCore.Sms.Activities;

public class SmsTask : TaskActivity
public class SmsTask : TaskActivity<SmsTask>
{
private readonly ISmsProvider _smsProvider;
private readonly IWorkflowExpressionEvaluator _expressionEvaluator;
Expand All @@ -29,8 +29,8 @@ IStringLocalizer<SmsTask> stringLocalizer
S = stringLocalizer;
}

public override string Name => nameof(SmsTask);
public override LocalizedString DisplayText => S["SMS Task"];

public override LocalizedString Category => S["Messaging"];

public WorkflowExpression<string> PhoneNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace OrchardCore.Twitter.Workflows.Activities
{
public class UpdateTwitterStatusTask : TaskActivity
public class UpdateTwitterStatusTask : TaskActivity<UpdateTwitterStatusTask>
{
private readonly TwitterClient _twitterClient;
private readonly IWorkflowExpressionEvaluator _expressionEvaluator;
Expand All @@ -26,9 +26,6 @@ IStringLocalizer<UpdateTwitterStatusTask> localizer
S = localizer;
}

// The technical name of the activity. Activities on a workflow definition reference this name.
public override string Name => nameof(UpdateTwitterStatusTask);

public override LocalizedString DisplayText => S["Update Twitter Status Task"];

// The category to which this activity belongs. The activity picker groups activities by this category.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@

namespace OrchardCore.Users.Workflows.Activities
{
public class AssignUserRoleTask : TaskActivity
public class AssignUserRoleTask : TaskActivity<AssignUserRoleTask>
{
private readonly UserManager<IUser> _userManager;
private readonly IUserService _userService;
private readonly IWorkflowExpressionEvaluator _expressionEvaluator;
protected readonly IStringLocalizer S;

public AssignUserRoleTask(UserManager<IUser> userManager, IUserService userService, IWorkflowExpressionEvaluator expressionvaluator, IStringLocalizer<AssignUserRoleTask> localizer)
public AssignUserRoleTask(
UserManager<IUser> userManager,
IUserService userService,
IWorkflowExpressionEvaluator expressionEvaluator,
IStringLocalizer<AssignUserRoleTask> localizer)
{
_userManager = userManager;
_userService = userService;
_expressionEvaluator = expressionvaluator;
_expressionEvaluator = expressionEvaluator;
S = localizer;
}

public override string Name => nameof(AssignUserRoleTask);

public override LocalizedString DisplayText => S["Assign User Role Task"];

public override LocalizedString Category => S["User"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace OrchardCore.Users.Workflows.Activities
{
public class RegisterUserTask : TaskActivity
public class RegisterUserTask : TaskActivity<RegisterUserTask>
{
private readonly IUserService _userService;
private readonly UserManager<IUser> _userManager;
Expand Down Expand Up @@ -49,9 +49,6 @@ public RegisterUserTask(
_htmlEncoder = htmlEncoder;
}

// The technical name of the activity. Activities on a workflow definition reference this name.
public override string Name => nameof(RegisterUserTask);

public override LocalizedString DisplayText => S["Register User Task"];

// The category to which this activity belongs. The activity picker groups activities by this category.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace OrchardCore.Users.Workflows.Activities
{
public class ValidateUserTask : TaskActivity
public class ValidateUserTask : TaskActivity<ValidateUserTask>
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly string _roleClaimType;
Expand All @@ -23,8 +23,6 @@ public ValidateUserTask(IHttpContextAccessor httpContextAccessor, IOptions<Ident
S = localizer;
}

public override string Name => nameof(ValidateUserTask);

public override LocalizedString Category => S["User"];

public bool SetUserName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OrchardCore.Workflows.Activities
{
public class CommitTransactionTask : TaskActivity
public class CommitTransactionTask : TaskActivity<CommitTransactionTask>
{
private readonly ISession _session;
private readonly IUpdateModelAccessor _updateModelAccessor;
Expand All @@ -24,8 +24,6 @@ public CommitTransactionTask(
S = localizer;
}

public override string Name => nameof(CommitTransactionTask);

public override LocalizedString DisplayText => S["Commit Transaction Task"];

public override LocalizedString Category => S["Session"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OrchardCore.Workflows.Activities
{
public class CorrelateTask : TaskActivity
public class CorrelateTask : TaskActivity<CorrelateTask>
{
private readonly IWorkflowScriptEvaluator _scriptEvaluator;
protected readonly IStringLocalizer S;
Expand All @@ -18,8 +18,6 @@ public CorrelateTask(IWorkflowScriptEvaluator scriptEvaluator, IStringLocalizer<
S = localizer;
}

public override string Name => nameof(CorrelateTask);

public override LocalizedString DisplayText => S["Correlate Task"];

public override LocalizedString Category => S["Primitives"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OrchardCore.Workflows.Activities
{
public class ForEachTask : TaskActivity
public class ForEachTask : TaskActivity<ForEachTask>
{
private readonly IWorkflowScriptEvaluator _scriptEvaluator;
protected readonly IStringLocalizer S;
Expand All @@ -18,7 +18,6 @@ public ForEachTask(IWorkflowScriptEvaluator scriptEvaluator, IStringLocalizer<Fo
_scriptEvaluator = scriptEvaluator;
S = localizer;
}
public override string Name => nameof(ForEachTask);

public override LocalizedString DisplayText => S["For Each Task"];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OrchardCore.Workflows.Activities
{
public class ForLoopTask : TaskActivity
public class ForLoopTask : TaskActivity<ForLoopTask>
{
private readonly IWorkflowScriptEvaluator _scriptEvaluator;
protected readonly IStringLocalizer S;
Expand All @@ -19,8 +19,6 @@ public ForLoopTask(IWorkflowScriptEvaluator scriptEvaluator, IStringLocalizer<Fo
S = localizer;
}

public override string Name => nameof(ForLoopTask);

public override LocalizedString DisplayText => S["For Loop Task"];

public override LocalizedString Category => S["Control Flow"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OrchardCore.Workflows.Activities
{
public class ForkTask : TaskActivity
public class ForkTask : TaskActivity<ForkTask>
{
protected readonly IStringLocalizer S;

Expand All @@ -15,8 +15,6 @@ public ForkTask(IStringLocalizer<ForkTask> localizer)
S = localizer;
}

public override string Name => nameof(ForkTask);

public override LocalizedString DisplayText => S["Fork Task"];

public override LocalizedString Category => S["Control Flow"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OrchardCore.Workflows.Activities
{
public class IfElseTask : TaskActivity
public class IfElseTask : TaskActivity<IfElseTask>
{
private readonly IWorkflowScriptEvaluator _scriptEvaluator;
protected readonly IStringLocalizer S;
Expand All @@ -17,7 +17,6 @@ public IfElseTask(IWorkflowScriptEvaluator scriptEvaluator, IStringLocalizer<IfE
_scriptEvaluator = scriptEvaluator;
S = localizer;
}
public override string Name => nameof(IfElseTask);

public override LocalizedString DisplayText => S["If Else Task"];

Expand Down
Loading
Loading