refactor(editor): Migrate workflow name consumers to workflowDocumentStore (#28682)

This commit is contained in:
Alex Grozav 2026-04-20 15:17:08 +03:00 committed by GitHub
parent a3292b738a
commit db1eb91940
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 8 deletions

View file

@ -63,9 +63,9 @@ export default defineConfig(
},
{
selector:
"MemberExpression[property.name='nodes'][object.property.name='workflow'][object.object.name='workflowsStore']",
"MemberExpression[property.name=/^(name|nodes|connections|active|isArchived|settings|tags|pinData|meta|versionId|activeVersionId|createdAt|updatedAt|parentFolder|scopes|usedCredentials|homeProject|description|versionData)$/][object.property.name='workflow'][object.object.name='workflowsStore']",
message:
'Use workflowDocumentStore node accessors instead of workflowsStore.workflow.nodes',
'Use the equivalent workflowDocumentStore accessor instead of workflowsStore.workflow.<property>',
},
{
selector:

View file

@ -2,6 +2,10 @@ import { createTestingPinia } from '@pinia/testing';
import { setActivePinia } from 'pinia';
import { executionStarted } from './executionStarted';
import { useWorkflowsStore } from '@/app/stores/workflows.store';
import {
createWorkflowDocumentId,
useWorkflowDocumentStore,
} from '@/app/stores/workflowDocument.store';
import { mockedStore } from '@/__tests__/utils';
import type { ExecutionStarted } from '@n8n/api-types/push/execution';
import type { WorkflowState } from '@/app/composables/useWorkflowState';
@ -20,7 +24,7 @@ describe('executionStarted', () => {
}
beforeEach(() => {
const pinia = createTestingPinia({ stubActions: true });
const pinia = createTestingPinia({ stubActions: false });
setActivePinia(pinia);
workflowsStore = mockedStore(useWorkflowsStore);
@ -43,7 +47,8 @@ describe('executionStarted', () => {
workflowsStore.activeExecutionId = null;
workflowsStore.workflowExecutionData = null;
workflowsStore.workflow.id = 'wf-123';
workflowsStore.workflow.name = 'My Workflow';
const workflowDocumentStore = useWorkflowDocumentStore(createWorkflowDocumentId('wf-123'));
workflowDocumentStore.setName('My Workflow');
await executionStarted(makeEvent('exec-1'), mockOptions);

View file

@ -1,5 +1,9 @@
import type { ExecutionStarted } from '@n8n/api-types/push/execution';
import { useWorkflowsStore } from '@/app/stores/workflows.store';
import {
createWorkflowDocumentId,
useWorkflowDocumentStore,
} from '@/app/stores/workflowDocument.store';
import { parse } from 'flatted';
import { createRunExecutionData } from 'n8n-workflow';
import type { WorkflowState } from '@/app/composables/useWorkflowState';
@ -35,6 +39,9 @@ export async function executionStarted(
// node status (e.g. DemoLayout iframe receiving push events for a new execution).
if (!workflowsStore.workflowExecutionData?.data || needsInit) {
const wf = workflowsStore.workflow;
const workflowDocumentStore = workflowsStore.workflowId
? useWorkflowDocumentStore(createWorkflowDocumentId(workflowsStore.workflowId))
: undefined;
options.workflowState.setWorkflowExecutionData({
id: data.executionId,
finished: false,
@ -44,7 +51,7 @@ export async function executionStarted(
startedAt: new Date(),
workflowData: {
id: wf.id,
name: wf.name,
name: workflowDocumentStore?.name ?? '',
active: wf.active,
isArchived: wf.isArchived,
nodes: wf.nodes,

View file

@ -125,7 +125,6 @@ describe('useWorkflowsStore', () => {
});
it('should initialize with default state', () => {
expect(workflowsStore.workflow.name).toBe('');
expect(workflowsStore.workflow.id).toBe('');
});

View file

@ -20,7 +20,6 @@ import { defaultSettings } from '@/__tests__/defaults';
import { createTestNode } from '@/__tests__/mocks';
import merge from 'lodash/merge';
import { DEFAULT_POSTHOG_SETTINGS } from '@/app/stores/posthog.store.test';
import { DEFAULT_NEW_WORKFLOW_NAME } from '@/app/constants';
import { nextTick, reactive } from 'vue';
import * as chatAPI from '@/features/ai/assistant/assistant.api';
import * as telemetryModule from '@/app/composables/useTelemetry';
@ -174,7 +173,6 @@ describe('AI Builder store', () => {
credentialsStore = mockedStore(useCredentialsStore);
workflowsStore.workflowId = 'test-workflow-id';
workflowsStore.workflow.name = DEFAULT_NEW_WORKFLOW_NAME;
workflowsStore.workflow.nodes = [];
workflowsStore.workflow.connections = {};
workflowsStore.nodesByName = {};