feat: Update Workflow class usage on the Frontend for better performance (no-changelog) (#17680)

This commit is contained in:
Alex Grozav
2025-08-04 15:04:00 +03:00
committed by GitHub
parent ff8531d544
commit 279dce639a
66 changed files with 659 additions and 660 deletions

View File

@@ -119,7 +119,7 @@ export type EnterEditModeArgs = {
};
type Props = {
workflow: Workflow;
workflowObject: Workflow;
workflowExecution?: IRunExecutionData;
runIndex: number;
tooMuchDataTitle: string;
@@ -314,7 +314,7 @@ const hasSubworkflowExecutionError = computed(() => !!workflowsStore.subWorkflow
// Sub-nodes may wish to display the parent node error as it can contain additional metadata
const parentNodeError = computed(() => {
const parentNode = props.workflow.getChildNodes(node.value?.name ?? '', 'ALL_NON_MAIN')[0];
const parentNode = props.workflowObject.getChildNodes(node.value?.name ?? '', 'ALL_NON_MAIN')[0];
return workflowRunData.value?.[parentNode]?.[props.runIndex]?.error as NodeError;
});
const workflowRunErrorAsNodeError = computed(() => {
@@ -508,12 +508,12 @@ const showIoSearchNoMatchContent = computed(
);
const parentNodeOutputData = computed(() => {
const parentNode = props.workflow.getParentNodesByDepth(node.value?.name ?? '')[0];
const parentNode = props.workflowObject.getParentNodesByDepth(node.value?.name ?? '')[0];
let parentNodeData: INodeExecutionData[] = [];
if (parentNode?.name) {
parentNodeData = nodeHelpers.getNodeInputData(
props.workflow.getNode(parentNode?.name),
props.workflowObject.getNode(parentNode?.name),
props.runIndex,
outputIndex.value,
'input',
@@ -525,8 +525,8 @@ const parentNodeOutputData = computed(() => {
});
const parentNodePinnedData = computed(() => {
const parentNode = props.workflow.getParentNodesByDepth(node.value?.name ?? '')[0];
return props.workflow.pinData?.[parentNode?.name || ''] ?? [];
const parentNode = props.workflowObject.getParentNodesByDepth(node.value?.name ?? '')[0];
return props.workflowObject.pinData?.[parentNode?.name || ''] ?? [];
});
const showPinButton = computed(() => {
@@ -745,10 +745,14 @@ onBeforeUnmount(() => {
function getResolvedNodeOutputs() {
if (node.value && nodeType.value) {
const workflowNode = props.workflow.getNode(node.value.name);
const workflowNode = props.workflowObject.getNode(node.value.name);
if (workflowNode) {
const outputs = NodeHelpers.getNodeOutputs(props.workflow, workflowNode, nodeType.value);
const outputs = NodeHelpers.getNodeOutputs(
props.workflowObject,
workflowNode,
nodeType.value,
);
return outputs;
}
}
@@ -780,13 +784,14 @@ function shouldHintBeDisplayed(hint: NodeHint): boolean {
return true;
}
function getNodeHints(): NodeHint[] {
const nodeHints = computed<NodeHint[]>(() => {
try {
if (node.value && nodeType.value) {
const workflowNode = props.workflow.getNode(node.value.name);
const workflowNode = props.workflowObject.getNode(node.value.name);
if (workflowNode) {
const nodeHints = nodeHelpers.getNodeHints(props.workflow, workflowNode, nodeType.value, {
const hints = nodeHelpers.getNodeHints(props.workflowObject, workflowNode, nodeType.value, {
runExecutionData: workflowExecution.value ?? null,
runIndex: props.runIndex,
connectionInputData: parentNodeOutputData.value,
@@ -803,13 +808,13 @@ function getNodeHints(): NodeHint[] {
node: node.value,
nodeType: nodeType.value,
nodeOutputData,
nodes: props.workflow.nodes,
connections: props.workflow.connectionsBySourceNode,
nodes: props.workflowObject.nodes,
connections: props.workflowObject.connectionsBySourceNode,
hasNodeRun: hasNodeRun.value,
hasMultipleInputItems,
});
return executionHints.value.concat(nodeHints, genericHints).filter(shouldHintBeDisplayed);
return executionHints.value.concat(hints, genericHints).filter(shouldHintBeDisplayed);
}
}
} catch (error) {
@@ -817,7 +822,8 @@ function getNodeHints(): NodeHint[] {
}
return [];
}
});
function onItemHover(itemIndex: number | null) {
if (itemIndex === null) {
emit('itemHover', null);
@@ -1548,7 +1554,7 @@ defineExpose({ enterEditMode });
:node="node"
/>
<N8nCallout
v-for="hint in getNodeHints()"
v-for="hint in nodeHints"
:key="hint.message"
:class="$style.hintCallout"
:theme="hint.type || 'info'"