🔀 Merge branch 'master' into oauth-support

This commit is contained in:
Jan Oberhauser
2020-05-12 01:56:27 +02:00
159 changed files with 20155 additions and 2001 deletions

View File

@@ -42,7 +42,7 @@
</el-tooltip>
</div>
<div v-for="parameter in credentialProperties" :key="parameter.name">
<el-row v-if="displayNodeParameter(parameter)" class="parameter-wrapper">
<el-row v-if="displayCredentialParameter(parameter)" class="parameter-wrapper">
<el-col :span="6" class="parameter-name">
{{parameter.displayName}}:
<el-tooltip placement="top" class="parameter-info" v-if="parameter.description" effect="light">
@@ -56,7 +56,6 @@
</el-row>
</div>
<el-row class="nodes-access-wrapper">
<el-col :span="6" class="headline">
Nodes with access:
@@ -112,6 +111,7 @@ import {
ICredentialType,
ICredentialNodeAccess,
INodeCredentialDescription,
INodeParameters,
INodeProperties,
INodeTypeDescription,
} from 'n8n-workflow';
@@ -232,6 +232,18 @@ export default mixins(
tempValue[name] = parameterData.value;
Vue.set(this, 'propertyValue', tempValue);
},
displayCredentialParameter (parameter: INodeProperties): boolean {
if (parameter.type === 'hidden') {
return false;
}
if (parameter.displayOptions === undefined) {
// If it is not defined no need to do a proper check
return true;
}
return this.displayParameter(this.propertyValue as INodeParameters, parameter, '');
},
async createCredentials (closeDialog: boolean): Promise<ICredentialsResponse | null> {
const nodesAccess = this.nodesAccess.map((nodeType) => {
return {
@@ -261,13 +273,6 @@ export default mixins(
return result;
},
displayNodeParameter (parameter: INodeProperties): boolean {
if (parameter.type === 'hidden') {
return false;
}
return true;
},
async oAuth2CredentialAuthorize () {
let url;

View File

@@ -504,11 +504,11 @@ export default mixins(
} else if (entry.finished === true) {
return 'The worklow execution was successful.';
} else if (entry.retryOf !== undefined) {
return `The workflow execution was a retry of "${entry.retryOf}" and did fail.<br />New retries have to be started from the original execution.`;
return `The workflow execution was a retry of "${entry.retryOf}" and failed.<br />New retries have to be started from the original execution.`;
} else if (entry.retrySuccessId !== undefined) {
return `The workflow execution did fail but the retry "${entry.retrySuccessId}" was successful.`;
return `The workflow execution failed but the retry "${entry.retrySuccessId}" was successful.`;
} else {
return 'The workflow execution did fail.';
return 'The workflow execution failed.';
}
},
async stopExecution (activeExecutionId: string) {

View File

@@ -129,6 +129,10 @@ export default mixins(nodeBase, workflowHelpers).extend({
}
},
nodeSubtitle (): string | undefined {
if (this.data.notesInFlow) {
return this.data.notes;
}
if (this.nodeType !== null && this.nodeType.subtitle !== undefined) {
return this.workflow.getSimpleParameterValue(this.data as INode, this.nodeType.subtitle) as string | undefined;
}

View File

@@ -142,6 +142,7 @@ export default mixins(
nodeValues: {
color: '#ff0000',
alwaysOutputData: false,
notesInFlow: false,
continueOnFail: false,
retryOnFail: false,
maxTries: 3,
@@ -162,6 +163,14 @@ export default mixins(
noDataExpression: true,
description: 'Notes to save with the node.',
},
{
displayName: 'Notes In Flow',
name: 'notesInFlow',
type: 'boolean',
default: false,
noDataExpression: true,
description: 'If activated it will display the above notes in the flow as subtitle.',
},
{
displayName: 'Node Color',
name: 'color',
@@ -438,6 +447,11 @@ export default mixins(
Vue.set(this.nodeValues, 'continueOnFail', this.node.continueOnFail);
}
if (this.node.notesInFlow) {
foundNodeSettings.push('notesInFlow');
Vue.set(this.nodeValues, 'notesInFlow', this.node.notesInFlow);
}
if (this.node.retryOnFail) {
foundNodeSettings.push('retryOnFail');
Vue.set(this.nodeValues, 'retryOnFail', this.node.retryOnFail);

View File

@@ -22,6 +22,8 @@ export const pushConnection = mixins(
return {
eventSource: null as EventSource | null,
reconnectTimeout: null as NodeJS.Timeout | null,
retryTimeout: null as NodeJS.Timeout | null,
pushMessageQueue: [] as Array<{ event: Event, retriesLeft: number }>,
};
},
computed: {
@@ -96,47 +98,84 @@ export const pushConnection = mixins(
* @param {number} retryAttempts
* @returns
*/
retryPushMessage (event: Event, retryAttempts: number) {
retryAttempts = retryAttempts - 1;
queuePushMessage (event: Event, retryAttempts: number) {
this.pushMessageQueue.push({ event, retriesLeft: retryAttempts });
if (retryAttempts <= 0) {
return;
if (this.retryTimeout === null) {
this.retryTimeout = setTimeout(this.processWaitingPushMessages, 20);
}
},
/**
* Process the push messages which are waiting in the queue
*/
processWaitingPushMessages () {
if (this.retryTimeout !== null) {
clearTimeout(this.retryTimeout);
this.retryTimeout = null;
}
setTimeout(() => {
this.pushMessageReceived(event, retryAttempts);
}, 200);
const queueLength = this.pushMessageQueue.length;
for (let i = 0; i < queueLength; i++) {
const messageData = this.pushMessageQueue.shift();
if (this.pushMessageReceived(messageData!.event, true) === false) {
// Was not successful
messageData!.retriesLeft -= 1;
if (messageData!.retriesLeft > 0) {
// If still retries are left add it back and stop execution
this.pushMessageQueue.unshift(messageData!);
}
break;
}
}
if (this.pushMessageQueue.length !== 0 && this.retryTimeout === null) {
this.retryTimeout = setTimeout(this.processWaitingPushMessages, 25);
}
},
/**
* Process a newly received message
*
* @param {Event} event The event data with the message data
* @returns {void}
* @param {boolean} [isRetry] If it is a retry
* @returns {boolean} If message could be processed
*/
pushMessageReceived (event: Event, retryAttempts?: number): void {
retryAttempts = retryAttempts || 5;
pushMessageReceived (event: Event, isRetry?: boolean): boolean {
const retryAttempts = 5;
let receivedData: IPushData;
try {
// @ts-ignore
receivedData = JSON.parse(event.data);
} catch (error) {
console.error('The received push data is not valid JSON.'); // eslint-disable-line no-console
return;
return false;
}
if (!['testWebhookReceived'].includes(receivedData.type) && isRetry !== true && this.pushMessageQueue.length) {
// If there are already messages in the queue add the new one that all of them
// get executed in order
this.queuePushMessage(event, retryAttempts);
return false;
}
if (['nodeExecuteAfter', 'nodeExecuteBefore'].includes(receivedData.type)) {
if (this.$store.getters.isActionActive('workflowRunning') === false) {
// No workflow is running so ignore the messages
return;
return false;
}
const pushData = receivedData.data as IPushDataNodeExecuteBefore;
if (this.$store.getters.activeExecutionId !== pushData.executionId) {
// The data is not for the currently active execution or
// we do not have the execution id yet.
this.retryPushMessage(event, retryAttempts);
return;
if (isRetry !== true) {
this.queuePushMessage(event, retryAttempts);
}
return false;
}
}
@@ -148,14 +187,16 @@ export const pushConnection = mixins(
if (this.$store.getters.isActionActive('workflowRunning') === false) {
// No workflow is running so ignore the messages
return;
return false;
}
if (this.$store.getters.activeExecutionId !== pushData.executionIdActive) {
// The workflow which did finish execution did either not get started
// by this session or we do not have the execution id yet.
this.retryPushMessage(event, retryAttempts);
return;
if (isRetry !== true) {
this.queuePushMessage(event, retryAttempts);
}
return false;
}
const runDataExecuted = pushData.data;
@@ -231,7 +272,10 @@ export const pushConnection = mixins(
this.$store.commit('setExecutionWaitingForWebhook', false);
this.$store.commit('setActiveExecutionId', pushData.executionId);
}
this.processWaitingPushMessages();
}
return true;
},
},
});

View File

@@ -181,7 +181,7 @@ if (process.env.NODE_ENV !== 'production') {
// not do anything about it anyway
return;
}
console.error('error cought in main.ts'); // eslint-disable-line no-console
console.error('error caught in main.ts'); // eslint-disable-line no-console
console.error(message); // eslint-disable-line no-console
console.error(error); // eslint-disable-line no-console
};