From 2433d59f00da6f7eca82231265b2b0fff9d13318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Fri, 21 Jun 2019 17:40:24 -0400 Subject: [PATCH 1/7] Add default shortcut (ctrl-s) for deploy This adds a shortcut for deploy (ctrl-s). --- packages/node_modules/@node-red/editor-client/src/js/keymap.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/node_modules/@node-red/editor-client/src/js/keymap.json b/packages/node_modules/@node-red/editor-client/src/js/keymap.json index 2db2d4836..335bd298b 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/keymap.json +++ b/packages/node_modules/@node-red/editor-client/src/js/keymap.json @@ -8,6 +8,7 @@ "ctrl-0": "core:zoom-reset", "ctrl-enter": "core:confirm-edit-tray", "ctrl-escape": "core:cancel-edit-tray", + "ctrl-s": "core:deploy-flows", "ctrl-g i": "core:show-info-tab", "ctrl-g d": "core:show-debug-tab", "ctrl-g c": "core:show-config-tab", From e4d3ff623a04058641e4ed55a99ffae2cd3f4828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Fri, 21 Jun 2019 19:04:25 -0400 Subject: [PATCH 2/7] change shortcut for ctrl-d --- .../node_modules/@node-red/editor-client/src/js/keymap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/keymap.json b/packages/node_modules/@node-red/editor-client/src/js/keymap.json index 335bd298b..ad3307ac7 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/keymap.json +++ b/packages/node_modules/@node-red/editor-client/src/js/keymap.json @@ -8,7 +8,7 @@ "ctrl-0": "core:zoom-reset", "ctrl-enter": "core:confirm-edit-tray", "ctrl-escape": "core:cancel-edit-tray", - "ctrl-s": "core:deploy-flows", + "ctrl-d": "core:deploy-flows", "ctrl-g i": "core:show-info-tab", "ctrl-g d": "core:show-debug-tab", "ctrl-g c": "core:show-config-tab", From d918bb568c80e063b3006532e9e6e527c01ac243 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 23 Jun 2019 12:09:43 +0100 Subject: [PATCH 3/7] Ignore empty examples directories (don't add to import menu) --- packages/node_modules/@node-red/registry/lib/library.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/registry/lib/library.js b/packages/node_modules/@node-red/registry/lib/library.js index 1eea6ed56..fcb5e1eac 100644 --- a/packages/node_modules/@node-red/registry/lib/library.js +++ b/packages/node_modules/@node-red/registry/lib/library.js @@ -51,7 +51,9 @@ function getFlowsFromPath(path) { } i++; }) - + if (!result.hasOwnProperty("f")) { + reject(result); + } resolve(result); }) }); @@ -63,7 +65,7 @@ function addNodeExamplesDir(module,path) { return getFlowsFromPath(path).then(function(result) { exampleFlows = exampleFlows||{}; exampleFlows[module] = result; - }); + }, function() { return; }); } function removeNodeExamplesDir(module) { delete exampleRoots[module]; From 55645e3730abcb9e73a9e52ce6f03c1355d2acff Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 28 Jun 2019 22:39:27 +0100 Subject: [PATCH 4/7] Properly escape node types in palette We were only escaping the first instance of any invalid dom char and not all of the --- .../node_modules/@node-red/editor-client/src/js/ui/palette.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js b/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js index ebfd7413b..28d5af46e 100755 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js @@ -150,7 +150,7 @@ RED.palette = (function() { } function escapeNodeType(nt) { - return nt.replace(" ","_").replace(".","_").replace(":","_"); + return nt.replace(/[ .:]/g,"_"); } function addNodeType(nt,def) { From c4f4115bcbce847f89e8997c5d859b886969cf48 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sat, 29 Jun 2019 01:16:02 +0100 Subject: [PATCH 5/7] better handle example file at any depth --- packages/node_modules/@node-red/registry/lib/library.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/node_modules/@node-red/registry/lib/library.js b/packages/node_modules/@node-red/registry/lib/library.js index fcb5e1eac..a8ca8a775 100644 --- a/packages/node_modules/@node-red/registry/lib/library.js +++ b/packages/node_modules/@node-red/registry/lib/library.js @@ -51,9 +51,6 @@ function getFlowsFromPath(path) { } i++; }) - if (!result.hasOwnProperty("f")) { - reject(result); - } resolve(result); }) }); @@ -63,9 +60,10 @@ function getFlowsFromPath(path) { function addNodeExamplesDir(module,path) { exampleRoots[module] = path; return getFlowsFromPath(path).then(function(result) { + if (JSON.stringify(result).indexOf('{"f":') === -1) { return; } exampleFlows = exampleFlows||{}; exampleFlows[module] = result; - }, function() { return; }); + }); } function removeNodeExamplesDir(module) { delete exampleRoots[module]; From 8b3b541a56d8a3dc6d1b7ba9e8c624e37e03d4d2 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 1 Jul 2019 11:14:21 +0100 Subject: [PATCH 6/7] Improve typedInput label width calculation If the label contains an img, the width calculation needs to wait for the img to be loaded. This fix is a bit hacky as it doesn't actually tie into the onload event, but should be good enough --- .../src/js/ui/common/typedInput.js | 96 ++++++++++--------- .../src/sass/ui/common/typedInput.scss | 3 + 2 files changed, 52 insertions(+), 47 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js index 0ef5b2102..daef61f64 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js @@ -439,21 +439,27 @@ }) }); }, - _getLabelWidth: function(label) { + _getLabelWidth: function(label, done) { var labelWidth = label.outerWidth(); if (labelWidth === 0) { - var container = $('
').css({ + var wrapper = $('
').css({ position:"absolute", "white-space": "nowrap", - top:0 + top:-2000 }).appendTo(document.body); + var container = $('
').appendTo(wrapper); var newTrigger = label.clone().appendTo(container); - labelWidth = newTrigger.outerWidth(); - container.remove(); + setTimeout(function() { + labelWidth = newTrigger.outerWidth(); + wrapper.remove(); + done(labelWidth); + },50) + } else { + done(labelWidth); } - return labelWidth; }, _resize: function() { + var that = this; if (this.uiWidth !== null) { this.uiSelect.width(this.uiWidth); } @@ -462,47 +468,44 @@ this.selectTrigger.addClass("red-ui-typedInput-full-width"); } else { this.selectTrigger.removeClass("red-ui-typedInput-full-width"); - var labelWidth = this._getLabelWidth(this.selectTrigger); - this.elementDiv.css('left',labelWidth+"px"); - this.valueLabelContainer.css('left',labelWidth+"px"); - if (this.optionExpandButton.is(":visible")) { - this.elementDiv.css('right',"22px"); - this.valueLabelContainer.css('right',"22px"); - } else { - this.elementDiv.css('right','0'); - this.valueLabelContainer.css('right','0'); - this.input.css({ - 'border-top-right-radius': '4px', - 'border-bottom-right-radius': '4px' - }); - } - - // if (this.optionSelectTrigger) { - // this.optionSelectTrigger.css({'left':(labelWidth)+"px",'width':'calc( 100% - '+labelWidth+'px )'}); - // } - - if (this.optionSelectTrigger) { - if (type && type.options && type.hasValue === true) { - this.optionSelectLabel.css({'left':'auto'}) - var lw = this._getLabelWidth(this.optionSelectLabel); - this.optionSelectTrigger.css({'width':(23+lw)+"px"}); - this.elementDiv.css('right',(23+lw)+"px"); - this.input.css({ - 'border-top-right-radius': 0, - 'border-bottom-right-radius': 0 - }); + this._getLabelWidth(this.selectTrigger, function(labelWidth) { + that.elementDiv.css('left',labelWidth+"px"); + that.valueLabelContainer.css('left',labelWidth+"px"); + if (that.optionExpandButton.is(":visible")) { + that.elementDiv.css('right',"22px"); + that.valueLabelContainer.css('right',"22px"); } else { - this.optionSelectLabel.css({'left':'0'}) - this.optionSelectTrigger.css({'width':'calc( 100% - '+labelWidth+'px )'}); - if (!this.optionExpandButton.is(":visible")) { - this.elementDiv.css({'right':0}); - this.input.css({ - 'border-top-right-radius': '4px', - 'border-bottom-right-radius': '4px' + that.elementDiv.css('right','0'); + that.valueLabelContainer.css('right','0'); + that.input.css({ + 'border-top-right-radius': '4px', + 'border-bottom-right-radius': '4px' + }); + } + if (that.optionSelectTrigger) { + if (type && type.options && type.hasValue === true) { + that.optionSelectLabel.css({'left':'auto'}) + that._getLabelWidth(that.optionSelectLabel, function(lw) { + that.optionSelectTrigger.css({'width':(23+lw)+"px"}); + that.elementDiv.css('right',(23+lw)+"px"); + that.input.css({ + 'border-top-right-radius': 0, + 'border-bottom-right-radius': 0 + }); }); + } else { + that.optionSelectLabel.css({'left':'0'}) + that.optionSelectTrigger.css({'width':'calc( 100% - '+labelWidth+'px )'}); + if (!that.optionExpandButton.is(":visible")) { + that.elementDiv.css({'right':0}); + that.input.css({ + 'border-top-right-radius': '4px', + 'border-bottom-right-radius': '4px' + }); + } } } - } + }); } }, _updateOptionSelectLabel: function(o) { @@ -624,6 +627,8 @@ } else if (opt.icon.indexOf("/") !== -1) { image = new Image(); + image.onload = function() { that._resize(); } + image.onerror = function() { that._resize(); } image.name = opt.icon; image.src = mapDeprecatedIcon(opt.icon); $('',{src:mapDeprecatedIcon(opt.icon),style:"margin-right: 4px;height: 18px;"}).prependTo(this.selectLabel); @@ -766,10 +771,7 @@ } this.input.trigger('change',this.propertyType,this.value()); } - if (image) { - image.onload = function() { that._resize(); } - image.onerror = function() { that._resize(); } - } else { + if (!image) { this._resize(); } } diff --git a/packages/node_modules/@node-red/editor-client/src/sass/ui/common/typedInput.scss b/packages/node_modules/@node-red/editor-client/src/sass/ui/common/typedInput.scss index f4746340a..63e5e0d2d 100644 --- a/packages/node_modules/@node-red/editor-client/src/sass/ui/common/typedInput.scss +++ b/packages/node_modules/@node-red/editor-client/src/sass/ui/common/typedInput.scss @@ -90,6 +90,9 @@ display: inline-block; height: 100%; padding: 0 1px 0 5px; + img { + max-width: none; + } } &:not(.disabled):hover { From f49d1ae8602c618f2e2e3707f3353389a3dd7dd8 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 1 Jul 2019 12:42:11 +0100 Subject: [PATCH 7/7] Ensure the subflow stop promise is waiting for before restarting --- packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js index 8b0341463..466c1341a 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js @@ -277,7 +277,7 @@ class Flow { if (this.subflowInstanceNodes[stopList[i]]) { try { (function(subflow) { - promises.push(stopNode(node,false).then(() => { subflow.stop() })); + promises.push(stopNode(node,false).then(() => subflow.stop())); })(this.subflowInstanceNodes[stopList[i]]); } catch(err) { node.error(err);