mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor(editor): Clean up unused code (#19546)
This commit is contained in:
@@ -769,24 +769,6 @@ export interface IUsedCredential {
|
|||||||
sharedWithProjects?: ProjectSharingData[];
|
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 {
|
export interface NodeMetadataMap {
|
||||||
[nodeName: string]: INodeMetadata;
|
[nodeName: string]: INodeMetadata;
|
||||||
}
|
}
|
||||||
@@ -845,48 +827,6 @@ export interface TargetItem {
|
|||||||
outputIndex: number;
|
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 = {
|
export type TargetNodeParameterContext = {
|
||||||
nodeName: string;
|
nodeName: string;
|
||||||
parameterPath: string;
|
parameterPath: string;
|
||||||
|
|||||||
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -965,7 +965,6 @@ describe('useWorkflowHelpers', () => {
|
|||||||
workflowsStore.pinnedWorkflowData = {
|
workflowsStore.pinnedWorkflowData = {
|
||||||
ParentNode: [{ json: { key: 'value' } }],
|
ParentNode: [{ json: { key: 'value' } }],
|
||||||
};
|
};
|
||||||
workflowsStore.shouldReplaceInputDataWithPinData = true;
|
|
||||||
|
|
||||||
const result = executeData({}, parentNodes, currentNode, inputName, runIndex);
|
const result = executeData({}, parentNodes, currentNode, inputName, runIndex);
|
||||||
|
|
||||||
@@ -982,7 +981,6 @@ describe('useWorkflowHelpers', () => {
|
|||||||
const runIndex = 0;
|
const runIndex = 0;
|
||||||
|
|
||||||
workflowsStore.pinnedWorkflowData = undefined;
|
workflowsStore.pinnedWorkflowData = undefined;
|
||||||
workflowsStore.shouldReplaceInputDataWithPinData = false;
|
|
||||||
workflowsStore.getWorkflowRunData = {
|
workflowsStore.getWorkflowRunData = {
|
||||||
ParentNode: [
|
ParentNode: [
|
||||||
{
|
{
|
||||||
@@ -1023,7 +1021,6 @@ describe('useWorkflowHelpers', () => {
|
|||||||
const parentRunIndex = 1;
|
const parentRunIndex = 1;
|
||||||
|
|
||||||
workflowsStore.pinnedWorkflowData = undefined;
|
workflowsStore.pinnedWorkflowData = undefined;
|
||||||
workflowsStore.shouldReplaceInputDataWithPinData = false;
|
|
||||||
workflowsStore.getWorkflowRunData = {
|
workflowsStore.getWorkflowRunData = {
|
||||||
ParentNode: [
|
ParentNode: [
|
||||||
{ data: {} } as never,
|
{ data: {} } as never,
|
||||||
@@ -1066,7 +1063,6 @@ describe('useWorkflowHelpers', () => {
|
|||||||
const runIndex = 0;
|
const runIndex = 0;
|
||||||
|
|
||||||
workflowsStore.pinnedWorkflowData = undefined;
|
workflowsStore.pinnedWorkflowData = undefined;
|
||||||
workflowsStore.shouldReplaceInputDataWithPinData = false;
|
|
||||||
workflowsStore.getWorkflowRunData = null;
|
workflowsStore.getWorkflowRunData = null;
|
||||||
|
|
||||||
const result = executeData({}, parentNodes, currentNode, inputName, runIndex);
|
const result = executeData({}, parentNodes, currentNode, inputName, runIndex);
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ export function resolveParameter<T = IDataObject>(
|
|||||||
opts.envVars,
|
opts.envVars,
|
||||||
opts.workflow.getNode(opts.nodeName),
|
opts.workflow.getNode(opts.nodeName),
|
||||||
opts.execution,
|
opts.execution,
|
||||||
true,
|
|
||||||
opts.workflow.pinData,
|
opts.workflow.pinData,
|
||||||
{
|
{
|
||||||
inputNodeName: opts.inputNode?.name,
|
inputNodeName: opts.inputNode?.name,
|
||||||
@@ -108,7 +107,6 @@ export function resolveParameter<T = IDataObject>(
|
|||||||
useEnvironmentsStore().variablesAsObject,
|
useEnvironmentsStore().variablesAsObject,
|
||||||
useNDVStore().activeNode,
|
useNDVStore().activeNode,
|
||||||
workflowsStore.workflowExecutionData,
|
workflowsStore.workflowExecutionData,
|
||||||
workflowsStore.shouldReplaceInputDataWithPinData,
|
|
||||||
workflowsStore.pinnedWorkflowData,
|
workflowsStore.pinnedWorkflowData,
|
||||||
opts,
|
opts,
|
||||||
);
|
);
|
||||||
@@ -122,7 +120,6 @@ function resolveParameterImpl<T = IDataObject>(
|
|||||||
envVars: Record<string, string | boolean | number>,
|
envVars: Record<string, string | boolean | number>,
|
||||||
ndvActiveNode: INodeUi | null,
|
ndvActiveNode: INodeUi | null,
|
||||||
executionData: IExecutionResponse | null,
|
executionData: IExecutionResponse | null,
|
||||||
shouldReplaceInputDataWithPinData: boolean,
|
|
||||||
pinData: IPinData | undefined,
|
pinData: IPinData | undefined,
|
||||||
opts: ResolveParameterOptions = {},
|
opts: ResolveParameterOptions = {},
|
||||||
): T | null {
|
): T | null {
|
||||||
@@ -209,7 +206,6 @@ function resolveParameterImpl<T = IDataObject>(
|
|||||||
contextNode!.name,
|
contextNode!.name,
|
||||||
inputName,
|
inputName,
|
||||||
runIndexParent,
|
runIndexParent,
|
||||||
shouldReplaceInputDataWithPinData,
|
|
||||||
pinData,
|
pinData,
|
||||||
executionData?.data?.resultData.runData ?? null,
|
executionData?.data?.resultData.runData ?? null,
|
||||||
nodeConnection,
|
nodeConnection,
|
||||||
@@ -224,7 +220,6 @@ function resolveParameterImpl<T = IDataObject>(
|
|||||||
contextNode.name,
|
contextNode.name,
|
||||||
inputName,
|
inputName,
|
||||||
0,
|
0,
|
||||||
shouldReplaceInputDataWithPinData,
|
|
||||||
pinData,
|
pinData,
|
||||||
executionData?.data?.resultData.runData ?? null,
|
executionData?.data?.resultData.runData ?? null,
|
||||||
);
|
);
|
||||||
@@ -274,7 +269,6 @@ function resolveParameterImpl<T = IDataObject>(
|
|||||||
contextNode!.name,
|
contextNode!.name,
|
||||||
inputName,
|
inputName,
|
||||||
runIndexCurrent,
|
runIndexCurrent,
|
||||||
shouldReplaceInputDataWithPinData,
|
|
||||||
pinData,
|
pinData,
|
||||||
executionData?.data?.resultData.runData ?? null,
|
executionData?.data?.resultData.runData ?? null,
|
||||||
runIndexParent,
|
runIndexParent,
|
||||||
@@ -288,7 +282,6 @@ function resolveParameterImpl<T = IDataObject>(
|
|||||||
contextNode!.name,
|
contextNode!.name,
|
||||||
inputName,
|
inputName,
|
||||||
runIndexParent,
|
runIndexParent,
|
||||||
shouldReplaceInputDataWithPinData,
|
|
||||||
pinData,
|
pinData,
|
||||||
executionData?.data?.resultData.runData ?? null,
|
executionData?.data?.resultData.runData ?? null,
|
||||||
);
|
);
|
||||||
@@ -383,7 +376,6 @@ function connectionInputData(
|
|||||||
currentNode: string,
|
currentNode: string,
|
||||||
inputName: string,
|
inputName: string,
|
||||||
runIndex: number,
|
runIndex: number,
|
||||||
shouldReplaceInputDataWithPinData: boolean,
|
|
||||||
pinData: IPinData | undefined,
|
pinData: IPinData | undefined,
|
||||||
workflowRunData: IRunData | null,
|
workflowRunData: IRunData | null,
|
||||||
nodeConnection: INodeConnection = { sourceIndex: 0, destinationIndex: 0 },
|
nodeConnection: INodeConnection = { sourceIndex: 0, destinationIndex: 0 },
|
||||||
@@ -395,7 +387,6 @@ function connectionInputData(
|
|||||||
currentNode,
|
currentNode,
|
||||||
inputName,
|
inputName,
|
||||||
runIndex,
|
runIndex,
|
||||||
shouldReplaceInputDataWithPinData,
|
|
||||||
pinData,
|
pinData,
|
||||||
workflowRunData,
|
workflowRunData,
|
||||||
);
|
);
|
||||||
@@ -442,7 +433,6 @@ export function executeData(
|
|||||||
currentNode,
|
currentNode,
|
||||||
inputName,
|
inputName,
|
||||||
runIndex,
|
runIndex,
|
||||||
workflowsStore.shouldReplaceInputDataWithPinData,
|
|
||||||
workflowsStore.pinnedWorkflowData,
|
workflowsStore.pinnedWorkflowData,
|
||||||
workflowsStore.getWorkflowRunData,
|
workflowsStore.getWorkflowRunData,
|
||||||
parentRunIndex,
|
parentRunIndex,
|
||||||
@@ -456,7 +446,6 @@ function executeDataImpl(
|
|||||||
currentNode: string,
|
currentNode: string,
|
||||||
inputName: string,
|
inputName: string,
|
||||||
runIndex: number,
|
runIndex: number,
|
||||||
shouldReplaceInputDataWithPinData: boolean,
|
|
||||||
pinData: IPinData | undefined,
|
pinData: IPinData | undefined,
|
||||||
workflowRunData: IRunData | null,
|
workflowRunData: IRunData | null,
|
||||||
parentRunIndex?: number,
|
parentRunIndex?: number,
|
||||||
@@ -473,17 +462,15 @@ function executeDataImpl(
|
|||||||
|
|
||||||
// Find the parent node which has data
|
// Find the parent node which has data
|
||||||
for (const parentNodeName of parentNodes) {
|
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) {
|
if (parentPinData) {
|
||||||
executeData.data = { main: [parentPinData] };
|
executeData.data = { main: [parentPinData] };
|
||||||
executeData.source = { main: [{ previousNode: parentNodeName }] };
|
executeData.source = { main: [{ previousNode: parentNodeName }] };
|
||||||
|
|
||||||
return executeData;
|
return executeData;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// populate `executeData` from `runData`
|
// populate `executeData` from `runData`
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import type {
|
|||||||
IRunDataDisplayMode,
|
IRunDataDisplayMode,
|
||||||
MainPanelDimensions,
|
MainPanelDimensions,
|
||||||
MainPanelType,
|
MainPanelType,
|
||||||
NDVState,
|
|
||||||
NodePanelType,
|
NodePanelType,
|
||||||
OutputPanel,
|
OutputPanel,
|
||||||
TargetItem,
|
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;
|
draggable.value.activeTarget = target;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import type { IExecutionResponse, INodeUi, IWorkflowDb, IWorkflowSettings } from
|
|||||||
import { deepCopy, SEND_AND_WAIT_OPERATION } from 'n8n-workflow';
|
import { deepCopy, SEND_AND_WAIT_OPERATION } from 'n8n-workflow';
|
||||||
import type {
|
import type {
|
||||||
IPinData,
|
IPinData,
|
||||||
ExecutionSummary,
|
|
||||||
IConnection,
|
IConnection,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INode,
|
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()', () => {
|
describe('getWorkflowResultDataByNodeName()', () => {
|
||||||
it('should return null when no workflow run data is present', () => {
|
it('should return null when no workflow run data is present', () => {
|
||||||
workflowsStore.workflowExecutionData = null;
|
workflowsStore.workflowExecutionData = null;
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||||||
const usedCredentials = ref<Record<string, IUsedCredential>>({});
|
const usedCredentials = ref<Record<string, IUsedCredential>>({});
|
||||||
|
|
||||||
const activeWorkflows = ref<string[]>([]);
|
const activeWorkflows = ref<string[]>([]);
|
||||||
const activeWorkflowExecution = ref<ExecutionSummary | null>(null);
|
|
||||||
const currentWorkflowExecutions = ref<ExecutionSummary[]>([]);
|
const currentWorkflowExecutions = ref<ExecutionSummary[]>([]);
|
||||||
const workflowExecutionData = ref<IExecutionResponse | null>(null);
|
const workflowExecutionData = ref<IExecutionResponse | null>(null);
|
||||||
const workflowExecutionStartedData =
|
const workflowExecutionStartedData =
|
||||||
@@ -280,10 +279,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||||||
|
|
||||||
const pinnedWorkflowData = computed(() => workflow.value.pinData);
|
const pinnedWorkflowData = computed(() => workflow.value.pinData);
|
||||||
|
|
||||||
const shouldReplaceInputDataWithPinData = computed(() => {
|
|
||||||
return !activeWorkflowExecution.value || activeWorkflowExecution.value.mode === 'manual';
|
|
||||||
});
|
|
||||||
|
|
||||||
const executedNode = computed(() => workflowExecutionData.value?.executedNode);
|
const executedNode = computed(() => workflowExecutionData.value?.executedNode);
|
||||||
|
|
||||||
const getAllLoadedFinishedExecutions = computed(() => {
|
const getAllLoadedFinishedExecutions = computed(() => {
|
||||||
@@ -1905,7 +1900,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||||||
workflow,
|
workflow,
|
||||||
usedCredentials,
|
usedCredentials,
|
||||||
activeWorkflows,
|
activeWorkflows,
|
||||||
activeWorkflowExecution,
|
|
||||||
currentWorkflowExecutions,
|
currentWorkflowExecutions,
|
||||||
workflowExecutionData,
|
workflowExecutionData,
|
||||||
workflowExecutionPairedItemMappings,
|
workflowExecutionPairedItemMappings,
|
||||||
@@ -1945,7 +1939,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||||||
nodesByName,
|
nodesByName,
|
||||||
nodesIssuesExist,
|
nodesIssuesExist,
|
||||||
pinnedWorkflowData,
|
pinnedWorkflowData,
|
||||||
shouldReplaceInputDataWithPinData,
|
|
||||||
executedNode,
|
executedNode,
|
||||||
getAllLoadedFinishedExecutions,
|
getAllLoadedFinishedExecutions,
|
||||||
getWorkflowExecution,
|
getWorkflowExecution,
|
||||||
|
|||||||
Reference in New Issue
Block a user