mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(editor): Reset dirty state on workflow activation only if its current workflow (#16997)
This commit is contained in:
committed by
GitHub
parent
6ef38411d8
commit
bb9679c4fa
@@ -477,6 +477,7 @@ describe('useWorkflowsStore', () => {
|
||||
|
||||
describe('setWorkflowActive()', () => {
|
||||
it('should set workflow as active when it is not already active', () => {
|
||||
uiStore.stateIsDirty = true;
|
||||
workflowsStore.workflowsById = { '1': { active: false } as IWorkflowDb };
|
||||
workflowsStore.workflow.id = '1';
|
||||
|
||||
@@ -485,6 +486,7 @@ describe('useWorkflowsStore', () => {
|
||||
expect(workflowsStore.activeWorkflows).toContain('1');
|
||||
expect(workflowsStore.workflowsById['1'].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', () => {
|
||||
@@ -498,6 +500,15 @@ describe('useWorkflowsStore', () => {
|
||||
expect(workflowsStore.workflowsById['1'].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()', () => {
|
||||
|
||||
@@ -829,7 +829,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
}
|
||||
|
||||
function setWorkflowActive(targetWorkflowId: string) {
|
||||
uiStore.stateIsDirty = false;
|
||||
const index = activeWorkflows.value.indexOf(targetWorkflowId);
|
||||
if (index === -1) {
|
||||
activeWorkflows.value.push(targetWorkflowId);
|
||||
@@ -838,6 +837,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
workflowsById.value[targetWorkflowId].active = true;
|
||||
}
|
||||
if (targetWorkflowId === workflow.value.id) {
|
||||
uiStore.stateIsDirty = false;
|
||||
setActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user