fix(n8n Trigger Node): Merge with Workflow Trigger node (#11174)

This commit is contained in:
Michael Kret
2024-10-10 08:00:55 +03:00
committed by GitHub
parent d78ab2983a
commit 6ec6b5197a
3 changed files with 141 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ import type {
} from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow';
type eventType = 'Instance started' | undefined;
type eventType = 'Instance started' | 'Workflow activated' | 'Workflow updated' | undefined;
export class N8nTrigger implements INodeType {
description: INodeTypeDescription = {
@@ -30,26 +30,46 @@ export class N8nTrigger implements INodeType {
type: 'multiOptions',
required: true,
default: [],
description:
'Specifies under which conditions an execution should happen: <b>Instance started</b>: Triggers when this n8n instance is started or re-started',
description: `Specifies under which conditions an execution should happen:
<ul>
<li><b>Active Workflow Updated</b>: Triggers when this workflow is updated</li>
<li><b>Instance Started</b>: Triggers when this n8n instance is started or re-started</li>
<li><b>Workflow Activated</b>: Triggers when this workflow is activated</li>
</ul>`,
options: [
{
name: 'Active Workflow Updated',
value: 'update',
description: 'Triggers when this workflow is updated',
},
{
name: 'Instance Started',
value: 'init',
description: 'Triggers when this n8n instance is started or re-started',
},
{
name: 'Workflow Activated',
value: 'activate',
description: 'Triggers when this workflow is activated',
},
],
},
],
};
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
const events = this.getNodeParameter('events', []) as string[];
const events = (this.getNodeParameter('events') as string[]) || [];
const activationMode = this.getActivationMode();
if (events.includes(activationMode)) {
let event: eventType;
if (activationMode === 'activate') {
event = 'Workflow activated';
}
if (activationMode === 'update') {
event = 'Workflow updated';
}
if (activationMode === 'init') {
event = 'Instance started';
}