From 5e1f4cf77894f1b83941eab2192b5248b7c786fe Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:39:16 +0300 Subject: [PATCH] refactor(editor): Type node view event bus (no-changelog) (#10396) --- packages/editor-ui/src/event-bus/node-view.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/editor-ui/src/event-bus/node-view.ts b/packages/editor-ui/src/event-bus/node-view.ts index 9023b161b7..9ed68a63e1 100644 --- a/packages/editor-ui/src/event-bus/node-view.ts +++ b/packages/editor-ui/src/event-bus/node-view.ts @@ -1,3 +1,28 @@ import { createEventBus } from 'n8n-design-system/utils'; +import type { IDataObject } from 'n8n-workflow'; -export const nodeViewEventBus = createEventBus(); +/** Callback function called after workflow has been save */ +export type OnSaveWorkflowFn = () => void; + +export interface NodeViewEventBusEvents { + /** Command to create a new workflow */ + newWorkflow: never; + + /** Command to open the chat */ + openChat: never; + + /** Command to save the current workflow */ + saveWorkflow: OnSaveWorkflowFn; + + /** Command to import a workflow from given data */ + importWorkflowData: IDataObject; + + /** Command to import a workflow from given URL */ + importWorkflowUrl: IDataObject; + + 'runWorkflowButton:mouseenter': never; + + 'runWorkflowButton:mouseleave': never; +} + +export const nodeViewEventBus = createEventBus();