Split actions into email + webhook

This commit is contained in:
shamoon
2024-11-02 08:46:41 -07:00
parent 93a58da426
commit 76672b0760
9 changed files with 405 additions and 294 deletions

View File

@@ -322,15 +322,23 @@
</div>
</div>
}
@case (WorkflowActionType.Notification) {
@case (WorkflowActionType.Email) {
<div class="row">
<div class="col">
<pngx-input-text i18n-title title="Notification subject" formControlName="notification_subject" [error]="error?.actions?.[i]?.notification_subject"></pngx-input-text>
<pngx-input-textarea i18n-title title="Notification body" formControlName="notification_body" [error]="error?.actions?.[i]?.notification_body"></pngx-input-textarea>
<pngx-input-text i18n-title title="Notification emails" formControlName="notification_destination_emails" [error]="error?.actions?.[i]?.notification_destination_emails"></pngx-input-text>
<pngx-input-text i18n-title title="Notification url" formControlName="notification_destination_url" [error]="error?.actions?.[i]?.notification_destination_url"></pngx-input-text>
<pngx-input-text i18n-title title="Notification headers" formControlName="notification_destination_url_headers" [error]="error?.actions?.[i]?.notification_destination_url_headers"></pngx-input-text>
<pngx-input-switch i18n-title title="Notification include document" formControlName="notification_include_document"></pngx-input-switch>
<pngx-input-text i18n-title title="Email subject" formControlName="email_subject" [error]="error?.actions?.[i]?.email_subject"></pngx-input-text>
<pngx-input-textarea i18n-title title="Email body" formControlName="email_body" [error]="error?.actions?.[i]?.email_body"></pngx-input-textarea>
<pngx-input-text i18n-title title="Email recipients" formControlName="email_to" [error]="error?.actions?.[i]?.email_to"></pngx-input-text>
<pngx-input-switch i18n-title title="Attach document" formControlName="email_include_document"></pngx-input-switch>
</div>
</div>
}
@case (WorkflowActionType.Webhook) {
<div class="row">
<div class="col">
<pngx-input-text i18n-title title="Webhook url" formControlName="webhook_url" [error]="error?.actions?.[i]?.webhook_url"></pngx-input-text>
<pngx-input-text i18n-title title="Webhook params" formControlName="webhook_params" [error]="error?.actions?.[i]?.webhook_params"></pngx-input-text>
<pngx-input-text i18n-title title="Webhook headers" formControlName="webhook_headers" [error]="error?.actions?.[i]?.webhook_headers"></pngx-input-text>
<pngx-input-switch i18n-title title="Include document" formControlName="webhook_include_document"></pngx-input-switch>
</div>
</div>
}

View File

@@ -97,8 +97,12 @@ export const WORKFLOW_ACTION_OPTIONS = [
name: $localize`Removal`,
},
{
id: WorkflowActionType.Notification,
name: $localize`Notification`,
id: WorkflowActionType.Email,
name: $localize`Email`,
},
{
id: WorkflowActionType.Webhook,
name: $localize`Webhook`,
},
]
@@ -406,19 +410,15 @@ export class WorkflowEditDialogComponent
remove_all_custom_fields: new FormControl(
action.remove_all_custom_fields
),
notification_subject: new FormControl(action.notification_subject),
notification_body: new FormControl(action.notification_body),
notification_destination_emails: new FormControl(
action.notification_destination_emails
),
notification_destination_url: new FormControl(
action.notification_destination_url
),
notification_destination_url_headers: new FormControl(
action.notification_destination_url_headers
),
notification_include_document: new FormControl(
action.notification_include_document
email_subject: new FormControl(action.email_subject),
email_body: new FormControl(action.email_body),
email_to: new FormControl(action.email_to),
email_include_document: new FormControl(action.email_include_document),
webhook_url: new FormControl(action.webhook_url),
webhook_params: new FormControl(action.webhook_params),
webhook_headers: new FormControl(action.webhook_headers),
webhook_include_document: new FormControl(
action.webhook_include_document
),
}),
{ emitEvent }
@@ -521,12 +521,14 @@ export class WorkflowEditDialogComponent
remove_all_permissions: false,
remove_custom_fields: [],
remove_all_custom_fields: false,
notification_subject: null,
notification_body: null,
notification_destination_emails: null,
notification_destination_url: null,
notification_destination_url_headers: null,
notification_include_document: null,
email_subject: null,
email_body: null,
email_to: null,
email_include_document: false,
webhook_url: null,
webhook_params: null,
webhook_headers: null,
webhook_include_document: false,
}
this.object.actions.push(action)
this.createActionField(action)

View File

@@ -3,7 +3,8 @@ import { ObjectWithId } from './object-with-id'
export enum WorkflowActionType {
Assignment = 1,
Removal = 2,
Notification = 3,
Email = 3,
Webhook = 4,
}
export interface WorkflowAction extends ObjectWithId {
type: WorkflowActionType
@@ -64,15 +65,19 @@ export interface WorkflowAction extends ObjectWithId {
remove_all_custom_fields?: boolean
notification_subject?: string
email_subject?: string
notification_body?: string
email_body?: string
notification_destination_emails?: string
email_to?: string
notification_destination_url?: string
email_include_document?: boolean
notification_destination_url_headers?: string
webhook_url?: string
notification_include_document?: boolean
webhook_params?: string
webhook_headers?: string
webhook_include_document?: boolean
}