Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Highlight active project when opening workflow in new canvas #12664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions packages/editor-ui/src/composables/useWorkflowHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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',
Expand Down
9 changes: 3 additions & 6 deletions packages/editor-ui/src/composables/useWorkflowHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1151,17 +1151,14 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute

function initState(workflowData: IWorkflowDb) {
workflowsStore.addWorkflow(workflowData);
workflowsStore.setActive(workflowData.active || false);

workflowsStore.setWorkflow(workflowData);

workflowsStore.setWorkflowId(workflowData.id);
workflowsStore.setWorkflowName({
newName: workflowData.name,
setStateDirty: uiStore.stateIsDirty,
});
workflowsStore.setWorkflowSettings(workflowData.settings ?? {});
workflowsStore.setWorkflowPinData(workflowData.pinData ?? {});
workflowsStore.setWorkflowVersionId(workflowData.versionId);
workflowsStore.setWorkflowMetadata(workflowData.meta);
workflowsStore.setWorkflowScopes(workflowData.scopes);

if (workflowData.usedCredentials) {
workflowsStore.setUsedCredentials(workflowData.usedCredentials);
Expand Down
5 changes: 5 additions & 0 deletions packages/editor-ui/src/stores/workflows.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
workflow.value.scopes = scopes;
}

function setWorkflowHomeProject(homeProject: IWorkflowDb['homeProject']): void {
workflow.value.homeProject = homeProject;
}

function setWorkflowMetadata(metadata: WorkflowMetadata | undefined): void {
workflow.value.meta = metadata;
}
Expand Down Expand Up @@ -1711,6 +1715,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
addWorkflowTagIds,
removeWorkflowTagId,
setWorkflowScopes,
setWorkflowHomeProject,
setWorkflowMetadata,
addToWorkflowMetadata,
setWorkflow,
Expand Down
4 changes: 4 additions & 0 deletions packages/editor-ui/src/views/NodeView.v2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ async function initializeRoute(force = false) {
if (route.name === VIEWS.EXECUTION_DEBUG) {
await initializeDebugMode();
}

await projectsStore.setProjectNavActiveIdByWorkflowHomeProject(
workflowsStore.workflow.homeProject,
);
}
}

Expand Down
Loading