mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(n8n Form Trigger Node): Do not rerun trigger when it has run data (#10687)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { ExecutionStatus, IDataObject } from 'n8n-workflow';
|
||||
import type { ExecutionStatus, IDataObject, INode, IPinData, IRunData } from 'n8n-workflow';
|
||||
import type { ExecutionFilterType, ExecutionsQueryFilter } from '@/Interface';
|
||||
import { isEmpty } from '@/utils/typesUtils';
|
||||
import { FORM_TRIGGER_NODE_TYPE, WAIT_NODE_TYPE } from '../constants';
|
||||
|
||||
export function getDefaultExecutionFilters(): ExecutionFilterType {
|
||||
return {
|
||||
@@ -86,3 +87,64 @@ export const openPopUpWindow = (
|
||||
window.open(url, '_blank', features);
|
||||
}
|
||||
};
|
||||
|
||||
export function displayForm({
|
||||
nodes,
|
||||
runData,
|
||||
pinData,
|
||||
destinationNode,
|
||||
directParentNodes,
|
||||
formWaitingUrl,
|
||||
executionId,
|
||||
source,
|
||||
getTestUrl,
|
||||
shouldShowForm,
|
||||
}: {
|
||||
nodes: INode[];
|
||||
runData: IRunData | undefined;
|
||||
pinData: IPinData;
|
||||
destinationNode: string | undefined;
|
||||
directParentNodes: string[];
|
||||
formWaitingUrl: string;
|
||||
executionId: string | undefined;
|
||||
source: string | undefined;
|
||||
getTestUrl: (node: INode) => string;
|
||||
shouldShowForm: (node: INode) => boolean;
|
||||
}) {
|
||||
for (const node of nodes) {
|
||||
const hasNodeRun = runData && runData?.hasOwnProperty(node.name);
|
||||
|
||||
if (hasNodeRun || pinData[node.name]) continue;
|
||||
|
||||
if (![FORM_TRIGGER_NODE_TYPE, WAIT_NODE_TYPE].includes(node.type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
destinationNode &&
|
||||
destinationNode !== node.name &&
|
||||
!directParentNodes.includes(node.name)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node.name === destinationNode || !node.disabled) {
|
||||
let testUrl = '';
|
||||
|
||||
if (node.type === FORM_TRIGGER_NODE_TYPE) {
|
||||
testUrl = getTestUrl(node);
|
||||
}
|
||||
|
||||
if (node.type === WAIT_NODE_TYPE && node.parameters.resume === 'form' && executionId) {
|
||||
if (!shouldShowForm(node)) continue;
|
||||
|
||||
const { webhookSuffix } = (node.parameters.options ?? {}) as IDataObject;
|
||||
const suffix =
|
||||
webhookSuffix && typeof webhookSuffix !== 'object' ? `/${webhookSuffix}` : '';
|
||||
testUrl = `${formWaitingUrl}/${executionId}${suffix}`;
|
||||
}
|
||||
|
||||
if (testUrl && source !== 'RunData.ManualChatMessage') openPopUpWindow(testUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user