refactor(editor): Clean up unused code (#19546)

This commit is contained in:
Suguru Inoue
2025-09-15 14:56:26 +02:00
committed by GitHub
parent 3a38b32867
commit 5a63304014
8 changed files with 7 additions and 172 deletions

View File

@@ -769,24 +769,6 @@ export interface IUsedCredential {
sharedWithProjects?: ProjectSharingData[];
}
export interface WorkflowsState {
activeWorkflows: string[];
activeWorkflowExecution: ExecutionSummary | null;
currentWorkflowExecutions: ExecutionSummary[];
activeExecutionId: string | null;
executingNode: string[];
executionWaitingForWebhook: boolean;
nodeMetadata: NodeMetadataMap;
subWorkflowExecutionError: Error | null;
usedCredentials: Record<string, IUsedCredential>;
workflow: IWorkflowDb;
workflowExecutionData: IExecutionResponse | null;
workflowExecutionPairedItemMappings: { [itemId: string]: Set<string> };
workflowsById: IWorkflowsMap;
chatMessages: string[];
isInDebugMode?: boolean;
}
export interface NodeMetadataMap {
[nodeName: string]: INodeMetadata;
}
@@ -845,48 +827,6 @@ export interface TargetItem {
outputIndex: number;
}
export interface NDVState {
activeNodeName: string | null;
mainPanelDimensions: { [key: string]: { [key: string]: number } };
pushRef: string;
input: {
displayMode: IRunDataDisplayMode;
nodeName?: string;
run?: number;
branch?: number;
data: {
isEmpty: boolean;
};
};
output: {
branch?: number;
displayMode: IRunDataDisplayMode;
data: {
isEmpty: boolean;
};
editMode: {
enabled: boolean;
value: string;
};
};
focusedMappableInput: string;
focusedInputPath: string;
mappingTelemetry: { [key: string]: string | number | boolean };
hoveringItem: null | TargetItem;
expressionOutputItemIndex: number;
draggable: {
isDragging: boolean;
type: string;
data: string;
dimensions: DOMRect | null;
activeTarget: { id: string; stickyPosition: null | XYPosition } | null;
};
isMappingOnboarded: boolean;
isTableHoverOnboarded: boolean;
isAutocompleteOnboarded: boolean;
highlightDraggables: boolean;
}
export type TargetNodeParameterContext = {
nodeName: string;
parameterPath: string;

View File

@@ -1,42 +0,0 @@
import { computed } from 'vue';
import { describe, it, expect, vi } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { useActiveNode } from '@/composables/useActiveNode';
import { useNodeType } from '@/composables/useNodeType';
const node = computed(() => mock());
const nodeType = computed(() => mock());
vi.mock('@/stores/ndv.store', () => ({
useNDVStore: vi.fn(() => ({
activeNode: node,
})),
}));
vi.mock('@/composables/useNodeType', () => ({
useNodeType: vi.fn(() => ({
nodeType,
})),
}));
vi.mock('pinia', () => ({
storeToRefs: vi.fn((store) => store),
}));
describe('useActiveNode()', () => {
it('should call useNodeType()', () => {
useActiveNode();
expect(useNodeType).toHaveBeenCalledWith({
node,
});
});
it('should return activeNode and activeNodeType', () => {
const { activeNode, activeNodeType } = useActiveNode();
expect(activeNode).toBe(node);
expect(activeNodeType).toBe(nodeType);
});
});

View File

@@ -1,17 +0,0 @@
import { storeToRefs } from 'pinia';
import { useNDVStore } from '@/stores/ndv.store';
import { useNodeType } from '@/composables/useNodeType';
export function useActiveNode() {
const ndvStore = useNDVStore();
const { activeNode } = storeToRefs(ndvStore);
const { nodeType: activeNodeType } = useNodeType({
node: activeNode,
});
return {
activeNode,
activeNodeType,
};
}

View File

@@ -965,7 +965,6 @@ describe('useWorkflowHelpers', () => {
workflowsStore.pinnedWorkflowData = {
ParentNode: [{ json: { key: 'value' } }],
};
workflowsStore.shouldReplaceInputDataWithPinData = true;
const result = executeData({}, parentNodes, currentNode, inputName, runIndex);
@@ -982,7 +981,6 @@ describe('useWorkflowHelpers', () => {
const runIndex = 0;
workflowsStore.pinnedWorkflowData = undefined;
workflowsStore.shouldReplaceInputDataWithPinData = false;
workflowsStore.getWorkflowRunData = {
ParentNode: [
{
@@ -1023,7 +1021,6 @@ describe('useWorkflowHelpers', () => {
const parentRunIndex = 1;
workflowsStore.pinnedWorkflowData = undefined;
workflowsStore.shouldReplaceInputDataWithPinData = false;
workflowsStore.getWorkflowRunData = {
ParentNode: [
{ data: {} } as never,
@@ -1066,7 +1063,6 @@ describe('useWorkflowHelpers', () => {
const runIndex = 0;
workflowsStore.pinnedWorkflowData = undefined;
workflowsStore.shouldReplaceInputDataWithPinData = false;
workflowsStore.getWorkflowRunData = null;
const result = executeData({}, parentNodes, currentNode, inputName, runIndex);

View File

@@ -88,7 +88,6 @@ export function resolveParameter<T = IDataObject>(
opts.envVars,
opts.workflow.getNode(opts.nodeName),
opts.execution,
true,
opts.workflow.pinData,
{
inputNodeName: opts.inputNode?.name,
@@ -108,7 +107,6 @@ export function resolveParameter<T = IDataObject>(
useEnvironmentsStore().variablesAsObject,
useNDVStore().activeNode,
workflowsStore.workflowExecutionData,
workflowsStore.shouldReplaceInputDataWithPinData,
workflowsStore.pinnedWorkflowData,
opts,
);
@@ -122,7 +120,6 @@ function resolveParameterImpl<T = IDataObject>(
envVars: Record<string, string | boolean | number>,
ndvActiveNode: INodeUi | null,
executionData: IExecutionResponse | null,
shouldReplaceInputDataWithPinData: boolean,
pinData: IPinData | undefined,
opts: ResolveParameterOptions = {},
): T | null {
@@ -209,7 +206,6 @@ function resolveParameterImpl<T = IDataObject>(
contextNode!.name,
inputName,
runIndexParent,
shouldReplaceInputDataWithPinData,
pinData,
executionData?.data?.resultData.runData ?? null,
nodeConnection,
@@ -224,7 +220,6 @@ function resolveParameterImpl<T = IDataObject>(
contextNode.name,
inputName,
0,
shouldReplaceInputDataWithPinData,
pinData,
executionData?.data?.resultData.runData ?? null,
);
@@ -274,7 +269,6 @@ function resolveParameterImpl<T = IDataObject>(
contextNode!.name,
inputName,
runIndexCurrent,
shouldReplaceInputDataWithPinData,
pinData,
executionData?.data?.resultData.runData ?? null,
runIndexParent,
@@ -288,7 +282,6 @@ function resolveParameterImpl<T = IDataObject>(
contextNode!.name,
inputName,
runIndexParent,
shouldReplaceInputDataWithPinData,
pinData,
executionData?.data?.resultData.runData ?? null,
);
@@ -383,7 +376,6 @@ function connectionInputData(
currentNode: string,
inputName: string,
runIndex: number,
shouldReplaceInputDataWithPinData: boolean,
pinData: IPinData | undefined,
workflowRunData: IRunData | null,
nodeConnection: INodeConnection = { sourceIndex: 0, destinationIndex: 0 },
@@ -395,7 +387,6 @@ function connectionInputData(
currentNode,
inputName,
runIndex,
shouldReplaceInputDataWithPinData,
pinData,
workflowRunData,
);
@@ -442,7 +433,6 @@ export function executeData(
currentNode,
inputName,
runIndex,
workflowsStore.shouldReplaceInputDataWithPinData,
workflowsStore.pinnedWorkflowData,
workflowsStore.getWorkflowRunData,
parentRunIndex,
@@ -456,7 +446,6 @@ function executeDataImpl(
currentNode: string,
inputName: string,
runIndex: number,
shouldReplaceInputDataWithPinData: boolean,
pinData: IPinData | undefined,
workflowRunData: IRunData | null,
parentRunIndex?: number,
@@ -473,17 +462,15 @@ function executeDataImpl(
// Find the parent node which has data
for (const parentNodeName of parentNodes) {
if (shouldReplaceInputDataWithPinData) {
const parentPinData = pinData?.[parentNodeName];
const parentPinData = pinData?.[parentNodeName];
// populate `executeData` from `pinData`
// populate `executeData` from `pinData`
if (parentPinData) {
executeData.data = { main: [parentPinData] };
executeData.source = { main: [{ previousNode: parentNodeName }] };
if (parentPinData) {
executeData.data = { main: [parentPinData] };
executeData.source = { main: [{ previousNode: parentNodeName }] };
return executeData;
}
return executeData;
}
// populate `executeData` from `runData`

View File

@@ -5,7 +5,6 @@ import type {
IRunDataDisplayMode,
MainPanelDimensions,
MainPanelType,
NDVState,
NodePanelType,
OutputPanel,
TargetItem,
@@ -312,7 +311,7 @@ export const useNDVStore = defineStore(STORES.NDV, () => {
};
};
const setDraggableTarget = (target: NDVState['draggable']['activeTarget']): void => {
const setDraggableTarget = (target: Draggable['activeTarget']): void => {
draggable.value.activeTarget = target;
};

View File

@@ -14,7 +14,6 @@ import type { IExecutionResponse, INodeUi, IWorkflowDb, IWorkflowSettings } from
import { deepCopy, SEND_AND_WAIT_OPERATION } from 'n8n-workflow';
import type {
IPinData,
ExecutionSummary,
IConnection,
INodeExecutionData,
INode,
@@ -317,26 +316,6 @@ describe('useWorkflowsStore', () => {
});
});
describe('shouldReplaceInputDataWithPinData', () => {
it('should return true when no active workflow execution', () => {
workflowsStore.activeWorkflowExecution = null;
expect(workflowsStore.shouldReplaceInputDataWithPinData).toBe(true);
});
it('should return true when active workflow execution mode is manual', () => {
workflowsStore.activeWorkflowExecution = { mode: 'manual' } as unknown as ExecutionSummary;
expect(workflowsStore.shouldReplaceInputDataWithPinData).toBe(true);
});
it('should return false when active workflow execution mode is not manual', () => {
workflowsStore.activeWorkflowExecution = { mode: 'automatic' } as unknown as ExecutionSummary;
expect(workflowsStore.shouldReplaceInputDataWithPinData).toBe(false);
});
});
describe('getWorkflowResultDataByNodeName()', () => {
it('should return null when no workflow run data is present', () => {
workflowsStore.workflowExecutionData = null;

View File

@@ -149,7 +149,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
const usedCredentials = ref<Record<string, IUsedCredential>>({});
const activeWorkflows = ref<string[]>([]);
const activeWorkflowExecution = ref<ExecutionSummary | null>(null);
const currentWorkflowExecutions = ref<ExecutionSummary[]>([]);
const workflowExecutionData = ref<IExecutionResponse | null>(null);
const workflowExecutionStartedData =
@@ -280,10 +279,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
const pinnedWorkflowData = computed(() => workflow.value.pinData);
const shouldReplaceInputDataWithPinData = computed(() => {
return !activeWorkflowExecution.value || activeWorkflowExecution.value.mode === 'manual';
});
const executedNode = computed(() => workflowExecutionData.value?.executedNode);
const getAllLoadedFinishedExecutions = computed(() => {
@@ -1905,7 +1900,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
workflow,
usedCredentials,
activeWorkflows,
activeWorkflowExecution,
currentWorkflowExecutions,
workflowExecutionData,
workflowExecutionPairedItemMappings,
@@ -1945,7 +1939,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
nodesByName,
nodesIssuesExist,
pinnedWorkflowData,
shouldReplaceInputDataWithPinData,
executedNode,
getAllLoadedFinishedExecutions,
getWorkflowExecution,