diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 4b717037c9..0346558d50 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -717,6 +717,7 @@ class App { // get generated dynamically this.app.get(`/${this.restEndpoint}/node-parameter-options`, ResponseHelper.send(async (req: express.Request, res: express.Response): Promise => { const nodeType = req.query.nodeType as string; + const path = req.query.path as string; let credentials: INodeCredentials | undefined = undefined; const currentNodeParameters = JSON.parse('' + req.query.currentNodeParameters) as INodeParameters; if (req.query.credentials !== undefined) { @@ -726,7 +727,7 @@ class App { const nodeTypes = NodeTypes(); - const loadDataInstance = new LoadNodeParameterOptions(nodeType, nodeTypes, JSON.parse('' + req.query.currentNodeParameters), credentials!); + const loadDataInstance = new LoadNodeParameterOptions(nodeType, nodeTypes, path, JSON.parse('' + req.query.currentNodeParameters), credentials!); const workflowData = loadDataInstance.getWorkflowData() as IWorkflowBase; const workflowCredentials = await WorkflowCredentials(workflowData.nodes); diff --git a/packages/core/src/LoadNodeParameterOptions.ts b/packages/core/src/LoadNodeParameterOptions.ts index 6a9b457503..d112f63bfd 100644 --- a/packages/core/src/LoadNodeParameterOptions.ts +++ b/packages/core/src/LoadNodeParameterOptions.ts @@ -18,10 +18,12 @@ const TEMP_WORKFLOW_NAME = 'Temp-Workflow'; export class LoadNodeParameterOptions { + path: string; workflow: Workflow; - constructor(nodeTypeName: string, nodeTypes: INodeTypes, currentNodeParameters: INodeParameters, credentials?: INodeCredentials) { + constructor(nodeTypeName: string, nodeTypes: INodeTypes, path: string, currentNodeParameters: INodeParameters, credentials?: INodeCredentials) { + this.path = path; const nodeType = nodeTypes.getByName(nodeTypeName); if (nodeType === undefined) { @@ -89,7 +91,7 @@ export class LoadNodeParameterOptions { throw new Error(`The node-type "${node!.type}" does not have the method "${methodName}" defined!`); } - const thisArgs = NodeExecuteFunctions.getLoadOptionsFunctions(this.workflow, node!, additionalData); + const thisArgs = NodeExecuteFunctions.getLoadOptionsFunctions(this.workflow, node!, this.path, additionalData); return nodeType!.methods.loadOptions[methodName].call(thisArgs); } diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 726526afc1..36004fd10c 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -871,18 +871,20 @@ export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData: * @param {IWorkflowExecuteAdditionalData} additionalData * @returns {ILoadOptionsFunctions} */ -export function getLoadOptionsFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData): ILoadOptionsFunctions { - return ((workflow: Workflow, node: INode) => { +export function getLoadOptionsFunctions(workflow: Workflow, node: INode, path: string, additionalData: IWorkflowExecuteAdditionalData): ILoadOptionsFunctions { + return ((workflow: Workflow, node: INode, path: string) => { const that = { getCredentials(type: string): ICredentialDataDecryptedObject | undefined { return getCredentials(workflow, node, type, additionalData, 'internal'); }, - getCurrentNodeParameter: (parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined => { + getCurrentNodeParameter: (parameterPath: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined => { const nodeParameters = additionalData.currentNodeParameters; - if (nodeParameters && nodeParameters[parameterName]) { - return nodeParameters[parameterName]; + + if (parameterPath.charAt(0) === '&') { + parameterPath = `${path.split('.').slice(1, -1).join('.')}.${parameterPath.slice(1)}`; } - return undefined; + + return get(nodeParameters, parameterPath); }, getCurrentNodeParameters: (): INodeParameters | undefined => { return additionalData.currentNodeParameters; @@ -915,7 +917,7 @@ export function getLoadOptionsFunctions(workflow: Workflow, node: INode, additio }, }; return that; - })(workflow, node); + })(workflow, node, path); } diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 1ac72fd90a..4fdbd770f8 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -131,7 +131,7 @@ export interface IRestApi { getSettings(): Promise; getNodeTypes(): Promise; getNodesInformation(nodeList: string[]): Promise; - getNodeParameterOptions(nodeType: string, methodName: string, currentNodeParameters: INodeParameters, credentials?: INodeCredentials): Promise; + getNodeParameterOptions(nodeType: string, path: string, methodName: string, currentNodeParameters: INodeParameters, credentials?: INodeCredentials): Promise; removeTestWebhook(workflowId: string): Promise; runWorkflow(runData: IStartRunData): Promise; createNewWorkflow(sendData: IWorkflowData): Promise; @@ -444,4 +444,4 @@ export interface ILinkMenuItemProperties { icon: string; href: string; newWindow?: boolean; -} \ No newline at end of file +} diff --git a/packages/editor-ui/src/components/ParameterInput.vue b/packages/editor-ui/src/components/ParameterInput.vue index ae2be2e8cd..4ed7460733 100644 --- a/packages/editor-ui/src/components/ParameterInput.vue +++ b/packages/editor-ui/src/components/ParameterInput.vue @@ -484,7 +484,7 @@ export default mixins( const resolvedNodeParameters = this.getResolveNodeParameters(currentNodeParameters); try { - const options = await this.restApi().getNodeParameterOptions(this.node.type, this.remoteMethod, resolvedNodeParameters, this.node.credentials); + const options = await this.restApi().getNodeParameterOptions(this.node.type, this.path, this.remoteMethod, resolvedNodeParameters, this.node.credentials); this.remoteParameterOptions.push.apply(this.remoteParameterOptions, options); } catch (error) { this.remoteParameterOptionsLoadingIssues = error.message; diff --git a/packages/editor-ui/src/components/mixins/restApi.ts b/packages/editor-ui/src/components/mixins/restApi.ts index d6aeff88c1..f51df9183e 100644 --- a/packages/editor-ui/src/components/mixins/restApi.ts +++ b/packages/editor-ui/src/components/mixins/restApi.ts @@ -157,9 +157,10 @@ export const restApi = Vue.extend({ }, // Returns all the parameter options from the server - getNodeParameterOptions: (nodeType: string, methodName: string, currentNodeParameters: INodeParameters, credentials?: INodeCredentials): Promise => { + getNodeParameterOptions: (nodeType: string, path: string, methodName: string, currentNodeParameters: INodeParameters, credentials?: INodeCredentials): Promise => { const sendData = { nodeType, + path, methodName, credentials, currentNodeParameters,