From 643d7cf76dd0c134c8ea96a5952ce939d067c1fc Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Fri, 17 Jan 2025 12:18:38 +0200 Subject: [PATCH] fix: highlight active project when opening workflow in new canvas --- .../src/composables/useWorkflowHelpers.test.ts | 17 ++--------------- .../src/composables/useWorkflowHelpers.ts | 9 +++------ .../editor-ui/src/stores/workflows.store.ts | 5 +++++ packages/editor-ui/src/views/NodeView.v2.vue | 4 ++++ 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/packages/editor-ui/src/composables/useWorkflowHelpers.test.ts b/packages/editor-ui/src/composables/useWorkflowHelpers.test.ts index ac7d5addabbad..149a667e5e222 100644 --- a/packages/editor-ui/src/composables/useWorkflowHelpers.test.ts +++ b/packages/editor-ui/src/composables/useWorkflowHelpers.test.ts @@ -290,14 +290,9 @@ describe('useWorkflowHelpers', () => { tags: [], }); const addWorkflowSpy = vi.spyOn(workflowsStore, 'addWorkflow'); - const setActiveSpy = vi.spyOn(workflowsStore, 'setActive'); + const setWorkflowSpy = vi.spyOn(workflowsStore, 'setWorkflow'); const setWorkflowIdSpy = vi.spyOn(workflowsStore, 'setWorkflowId'); const setWorkflowNameSpy = vi.spyOn(workflowsStore, 'setWorkflowName'); - const setWorkflowSettingsSpy = vi.spyOn(workflowsStore, 'setWorkflowSettings'); - const setWorkflowPinDataSpy = vi.spyOn(workflowsStore, 'setWorkflowPinData'); - const setWorkflowVersionIdSpy = vi.spyOn(workflowsStore, 'setWorkflowVersionId'); - const setWorkflowMetadataSpy = vi.spyOn(workflowsStore, 'setWorkflowMetadata'); - const setWorkflowScopesSpy = vi.spyOn(workflowsStore, 'setWorkflowScopes'); const setUsedCredentialsSpy = vi.spyOn(workflowsStore, 'setUsedCredentials'); const setWorkflowSharedWithSpy = vi.spyOn(workflowsEEStore, 'setWorkflowSharedWith'); const setWorkflowTagIdsSpy = vi.spyOn(workflowsStore, 'setWorkflowTagIds'); @@ -306,20 +301,12 @@ describe('useWorkflowHelpers', () => { initState(workflowData); expect(addWorkflowSpy).toHaveBeenCalledWith(workflowData); - expect(setActiveSpy).toHaveBeenCalledWith(true); + expect(setWorkflowSpy).toHaveBeenCalledWith(workflowData); expect(setWorkflowIdSpy).toHaveBeenCalledWith('1'); expect(setWorkflowNameSpy).toHaveBeenCalledWith({ newName: 'Test Workflow', setStateDirty: false, }); - expect(setWorkflowSettingsSpy).toHaveBeenCalledWith({ - executionOrder: 'v1', - timezone: 'DEFAULT', - }); - expect(setWorkflowPinDataSpy).toHaveBeenCalledWith({}); - expect(setWorkflowVersionIdSpy).toHaveBeenCalledWith('1'); - expect(setWorkflowMetadataSpy).toHaveBeenCalledWith({}); - expect(setWorkflowScopesSpy).toHaveBeenCalledWith(['workflow:create']); expect(setUsedCredentialsSpy).toHaveBeenCalledWith([]); expect(setWorkflowSharedWithSpy).toHaveBeenCalledWith({ workflowId: '1', diff --git a/packages/editor-ui/src/composables/useWorkflowHelpers.ts b/packages/editor-ui/src/composables/useWorkflowHelpers.ts index 493bb7f824f31..e48c221b2c329 100644 --- a/packages/editor-ui/src/composables/useWorkflowHelpers.ts +++ b/packages/editor-ui/src/composables/useWorkflowHelpers.ts @@ -1151,17 +1151,14 @@ export function useWorkflowHelpers(options: { router: ReturnType { workflow.value.scopes = scopes; } + function setWorkflowHomeProject(homeProject: IWorkflowDb['homeProject']): void { + workflow.value.homeProject = homeProject; + } + function setWorkflowMetadata(metadata: WorkflowMetadata | undefined): void { workflow.value.meta = metadata; } @@ -1711,6 +1715,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => { addWorkflowTagIds, removeWorkflowTagId, setWorkflowScopes, + setWorkflowHomeProject, setWorkflowMetadata, addToWorkflowMetadata, setWorkflow, diff --git a/packages/editor-ui/src/views/NodeView.v2.vue b/packages/editor-ui/src/views/NodeView.v2.vue index b09ca822a029f..9da9926fdc66b 100644 --- a/packages/editor-ui/src/views/NodeView.v2.vue +++ b/packages/editor-ui/src/views/NodeView.v2.vue @@ -371,6 +371,10 @@ async function initializeRoute(force = false) { if (route.name === VIEWS.EXECUTION_DEBUG) { await initializeDebugMode(); } + + await projectsStore.setProjectNavActiveIdByWorkflowHomeProject( + workflowsStore.workflow.homeProject, + ); } }