fix(editor): Reset dirty state on workflow activation only if its current workflow (#16997)

This commit is contained in:
Guillaume Jacquart
2025-07-04 17:24:21 +02:00
committed by GitHub
parent 6ef38411d8
commit bb9679c4fa
2 changed files with 12 additions and 1 deletions

View File

@@ -477,6 +477,7 @@ describe('useWorkflowsStore', () => {
describe('setWorkflowActive()', () => { describe('setWorkflowActive()', () => {
it('should set workflow as active when it is not already active', () => { it('should set workflow as active when it is not already active', () => {
uiStore.stateIsDirty = true;
workflowsStore.workflowsById = { '1': { active: false } as IWorkflowDb }; workflowsStore.workflowsById = { '1': { active: false } as IWorkflowDb };
workflowsStore.workflow.id = '1'; workflowsStore.workflow.id = '1';
@@ -485,6 +486,7 @@ describe('useWorkflowsStore', () => {
expect(workflowsStore.activeWorkflows).toContain('1'); expect(workflowsStore.activeWorkflows).toContain('1');
expect(workflowsStore.workflowsById['1'].active).toBe(true); expect(workflowsStore.workflowsById['1'].active).toBe(true);
expect(workflowsStore.workflow.active).toBe(true); expect(workflowsStore.workflow.active).toBe(true);
expect(uiStore.stateIsDirty).toBe(false);
}); });
it('should not modify active workflows when workflow is already active', () => { it('should not modify active workflows when workflow is already active', () => {
@@ -498,6 +500,15 @@ describe('useWorkflowsStore', () => {
expect(workflowsStore.workflowsById['1'].active).toBe(true); expect(workflowsStore.workflowsById['1'].active).toBe(true);
expect(workflowsStore.workflow.active).toBe(true); expect(workflowsStore.workflow.active).toBe(true);
}); });
it('should not set current workflow as active when it is not the target', () => {
uiStore.stateIsDirty = true;
workflowsStore.workflow.id = '1';
workflowsStore.workflowsById = { '1': { active: false } as IWorkflowDb };
workflowsStore.setWorkflowActive('2');
expect(workflowsStore.workflowsById['1'].active).toBe(false);
expect(uiStore.stateIsDirty).toBe(true);
});
}); });
describe('setWorkflowInactive()', () => { describe('setWorkflowInactive()', () => {

View File

@@ -829,7 +829,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
} }
function setWorkflowActive(targetWorkflowId: string) { function setWorkflowActive(targetWorkflowId: string) {
uiStore.stateIsDirty = false;
const index = activeWorkflows.value.indexOf(targetWorkflowId); const index = activeWorkflows.value.indexOf(targetWorkflowId);
if (index === -1) { if (index === -1) {
activeWorkflows.value.push(targetWorkflowId); activeWorkflows.value.push(targetWorkflowId);
@@ -838,6 +837,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
workflowsById.value[targetWorkflowId].active = true; workflowsById.value[targetWorkflowId].active = true;
} }
if (targetWorkflowId === workflow.value.id) { if (targetWorkflowId === workflow.value.id) {
uiStore.stateIsDirty = false;
setActive(true); setActive(true);
} }
} }