From 21b4b0be566d7d48c54a9d2403ff329ef1b67a87 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Thu, 14 Nov 2024 15:27:46 -0500 Subject: [PATCH] document `createNewWorkflow` method --- packages/editor-ui/src/stores/workflows.store.ts | 13 +++++++------ .../editor-ui/src/views/WorkflowOnboardingView.vue | 4 +--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/editor-ui/src/stores/workflows.store.ts b/packages/editor-ui/src/stores/workflows.store.ts index b66f0828f6295..929a77735055b 100644 --- a/packages/editor-ui/src/stores/workflows.store.ts +++ b/packages/editor-ui/src/stores/workflows.store.ts @@ -1436,18 +1436,19 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => { return response && unflattenExecutionData(response); } - async function createNewWorkflow( - sendData: IWorkflowDataCreate, - options: { inCurrentProject?: boolean } = {}, - ): Promise { - const { inCurrentProject = true } = options; + /** + * Creates a new workflow with the provided data. + * Ensures that the new workflow is not active upon creation. + * If the project ID is not provided in the data, it assigns the current project ID from the project store. + */ + async function createNewWorkflow(sendData: IWorkflowDataCreate): Promise { // make sure that the new ones are not active sendData.active = false; const rootStore = useRootStore(); const projectStore = useProjectsStore(); - if (inCurrentProject && projectStore.currentProjectId) { + if (!sendData.projectId && projectStore.currentProjectId) { (sendData as unknown as IDataObject).projectId = projectStore.currentProjectId; } diff --git a/packages/editor-ui/src/views/WorkflowOnboardingView.vue b/packages/editor-ui/src/views/WorkflowOnboardingView.vue index ebe262ff915d0..67d0a57ad84a4 100644 --- a/packages/editor-ui/src/views/WorkflowOnboardingView.vue +++ b/packages/editor-ui/src/views/WorkflowOnboardingView.vue @@ -77,9 +77,7 @@ const openSampleSubworkflow = async () => { workflow.projectId = projectId as string; } - const newWorkflow = await workflowsStore.createNewWorkflow(workflow, { - inCurrentProject: false, - }); + const newWorkflow = await workflowsStore.createNewWorkflow(workflow); const sampleSubworkflowChannel = new BroadcastChannel('new-sample-sub-workflow-created');