Skip to content

Commit

Permalink
fix(n8n Form Trigger Node): Execution from canvas (#10132)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency authored and cstuncsik committed Jul 31, 2024
1 parent 484002b commit ebc45a1
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions packages/editor-ui/src/composables/useWorkflowHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ import { useProjectsStore } from '@/stores/projects.store';
import { useTagsStore } from '@/stores/tags.store';
import useWorkflowsEEStore from '@/stores/workflows.ee.store';

type ResolveParameterOptions = {
targetItem?: TargetItem;
inputNodeName?: string;
inputRunIndex?: number;
inputBranchIndex?: number;
additionalKeys?: IWorkflowDataProxyAdditionalKeys;
isForCredential?: boolean;
contextNodeName?: string;
};

export function resolveParameter<T = IDataObject>(
parameter: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[],
opts: {
targetItem?: TargetItem;
inputNodeName?: string;
inputRunIndex?: number;
inputBranchIndex?: number;
additionalKeys?: IWorkflowDataProxyAdditionalKeys;
isForCredential?: boolean;
} = {},
opts: ResolveParameterOptions = {},
): T | null {
let itemIndex = opts?.targetItem?.itemIndex || 0;

Expand Down Expand Up @@ -117,7 +120,9 @@ export function resolveParameter<T = IDataObject>(
}

const inputName = NodeConnectionType.Main;
const activeNode = useNDVStore().activeNode;

const activeNode =
useNDVStore().activeNode ?? useWorkflowsStore().getNodeByName(opts.contextNodeName || '');
let contextNode = activeNode;

if (activeNode) {
Expand Down Expand Up @@ -638,6 +643,7 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
webhookData: IWebhookDescription,
key: string,
stringify = true,
nodeName?: string,
): string {
if (webhookData[key] === undefined) {
return 'empty';
Expand All @@ -646,7 +652,7 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
return resolveExpression(
webhookData[key] as string,
undefined,
undefined,
{ contextNodeName: nodeName },
stringify,
) as string;
} catch (e) {
Expand All @@ -672,25 +678,22 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
}

const workflowId = workflowsStore.workflowId;
const path = getWebhookExpressionValue(webhookData, 'path');
const path = getWebhookExpressionValue(webhookData, 'path', true, node.name);
const isFullPath =
(getWebhookExpressionValue(webhookData, 'isFullPath') as unknown as boolean) || false;
(getWebhookExpressionValue(
webhookData,
'isFullPath',
true,
node.name,
) as unknown as boolean) || false;

return NodeHelpers.getNodeWebhookUrl(baseUrl, workflowId, node, path, isFullPath);
}

function resolveExpression(
expression: string,
siblingParameters: INodeParameters = {},
opts: {
targetItem?: TargetItem;
inputNodeName?: string;
inputRunIndex?: number;
inputBranchIndex?: number;
c?: number;
additionalKeys?: IWorkflowDataProxyAdditionalKeys;
isForCredential?: boolean;
} = {},
opts: ResolveParameterOptions & { c?: number } = {},
stringifyObject = true,
) {
const parameters = {
Expand Down

0 comments on commit ebc45a1

Please sign in to comment.