From 0f0cb3ac6d1d1b2fa015ee1488655dfc15979a0f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 28 Oct 2021 12:14:03 +0100 Subject: [PATCH 1/3] Fix setting object env var properties so they can be undone --- .../src/js/ui/editors/panes/envVarProperties.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editors/panes/envVarProperties.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editors/panes/envVarProperties.js index 10425f18a..fb1d89b3f 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editors/panes/envVarProperties.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editors/panes/envVarProperties.js @@ -56,8 +56,12 @@ }); } if (!isSameObj(old_env, new_env)) { - node.env = new_env; editState.changes.env = node.env; + if (new_env.length === 0) { + delete node.env; + } else { + node.env = new_env; + } editState.changed = true; } } From b8ad6475e1e5b8d6f72d191b4852ef63b796e656 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 28 Oct 2021 12:14:34 +0100 Subject: [PATCH 2/3] Strip off env property if it is empty - avoid inflated flow files --- .../node_modules/@node-red/editor-client/src/js/nodes.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 76f544396..a7eea6caf 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -1097,6 +1097,11 @@ RED.nodes = (function() { // Until we know how that can happen, add a filter here to remove them node.nodes = node.nodes.filter(function(n) { return !!n }).map(function(n) { return n.id }); } + if (n.type === "tab" || n.type === "group") { + if (node.env && node.env.length === 0) { + delete node.env; + } + } if (n._def.category != "config") { node.x = n.x; node.y = n.y; From a38ebef100bdee166822d276bf59a189ab9f6e37 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 28 Oct 2021 12:14:56 +0100 Subject: [PATCH 3/3] Display group changes property in diff view --- .../@node-red/editor-client/src/js/ui/diff.js | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/diff.js b/packages/node_modules/@node-red/editor-client/src/js/ui/diff.js index 646fe326e..b6a069ab5 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/diff.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/diff.js @@ -554,6 +554,8 @@ RED.diff = (function() { color: "#DDAA99", defaults:{name:{value:""}} } + } else if (node.type === "group") { + def = RED.group.def; } else { def = {}; } @@ -763,16 +765,15 @@ RED.diff = (function() { } } - if (node.hasOwnProperty('x')) { if (localNode) { - if (localNode.x !== node.x || localNode.y !== node.y) { + if (localNode.x !== node.x || localNode.y !== node.y || localNode.w !== node.w || localNode.h !== node.h ) { localChanged = true; localChanges++; } } if (remoteNode) { - if (remoteNode.x !== node.x || remoteNode.y !== node.y) { + if (remoteNode.x !== node.x || remoteNode.y !== node.y|| remoteNode.w !== node.w || remoteNode.h !== node.h) { remoteChanged = true; remoteChanges++; } @@ -790,7 +791,12 @@ RED.diff = (function() { localCell.addClass("red-ui-diff-status-"+(localChanged?"changed":"unchanged")); $(''+(localChanged?'':'')+'').appendTo(localCell); element = $('').appendTo(localCell); - propertyElements['local.position'] = RED.utils.createObjectElement({x:localNode.x,y:localNode.y}, + var localPosition = {x:localNode.x,y:localNode.y}; + if (localNode.hasOwnProperty('w')) { + localPosition.w = localNode.w; + localPosition.h = localNode.h; + } + propertyElements['local.position'] = RED.utils.createObjectElement(localPosition, { path: "position", exposeApi: true, @@ -811,7 +817,12 @@ RED.diff = (function() { if (remoteNode) { $(''+(remoteChanged?'':'')+'').appendTo(remoteCell); element = $('').appendTo(remoteCell); - propertyElements['remote.position'] = RED.utils.createObjectElement({x:remoteNode.x,y:remoteNode.y}, + var remotePosition = {x:remoteNode.x,y:remoteNode.y}; + if (remoteNode.hasOwnProperty('w')) { + remotePosition.w = remoteNode.w; + remotePosition.h = remoteNode.h; + } + propertyElements['remote.position'] = RED.utils.createObjectElement(remotePosition, { path: "position", exposeApi: true, @@ -883,11 +894,11 @@ RED.diff = (function() { } } } - var properties = Object.keys(node).filter(function(p) { return p!='inputLabels'&&p!='outputLabels'&&p!='z'&&p!='wires'&&p!=='x'&&p!=='y'&&p!=='id'&&p!=='type'&&(!def.defaults||!def.defaults.hasOwnProperty(p))}); + var properties = Object.keys(node).filter(function(p) { return p!='inputLabels'&&p!='outputLabels'&&p!='z'&&p!='wires'&&p!=='x'&&p!=='y'&&p!=='w'&&p!=='h'&&p!=='id'&&p!=='type'&&(!def.defaults||!def.defaults.hasOwnProperty(p))}); if (def.defaults) { properties = properties.concat(Object.keys(def.defaults)); } - if (node.type !== 'tab') { + if (node.type !== 'tab' && node.type !== "group") { properties = properties.concat(['inputLabels','outputLabels']); } if ( ((localNode && localNode.hasOwnProperty('icon')) || (remoteNode && remoteNode.hasOwnProperty('icon'))) &&