diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 1273572f08..878152de40 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -525,6 +525,7 @@ class App { this.app.get('/rest/node-parameter-options', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise => { const nodeType = req.query.nodeType; let credentials: INodeCredentials | undefined = undefined; + const currentNodeParameters = req.query.currentNodeParameters; if (req.query.credentials !== undefined) { credentials = JSON.parse(req.query.credentials); } @@ -537,7 +538,7 @@ class App { const workflowData = loadDataInstance.getWorkflowData() as IWorkflowBase; const workflowCredentials = await WorkflowCredentials(workflowData.nodes); - const additionalData = await WorkflowExecuteAdditionalData.getBase(executionMode, workflowCredentials); + const additionalData = await WorkflowExecuteAdditionalData.getBase(executionMode, workflowCredentials,currentNodeParameters); return loadDataInstance.getOptions(methodName, additionalData); })); diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index 8565aff6b3..a5e79de075 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -23,6 +23,7 @@ import { IWorkflowExecuteAdditionalData, IWorkflowExecuteHooks, WorkflowExecuteMode, + INodeParameters, } from 'n8n-workflow'; import * as config from '../config'; @@ -245,7 +246,7 @@ const hooks = (mode: WorkflowExecuteMode, workflowData: IWorkflowBase, execution * @param {IWorkflowCredentials} credentials * @returns {Promise} */ -export async function getBase(mode: WorkflowExecuteMode, credentials: IWorkflowCredentials): Promise { +export async function getBase(mode: WorkflowExecuteMode, credentials: IWorkflowCredentials,currentNodeParameters: INodeParameters[] = []): Promise { const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl(); const timezone = config.get('generic.timezone') as string; @@ -263,6 +264,7 @@ export async function getBase(mode: WorkflowExecuteMode, credentials: IWorkflowC timezone, webhookBaseUrl, webhookTestBaseUrl, + currentNodeParameters }; } diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 675ad36d5f..1cf832952f 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -513,6 +513,13 @@ export function getLoadOptionsFunctions(workflow: Workflow, node: INode, additio getCredentials(type: string): ICredentialDataDecryptedObject | undefined { return getCredentials(workflow, node, type, additionalData); }, + getCurrentNodeParameters : (parameterName : string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { + const nodeParameters = JSON.parse(''+additionalData.currentNodeParameters); + if(nodeParameters && nodeParameters[parameterName] ){ + return nodeParameters[parameterName]; + } + return false; + }, getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any const runExecutionData: IRunExecutionData | null = null; const itemIndex = 0; diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 53e24d23da..e28ebee5f5 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -53,8 +53,6 @@ declare module 'jsplumb' { } } - - // EndpointOptions from jsplumb seems incomplete and wrong so we define an own one export interface IEndpointOptions { anchor?: any; // tslint:disable-line:no-any @@ -353,7 +351,6 @@ export interface IPushDataExecutionStarted { workflowName?: string; } - export interface IPushDataExecutionFinished { data: IRun; executionIdActive: string; diff --git a/packages/editor-ui/src/components/ParameterInput.vue b/packages/editor-ui/src/components/ParameterInput.vue index 3639ac884a..19fff5a6a7 100644 --- a/packages/editor-ui/src/components/ParameterInput.vue +++ b/packages/editor-ui/src/components/ParameterInput.vue @@ -400,10 +400,9 @@ export default mixins( }, methods: { async loadRemoteParameterOptions () { - if (this.node === null || this.remoteMethod === undefined) { + if (this.node === null || this.remoteMethod === undefined || this.remoteParameterOptionsLoading) { return; } - this.remoteParameterOptionsLoadingIssues = null; this.remoteParameterOptionsLoading = true; this.remoteParameterOptions.length = 0; @@ -513,6 +512,28 @@ export default mixins( this.$watch(() => this.node!.credentials, () => { this.loadRemoteParameterOptions(); }, { deep: true, immediate: true }); + + // Reload function on change element from + // displayOptions.typeOptions.reloadOnChange parameters + if (this.parameter.typeOptions && this.parameter.typeOptions.reloadOnChange) { + // Get all paramter in reloadOnChange property + // This reload when parameters in reloadOnChange is updated + const paramtersOnChange : string[] = this.parameter.typeOptions.reloadOnChange; + for (let i = 0; i < paramtersOnChange.length; i++) { + const parameter = paramtersOnChange[i] as string; + if (parameter in this.node.parameters) { + this.$watch(() => { + if (this.node && this.node.parameters && this.node.parameters[parameter]) { + return this.node.parameters![parameter]; + } else { + return null; + } + }, () => { + this.loadRemoteParameterOptions(); + }, { deep: true, immediate: true }); + } + } + } } }, }); diff --git a/packages/editor-ui/src/components/mixins/restApi.ts b/packages/editor-ui/src/components/mixins/restApi.ts index d548b5d4d4..bcfbeca914 100644 --- a/packages/editor-ui/src/components/mixins/restApi.ts +++ b/packages/editor-ui/src/components/mixins/restApi.ts @@ -157,8 +157,8 @@ export const restApi = Vue.extend({ nodeType, methodName, credentials, + currentNodeParameters : this.$store.getters.activeNode.parameters, }; - return self.restApi().makeRestApiRequest('GET', '/node-parameter-options', sendData); }, diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index d4cfd62c79..77afadf4a7 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -181,6 +181,7 @@ export interface IExecuteSingleFunctions { export interface ILoadOptionsFunctions { getCredentials(type: string): ICredentialDataDecryptedObject | undefined; getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; //tslint:disable-line:no-any + getCurrentNodeParameters(parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; getTimezone(): string; helpers: { [key: string]: ((...args: any[]) => any) | undefined; //tslint:disable-line:no-any @@ -290,7 +291,7 @@ export type NodeParameterValue = string | number | boolean; export interface INodeParameters { // TODO: Later also has to be possible to add multiple ones with the name name. So array has to be possible - [key: string]: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[]; + [key: string]: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] ; } @@ -597,6 +598,7 @@ export interface IWorkflowExecuteAdditionalData { timezone: string; webhookBaseUrl: string; webhookTestBaseUrl: string; + currentNodeParameters? : INodeParameters[]; } export type WorkflowExecuteMode = 'cli' | 'error' | 'internal' | 'manual' | 'retry' | 'trigger' | 'webhook';