Skip to content

Commit

Permalink
document createNewWorkflow method
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoE105 committed Nov 14, 2024
1 parent 00015e5 commit 21b4b0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 7 additions & 6 deletions packages/editor-ui/src/stores/workflows.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1436,18 +1436,19 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
return response && unflattenExecutionData(response);
}

async function createNewWorkflow(
sendData: IWorkflowDataCreate,
options: { inCurrentProject?: boolean } = {},
): Promise<IWorkflowDb> {
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<IWorkflowDb> {
// 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;
}

Expand Down
4 changes: 1 addition & 3 deletions packages/editor-ui/src/views/WorkflowOnboardingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 21b4b0b

Please sign in to comment.