From 2da1554caa09c3ba6937ed5078403a59c830d503 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Tue, 18 Feb 2020 21:38:32 +0900 Subject: [PATCH 1/2] update message catalogue for subflow UI --- .../@node-red/editor-client/locales/en-US/editor.json | 3 ++- .../@node-red/editor-client/locales/ja/editor.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index 7977a5752..6c9196577 100755 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -351,7 +351,8 @@ "bool": "bool", "json": "JSON", "bin": "buffer", - "env": "env variable" + "env": "env variable", + "cred": "credential" }, "menu": { "input": "input", diff --git a/packages/node_modules/@node-red/editor-client/locales/ja/editor.json b/packages/node_modules/@node-red/editor-client/locales/ja/editor.json index cf04ced1d..656ec764e 100755 --- a/packages/node_modules/@node-red/editor-client/locales/ja/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/ja/editor.json @@ -351,7 +351,8 @@ "bool": "真偽", "json": "JSON", "bin": "バッファ", - "env": "環境変数" + "env": "環境変数", + "cred": "認証情報" }, "menu": { "input": "入力", From 8405826fab39cf55596ff064221e0f37170f506e Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 24 Feb 2020 21:17:54 +0000 Subject: [PATCH 2/2] Ensure trigger sends complete 2nd msg if set to send latest msg and add test to close #2474 --- .../@node-red/nodes/core/function/89-trigger.js | 13 ++++++++----- test/nodes/core/function/89-trigger_spec.js | 8 +++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/function/89-trigger.js b/packages/node_modules/@node-red/nodes/core/function/89-trigger.js index 48a595ccc..d84bf57a8 100644 --- a/packages/node_modules/@node-red/nodes/core/function/89-trigger.js +++ b/packages/node_modules/@node-red/nodes/core/function/89-trigger.js @@ -106,7 +106,9 @@ module.exports = function(RED) { }); } + var npay; this.on('input', function(msg) { + if (node.op2type === "payl") { npay = RED.util.cloneMessage(msg); } processMessageQueue(msg); }); @@ -124,7 +126,7 @@ module.exports = function(RED) { else { if (((!node.topics[topic].tout) && (node.topics[topic].tout !== 0)) || (node.loop === true)) { promise = Promise.resolve(); - if (node.op2type === "pay" || node.op2type === "payl") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); } + if (node.op2type === "pay") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); } else if (node.op2Templated) { node.topics[topic].m2 = mustache.render(node.op2,msg); } else if (node.op2type !== "nul") { promise = new Promise((resolve,reject) => { @@ -188,7 +190,8 @@ module.exports = function(RED) { promise.then(() => { msg2.payload = node.topics[topic].m2; delete node.topics[topic]; - node.send(msg2); + if (node.op2type === "payl") { node.send(npay); } + else { node.send(msg2); } node.status({}); }).catch(err => { node.error(err); @@ -244,9 +247,9 @@ module.exports = function(RED) { }); }, node.duration); } - else { - if (node.op2type === "payl") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); } - } + // else { + // if (node.op2type === "payl") {node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); } + // } } return Promise.resolve(); } diff --git a/test/nodes/core/function/89-trigger_spec.js b/test/nodes/core/function/89-trigger_spec.js index 5f7bfc2d1..be0094ccf 100644 --- a/test/nodes/core/function/89-trigger_spec.js +++ b/test/nodes/core/function/89-trigger_spec.js @@ -736,10 +736,12 @@ describe('trigger node', function() { try { if (c === 0) { msg.should.have.a.property("payload", "Goodbye"); + msg.should.have.a.property("topic", "test2"); c += 1; } else { msg.should.have.a.property("payload", "World"); + msg.should.have.a.property("topic", "test3"); (Date.now() - ss).should.be.greaterThan(70); done(); } @@ -747,12 +749,12 @@ describe('trigger node', function() { catch(err) { done(err); } }); var ss = Date.now(); - n1.emit("input", {payload:"Hello"}); + n1.emit("input", {payload:"Hello", topic:"test1"}); setTimeout( function() { - n1.emit("input", {payload:"Goodbye"}); + n1.emit("input", {payload:"Goodbye", topic:"test2"}); },20); setTimeout( function() { - n1.emit("input", {payload:"World"}); + n1.emit("input", {payload:"World", topic:"test3"}); },80); }); });