mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
adc2515dee
* N8N-2586 Improve Waiting Webhook call state in WF Canvas * N8N-2586 Added watcher for showing Webhook's Node Tooltip on execution * N8N-2586 Show helping tooltip for trigger node if wokrflow is running, it is a trigger node, if it is only one trigger node in WF * N8N-2586 Rework/Move logic to computed property, Created getter for ActveTriggerNodesInWokrflow, Add style to trigger node's tooltip, remove comments * N8N-2586 Added EventTriggerDescription prop in INodeTypeDescription Interface, Updated Logic for TriggerNode Tooltip based on the new prop * N8N-2586 Add new use cases/watcher to show Trigger Nodes Tooltip / If has issues, if paused, if wokrlfow is running, Refactor Getter * N8N-2586 Added z-index to tooltip, Added new Scenario for Tooltip if it is Draged&Droped on the WF * N8N-2586 Refactor computed property for draged nodes * N8N-2586 Fixed Conflicts * N8N-2586 Fixed Tooltip * N8N-2586 Dont show tooltip on core trigger nodes that execute automatically * N8N-2586 Fixed Webhook tooltip when adding/deleting canvas during WF execution * N8N-2586 Updated Logic, Simplify the code * N8N-2586 Simplify Code * N8N-2586 Added check for nodetype * update dragging to use local state * N8N-2586 Added eventTriggerDescription to Interval Node * add comment, use new getter * update to always check Co-authored-by: Mutasem <mutdmour@gmail.com>
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { ITriggerFunctions } from 'n8n-core';
|
|
import {
|
|
INodeType,
|
|
INodeTypeDescription,
|
|
ITriggerResponse,
|
|
} from 'n8n-workflow';
|
|
|
|
type eventType = 'Instance started' | undefined;
|
|
|
|
export class N8nTrigger implements INodeType {
|
|
description: INodeTypeDescription = {
|
|
displayName: 'n8n Trigger',
|
|
name: 'n8nTrigger',
|
|
icon: 'file:n8nTrigger.svg',
|
|
group: ['trigger'],
|
|
version: 1,
|
|
description: 'Handle events from your n8n instance',
|
|
eventTriggerDescription: '',
|
|
defaults: {
|
|
name: 'n8n Trigger',
|
|
color: '#ff6d5a',
|
|
},
|
|
inputs: [],
|
|
outputs: ['main'],
|
|
properties: [
|
|
{
|
|
displayName: 'Events',
|
|
name: 'events',
|
|
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',
|
|
options: [
|
|
{
|
|
name: 'Instance started',
|
|
value: 'init',
|
|
description: 'Triggers when this n8n instance is started or re-started',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
|
|
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
|
|
const events = this.getNodeParameter('events', []) as string[];
|
|
|
|
const activationMode = this.getActivationMode();
|
|
|
|
if (events.includes(activationMode)) {
|
|
let event: eventType;
|
|
if (activationMode === 'init') {
|
|
event = 'Instance started';
|
|
}
|
|
this.emit([
|
|
this.helpers.returnJsonArray([
|
|
{ event, timestamp: (new Date()).toISOString(), workflow_id: this.getWorkflow().id },
|
|
]),
|
|
]);
|
|
}
|
|
|
|
const self = this;
|
|
async function manualTriggerFunction() {
|
|
self.emit([self.helpers.returnJsonArray([{ event: 'Manual execution', timestamp: (new Date()).toISOString(), workflow_id: self.getWorkflow().id }])]);
|
|
}
|
|
|
|
return {
|
|
manualTriggerFunction,
|
|
};
|
|
}
|
|
}
|