mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
726a99bf69
* ✨ n8n start trigger node * first declaration of WorkflowActivationMode * implement first WorkflowActivationMode: 'init', 'create', 'update', 'activate' * fix Server missing id * add activation infos to triggers * remove WorkflowActivationMode from webhook execution function * add some missing activation and add manual activation * clean up and fix some code * fix UnhandledPromiseRejectionWarning: Error: Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function! * fix spaces * use a better name for the node * fix ident in package.json * Contributions to lublak's PR #1287 * Fixed linting issues and change the way parameters are displayed * ⚡ Fix name and minor improvements Co-authored-by: lublak <lublak.de@gmail.com> Co-authored-by: lublak <44057030+lublak@users.noreply.github.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { ITriggerFunctions } from 'n8n-core';
|
|
import {
|
|
INodeType,
|
|
INodeTypeDescription,
|
|
ITriggerResponse,
|
|
} from 'n8n-workflow';
|
|
|
|
export class ActivationTrigger implements INodeType {
|
|
description: INodeTypeDescription = {
|
|
displayName: 'Activation Trigger',
|
|
name: 'activationTrigger',
|
|
icon: 'fa:play-circle',
|
|
group: ['trigger'],
|
|
version: 1,
|
|
description: 'Executes whenever the workflow becomes active.',
|
|
defaults: {
|
|
name: 'Activation Trigger',
|
|
color: '#00e000',
|
|
},
|
|
inputs: [],
|
|
outputs: ['main'],
|
|
properties: [
|
|
{
|
|
displayName: 'Events',
|
|
name: 'events',
|
|
type: 'multiOptions',
|
|
required: true,
|
|
default: [],
|
|
description: 'Specifies under which conditions an execution should happen:<br />' +
|
|
'- <b>Activation</b>: Workflow gets activated<br />' +
|
|
'- <b>Update</b>: Workflow gets saved while active<br>' +
|
|
'- <b>Start</b>: n8n starts or restarts',
|
|
options: [
|
|
{
|
|
name: 'Activation',
|
|
value: 'activate',
|
|
description: 'Run when workflow gets activated',
|
|
},
|
|
{
|
|
name: 'Start',
|
|
value: 'init',
|
|
description: 'Run when n8n starts or restarts',
|
|
},
|
|
{
|
|
name: 'Update',
|
|
value: 'update',
|
|
description: 'Run when workflow gets saved while it is active',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
|
|
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
|
|
const events = this.getNodeParameter('events', []) as string[];
|
|
|
|
const activationMode = this.getActivationMode();
|
|
|
|
if (events.includes(activationMode)) {
|
|
this.emit([this.helpers.returnJsonArray([{ activation: activationMode }])]);
|
|
}
|
|
|
|
const self = this;
|
|
async function manualTriggerFunction() {
|
|
self.emit([self.helpers.returnJsonArray([{ activation: 'manual' }])]);
|
|
}
|
|
|
|
return {
|
|
manualTriggerFunction,
|
|
};
|
|
}
|
|
}
|