@node-red/editor-client 4.0.6 → 4.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/editor-client",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
package/public/red/about CHANGED
@@ -1,3 +1,11 @@
1
+ #### 4.0.7: Maintenance Release
2
+
3
+ Editor
4
+
5
+ - Fix def can be undefined if the type is missing (#4997) @GogoVega
6
+ - Fix the user list of nested config node (#4995) @GogoVega
7
+ - Support custom login message and button (#4993) @knolleary
8
+
1
9
  #### 4.0.6: Maintenance Release
2
10
 
3
11
  Editor
package/public/red/red.js CHANGED
@@ -1834,6 +1834,37 @@ RED.user = (function() {
1834
1834
  }
1835
1835
 
1836
1836
 
1837
+ } else {
1838
+ if (data.prompts) {
1839
+ if (data.loginMessage) {
1840
+ const sessionMessages = $("<div/>",{class:"form-row",style:"text-align: center"}).appendTo("#node-dialog-login-fields");
1841
+ $('<div>').text(data.loginMessage).appendTo(sessionMessages);
1842
+ }
1843
+
1844
+ i = 0;
1845
+ for (;i<data.prompts.length;i++) {
1846
+ var field = data.prompts[i];
1847
+ var row = $("<div/>",{class:"form-row",style:"text-align: center"}).appendTo("#node-dialog-login-fields");
1848
+ var loginButton = $('<a href="#" class="red-ui-button"></a>',{style: "padding: 10px"}).appendTo(row).on("click", function() {
1849
+ document.location = field.url;
1850
+ });
1851
+ if (field.image) {
1852
+ $("<img>",{src:field.image}).appendTo(loginButton);
1853
+ } else if (field.label) {
1854
+ var label = $('<span></span>').text(field.label);
1855
+ if (field.icon) {
1856
+ $('<i></i>',{class: "fa fa-2x "+field.icon, style:"vertical-align: middle"}).appendTo(loginButton);
1857
+ label.css({
1858
+ "verticalAlign":"middle",
1859
+ "marginLeft":"8px"
1860
+ });
1861
+
1862
+ }
1863
+ label.appendTo(loginButton);
1864
+ }
1865
+ loginButton.button();
1866
+ }
1867
+ }
1837
1868
  }
1838
1869
  if (opts.cancelable) {
1839
1870
  $("#node-dialog-login-cancel").button().on("click", function( event ) {
@@ -5129,12 +5160,15 @@ RED.nodes = (function() {
5129
5160
  }
5130
5161
  n["_"] = RED._;
5131
5162
  }
5163
+
5164
+ // Both node and config node can use a config node
5165
+ updateConfigNodeUsers(newNode, { action: "add" });
5166
+
5132
5167
  if (n._def.category == "config") {
5133
5168
  configNodes[n.id] = newNode;
5134
5169
  } else {
5135
5170
  if (n.wires && (n.wires.length > n.outputs)) { n.outputs = n.wires.length; }
5136
5171
  n.dirty = true;
5137
- updateConfigNodeUsers(newNode, { action: "add" });
5138
5172
  if (n._def.category == "subflows" && typeof n.i === "undefined") {
5139
5173
  var nextId = 0;
5140
5174
  RED.nodes.eachNode(function(node) {
@@ -5196,9 +5230,11 @@ RED.nodes = (function() {
5196
5230
  var removedLinks = [];
5197
5231
  var removedNodes = [];
5198
5232
  var node;
5233
+
5199
5234
  if (id in configNodes) {
5200
5235
  node = configNodes[id];
5201
5236
  delete configNodes[id];
5237
+ updateConfigNodeUsers(node, { action: "remove" });
5202
5238
  RED.events.emit('nodes:remove',node);
5203
5239
  RED.workspaces.refresh();
5204
5240
  } else if (allNodes.hasNode(id)) {
@@ -5208,6 +5244,8 @@ RED.nodes = (function() {
5208
5244
  removedLinks = links.filter(function(l) { return (l.source === node) || (l.target === node); });
5209
5245
  removedLinks.forEach(removeLink);
5210
5246
  updateConfigNodeUsers(node, { action: "remove" });
5247
+
5248
+ // TODO: Legacy code for exclusive config node
5211
5249
  var updatedConfigNode = false;
5212
5250
  for (var d in node._def.defaults) {
5213
5251
  if (node._def.defaults.hasOwnProperty(d)) {
@@ -6609,6 +6647,21 @@ RED.nodes = (function() {
6609
6647
  }
6610
6648
  }
6611
6649
 
6650
+ // Config node can use another config node, must ensure that this other
6651
+ // config node is added before to exists when updating the user list
6652
+ const configNodeFilter = function (node) {
6653
+ let count = 0;
6654
+ if (node._def?.defaults) {
6655
+ for (const def of Object.values(node._def.defaults)) {
6656
+ if (def.type) {
6657
+ count++;
6658
+ }
6659
+ }
6660
+ }
6661
+ return count;
6662
+ };
6663
+ new_nodes.sort((a, b) => configNodeFilter(a) - configNodeFilter(b));
6664
+
6612
6665
  // Find regular flow nodes and subflow instances
6613
6666
  for (i=0;i<newNodes.length;i++) {
6614
6667
  n = newNodes[i];
@@ -6779,13 +6832,13 @@ RED.nodes = (function() {
6779
6832
  node.type = "unknown";
6780
6833
  }
6781
6834
  if (node._def.category != "config") {
6782
- if (n.hasOwnProperty('inputs') && def.defaults.hasOwnProperty("inputs")) {
6835
+ if (n.hasOwnProperty('inputs') && node._def.defaults.hasOwnProperty("inputs")) {
6783
6836
  node.inputs = parseInt(n.inputs, 10);
6784
6837
  node._config.inputs = JSON.stringify(n.inputs);
6785
6838
  } else {
6786
6839
  node.inputs = node._def.inputs;
6787
6840
  }
6788
- if (n.hasOwnProperty('outputs') && def.defaults.hasOwnProperty("outputs")) {
6841
+ if (n.hasOwnProperty('outputs') && node._def.defaults.hasOwnProperty("outputs")) {
6789
6842
  node.outputs = parseInt(n.outputs, 10);
6790
6843
  node._config.outputs = JSON.stringify(n.outputs);
6791
6844
  } else {
@@ -7146,6 +7199,7 @@ RED.nodes = (function() {
7146
7199
  var property = node._def.defaults[d];
7147
7200
  if (property.type) {
7148
7201
  var type = registry.getNodeType(property.type);
7202
+ // Need to ensure the type is a config node to not treat links nodes
7149
7203
  if (type && type.category == "config") {
7150
7204
  var configNode = configNodes[node[d]];
7151
7205
  if (configNode) {