From 326f346936e79e5da8a36fdb3a47e11aaff15a35 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Tue, 14 Jun 2022 22:54:00 +0200 Subject: [PATCH 1/8] Import default export if node is a transpiled es module --- packages/node_modules/@node-red/registry/lib/loader.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/node_modules/@node-red/registry/lib/loader.js b/packages/node_modules/@node-red/registry/lib/loader.js index fc508aa57..61f28ab86 100644 --- a/packages/node_modules/@node-red/registry/lib/loader.js +++ b/packages/node_modules/@node-red/registry/lib/loader.js @@ -359,6 +359,7 @@ function loadNodeSet(node) { try { var loadPromise = null; var r = require(node.file); + r = r.__esModule ? r.default : r if (typeof r === "function") { var red = registryUtil.createNodeApi(node); From 6c0d6c5425125d8dd89469eb7d6d4fc5f8e31479 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 15 Jun 2022 10:16:12 +0100 Subject: [PATCH 2/8] Join-reduce keep existing msg properties see https://discourse.nodered.org/t/no-response-object-after-split-join/63919 --- .../node_modules/@node-red/nodes/core/sequence/17-split.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/sequence/17-split.js b/packages/node_modules/@node-red/nodes/core/sequence/17-split.js index e158f344c..325cf85b5 100644 --- a/packages/node_modules/@node-red/nodes/core/sequence/17-split.js +++ b/packages/node_modules/@node-red/nodes/core/sequence/17-split.js @@ -314,11 +314,13 @@ module.exports = function(RED) { if (err) { return done(err); } - msgInfo.send({payload: result}); + msgInfo.msg.payload = result; + msgInfo.send(msgInfo.msg); done(); }); } else { - msgInfo.send({payload: result}); + msgInfo.msg.payload = result; + msgInfo.send(msgInfo.msg); done(); } } else { From 01d9affe61efbf35fdeb304985dfc5061d24299e Mon Sep 17 00:00:00 2001 From: cow0w Date: Fri, 17 Jun 2022 22:18:14 +0300 Subject: [PATCH 3/8] Add support for evalulating {{env.}} within a template node --- .../nodes/core/function/80-template.js | 24 +++++++++++++++++++ test/nodes/core/function/80-template_spec.js | 22 +++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/packages/node_modules/@node-red/nodes/core/function/80-template.js b/packages/node_modules/@node-red/nodes/core/function/80-template.js index d4c27cfd0..69954aba2 100644 --- a/packages/node_modules/@node-red/nodes/core/function/80-template.js +++ b/packages/node_modules/@node-red/nodes/core/function/80-template.js @@ -44,6 +44,14 @@ module.exports = function(RED) { return undefined; } + function parseEnv(key) { + var match = /^env\.(.+)/.exec(key); + if (match) { + return match[1]; + } + return undefined; + } + /** * Custom Mustache Context capable to collect message property and node * flow and global context @@ -74,6 +82,11 @@ module.exports = function(RED) { return value; } + // try env + if (parseEnv(name)) { + return this.cachedContextTokens[name]; + } + // try flow/global context: var context = parseContext(name); if (context) { @@ -156,6 +169,17 @@ module.exports = function(RED) { var tokens = extractTokens(mustache.parse(template)); var resolvedTokens = {}; tokens.forEach(function(name) { + var env_name = parseEnv(name); + if (env_name) { + var promise = new Promise((resolve, reject) => { + var val = RED.util.evaluateNodeProperty(env_name, 'env', node) + resolvedTokens[name] = val; + resolve(); + }); + promises.push(promise); + return; + } + var context = parseContext(name); if (context) { var type = context.type; diff --git a/test/nodes/core/function/80-template_spec.js b/test/nodes/core/function/80-template_spec.js index e944824b3..b4f530d05 100644 --- a/test/nodes/core/function/80-template_spec.js +++ b/test/nodes/core/function/80-template_spec.js @@ -144,6 +144,28 @@ describe('template node', function() { }); }); + describe('env var', function() { + before(function() { + process.env.TEST = 'xyzzy'; + }) + after(function() { + delete process.env.TEST; + }) + + it('should modify payload from env variable', function(done) { + var flow = [{id:"n1",z:"t1", type:"template", field:"payload", template:"payload={{env.TEST}}",wires:[["n2"]]},{id:"n2",z:"t1",type:"helper"}]; + helper.load(templateNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + n2.on("input", function(msg) { + msg.should.have.property('payload', 'payload=xyzzy'); + done(); + }); + n1.receive({payload:"foo",topic: "bar"}); + }); + }); + }); + it('should modify payload from flow context', function(done) { var flow = [{id:"n1",z:"t1", type:"template", field:"payload", template:"payload={{flow.value}}",wires:[["n2"]]},{id:"n2",z:"t1",type:"helper"}]; helper.load(templateNode, flow, function() { From 2ea10206faa4892426b8be3b0284ab1e96ad2cd7 Mon Sep 17 00:00:00 2001 From: Mauricio Bonani Date: Tue, 21 Jun 2022 11:43:02 -0400 Subject: [PATCH 4/8] Fix select box alignment --- .../node_modules/@node-red/nodes/core/common/20-inject.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/nodes/core/common/20-inject.html b/packages/node_modules/@node-red/nodes/core/common/20-inject.html index de3990a93..0fafa9df0 100644 --- a/packages/node_modules/@node-red/nodes/core/common/20-inject.html +++ b/packages/node_modules/@node-red/nodes/core/common/20-inject.html @@ -118,7 +118,7 @@ .inject-time-row { padding-left: 110px; } - .inject-time-row select { + .inject-time-row:not(#inject-time-row-interval) select { margin: 3px 0; } .inject-time-days label { From 5393fa81b906f1ba2c943e913a5d3c19e6707bff Mon Sep 17 00:00:00 2001 From: Mauricio Bonani Date: Sat, 25 Jun 2022 20:27:32 -0400 Subject: [PATCH 5/8] Leave Monaco theme commented out by default --- packages/node_modules/node-red/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/node-red/settings.js b/packages/node_modules/node-red/settings.js index d8f879851..99fa6437f 100644 --- a/packages/node_modules/node-red/settings.js +++ b/packages/node_modules/node-red/settings.js @@ -401,7 +401,7 @@ module.exports = { * packages/node_modules/@node-red/editor-client/src/vendor/monaco/dist/theme * e.g. "tomorrow-night", "upstream-sunburst", "github", "my-theme" */ - theme: "vs", + // theme: "vs", /** other overrides can be set e.g. fontSize, fontFamily, fontLigatures etc. * for the full list, see https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneEditorConstructionOptions.html */ From 78327716a4ed027582723fdc8094645513eed0d1 Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Sun, 26 Jun 2022 09:08:26 +0100 Subject: [PATCH 6/8] ensure workspace clean after undoing dropped node --- .../@node-red/editor-client/src/js/ui/view-tools.js | 5 +++-- .../node_modules/@node-red/editor-client/src/js/ui/view.js | 3 ++- .../node_modules/@node-red/nodes/core/common/21-debug.html | 2 +- .../node_modules/@node-red/nodes/core/common/60-link.html | 2 +- .../@node-red/nodes/core/function/10-function.html | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view-tools.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view-tools.js index 888fb4d7f..a781c44fc 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view-tools.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view-tools.js @@ -979,13 +979,14 @@ RED.view.tools = (function() { * - it uses ` ` - where N is the next available integer that * doesn't clash with any existing nodes of that type * @param {Object} node The node to set the name of - if not provided, uses current selection + * @param {{ renameBlank: boolean, renameClash: boolean, generateHistory: boolean }} options Possible options are `renameBlank`, `renameClash` and `generateHistory` */ function generateNodeNames(node, options) { - options = options || { + options = Object.assign({ renameBlank: true, renameClash: true, generateHistory: true - } + }, options) let nodes = node; if (node) { if (!Array.isArray(node)) { diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index b55244d0f..0ddc06a8c 100755 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -5872,6 +5872,7 @@ RED.view = (function() { * @private */ function createNode(type, x, y, z) { + const wasDirty = RED.nodes.dirty() var m = /^subflow:(.+)$/.exec(type); var activeSubflow = z ? RED.nodes.subflow(z) : null; if (activeSubflow && m) { @@ -5930,7 +5931,7 @@ RED.view = (function() { var historyEvent = { t: "add", nodes: [nn.id], - dirty: RED.nodes.dirty() + dirty: wasDirty } if (activeSubflow) { var subflowRefresh = RED.subflow.refresh(true); diff --git a/packages/node_modules/@node-red/nodes/core/common/21-debug.html b/packages/node_modules/@node-red/nodes/core/common/21-debug.html index 62da1b259..f861f518b 100644 --- a/packages/node_modules/@node-red/nodes/core/common/21-debug.html +++ b/packages/node_modules/@node-red/nodes/core/common/21-debug.html @@ -558,7 +558,7 @@ onadd: function() { if (this.name === '_DEFAULT_') { this.name = '' - RED.actions.invoke("core:generate-node-names", this) + RED.actions.invoke("core:generate-node-names", this, {generateHistory: false}) } } }); diff --git a/packages/node_modules/@node-red/nodes/core/common/60-link.html b/packages/node_modules/@node-red/nodes/core/common/60-link.html index f592bcd3d..4b8c9a3d6 100644 --- a/packages/node_modules/@node-red/nodes/core/common/60-link.html +++ b/packages/node_modules/@node-red/nodes/core/common/60-link.html @@ -221,7 +221,7 @@ function onAdd() { if (this.name === '_DEFAULT_') { this.name = '' - RED.actions.invoke("core:generate-node-names", this) + RED.actions.invoke("core:generate-node-names", this, {generateHistory: false}) } for (var i=0;i Date: Sun, 26 Jun 2022 11:52:55 +0100 Subject: [PATCH 7/8] use $node-port-background as config node icon background Makse sense since it contrasts the $node-port-label-color used for icon text Also, only show pointer if node icon has count --- .../@node-red/editor-client/src/sass/tab-config.scss | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/sass/tab-config.scss b/packages/node_modules/@node-red/editor-client/src/sass/tab-config.scss index 5c8d0ba94..f88fce07a 100644 --- a/packages/node_modules/@node-red/editor-client/src/sass/tab-config.scss +++ b/packages/node_modules/@node-red/editor-client/src/sass/tab-config.scss @@ -37,7 +37,7 @@ ul.red-ui-sidebar-node-config-list { } .red-ui-palette-node { overflow: hidden; - + cursor: default; &.selected { border-color: transparent; box-shadow: 0 0 0 2px $node-selected-color; @@ -58,7 +58,7 @@ ul.red-ui-sidebar-node-config-list { .red-ui-palette-icon-container { font-size: 12px; line-height: 30px; - background-color: $node-icon-background-color; + background-color: $node-port-background; border-top-right-radius: 4px; border-bottom-right-radius: 4px; a { @@ -68,6 +68,7 @@ ul.red-ui-sidebar-node-config-list { left: 0; right: 0; color: $node-port-label-color; + cursor: pointer; &:hover { text-decoration: none; background: $node-port-background-hover; From 125b37e98f6d33894593a907b3d25339791709f2 Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Sun, 26 Jun 2022 12:16:39 +0100 Subject: [PATCH 8/8] increase quick-add height to reveal 2 most recent fixes #3568 --- .../node_modules/@node-red/editor-client/src/sass/search.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/editor-client/src/sass/search.scss b/packages/node_modules/@node-red/editor-client/src/sass/search.scss index cce1e69e4..168bc7a94 100644 --- a/packages/node_modules/@node-red/editor-client/src/sass/search.scss +++ b/packages/node_modules/@node-red/editor-client/src/sass/search.scss @@ -54,7 +54,7 @@ } .red-ui-search-results-container { display: none; - height: 150px; + height: 195px; .red-ui-editableList-container { border: 1px dashed $primary-border-color; border-top: 1px solid $secondary-border-color;