mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
a2f628927d
* add panel * add workflow activation hints * support service trigger nodes * update polling state * support more views * update when trigger panel shows * update start/error nodes * add cron/interval info box * clean up start node * fix up webhook views * remove console log * add listening state * clean up loading state * update loading state * fix up animation * update views * add executions hint * update views * update accordian styling * address more issues * disable execute button if issues * disable if it has issues * add stop waiting button * can activate workflow when dsiabled * update el * fix has issues * add margin bttm * update views * close ndv * add shake * update copies * add error when polling node is missing one * update package lock * hide switch * hide binary data that's missing keys * hide main bar if ndv is open * remove waiting to execute * change accordion bg color * capitalize text * disable trigger panel in read only views * remove webhook title * update webhook desc * update component * update webhook executions note * update header * update webhook url * update exec help * bring back waiting to execute for non triggers * add transition fade * set shake * add helpful tooltip * add nonactive text * add inactive text * hide trigger panel by default * remove unused import * update pulse animation * handle empty values for options * update text * add flag for mock manual executions * add overrides * Add overrides * update check * update package lock; show button for others * hide more info * update other core nodes * update service name * remove panel from nodes * update panel * last tweaks * add telemetry event * add telemetry; address issues * address feedback * address feedback * address feedback * fix previous * fix previous * fix bug * fix bug with webhookbased * add extra break * update telemetry * update telemetry * add telemetry req * add info icon story; use icon component * clean css; en.json * clean en.json * rename key * add key * sort keys alpha * handle activation if active + add previous state to telemetry * stop activation if active * remove unnessary tracking * remove unused import * remove unused * remove unnessary flag * rewrite in ts * move pulse to design system * clean up * clean up * clean up * disable tslint check * disable tslint check
87 lines
2.3 KiB
TypeScript
87 lines
2.3 KiB
TypeScript
import { ITriggerFunctions } from 'n8n-core';
|
|
import {
|
|
INodeType,
|
|
INodeTypeDescription,
|
|
ITriggerResponse,
|
|
} from 'n8n-workflow';
|
|
|
|
type eventType = 'Workflow activated' | 'Workflow updated' | undefined;
|
|
type activationType = 'activate' | 'update';
|
|
|
|
export class WorkflowTrigger implements INodeType {
|
|
description: INodeTypeDescription = {
|
|
displayName: 'Workflow Trigger',
|
|
name: 'workflowTrigger',
|
|
icon: 'fa:network-wired',
|
|
group: ['trigger'],
|
|
version: 1,
|
|
description: 'Triggers based on various lifecycle events, like when a workflow is activated',
|
|
eventTriggerDescription: '',
|
|
mockManualExecution: true,
|
|
activationMessage: 'Your workflow will now trigger executions on the event you have defined.',
|
|
defaults: {
|
|
name: 'Workflow 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:
|
|
<ul>
|
|
<li><b>Active Workflow Updated</b>: Triggers when this workflow is updated</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: 'Workflow Activated',
|
|
value: 'activate',
|
|
description: 'Triggers when this workflow is activated',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
|
|
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
|
|
const events = this.getNodeParameter('events', []) as activationType[];
|
|
|
|
const activationMode = this.getActivationMode() as activationType;
|
|
|
|
if (events.includes(activationMode)) {
|
|
let event: eventType;
|
|
if (activationMode === 'activate') {
|
|
event = 'Workflow activated';
|
|
}
|
|
if (activationMode === 'update') {
|
|
event = 'Workflow updated';
|
|
}
|
|
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,
|
|
};
|
|
}
|
|
}
|