@node-red/nodes 3.0.0-beta.4 → 3.0.0
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.
|
@@ -245,44 +245,37 @@
|
|
|
245
245
|
// complete parentage of the node that generated this message.
|
|
246
246
|
// flow-id/subflow-A-instance/subflow-B-instance
|
|
247
247
|
|
|
248
|
-
// If it has one id, that is a top level flow
|
|
248
|
+
// If it has one id, that is a top level flow or config node/global
|
|
249
249
|
// each subsequent id is the instance id of a subflow node
|
|
250
250
|
//
|
|
251
251
|
pathParts = o.path.split("/");
|
|
252
252
|
if (pathParts.length === 1) {
|
|
253
|
-
// The source node is on a flow - so can use its id to find
|
|
253
|
+
// The source node is on a flow or is a global/config - so can use its id to find
|
|
254
254
|
sourceNode = RED.nodes.node(o.id);
|
|
255
255
|
} else if (pathParts.length > 1) {
|
|
256
256
|
// Highlight the subflow instance node.
|
|
257
257
|
sourceNode = RED.nodes.node(pathParts[1]);
|
|
258
258
|
}
|
|
259
|
+
const getNodeLabel = (n) => n.name || (typeof n.label === "function" && n.label()) || (typeof n.label === "string" && n.label) || (n.type + ":" + n.id);
|
|
259
260
|
pathHierarchy = pathParts.map((id,index) => {
|
|
260
261
|
if (index === 0) {
|
|
261
|
-
|
|
262
|
-
id: id,
|
|
263
|
-
|
|
264
|
-
}
|
|
262
|
+
if (id === "global") {
|
|
263
|
+
return { id: sourceNode.id, label: getNodeLabel(sourceNode) }
|
|
264
|
+
}
|
|
265
|
+
return { id: id, label: RED.nodes.workspace(id).label } //flow id + name
|
|
265
266
|
} else {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
label: (instanceNode.name || RED.nodes.subflow(instanceNode.type.substring(8)).name)
|
|
270
|
-
}
|
|
267
|
+
const instanceNode = RED.nodes.node(id)
|
|
268
|
+
const pathLabel = (instanceNode.name || RED.nodes.subflow(instanceNode.type.substring(8)).name)
|
|
269
|
+
return { id: id, label: pathLabel }
|
|
271
270
|
}
|
|
272
271
|
})
|
|
273
|
-
if (pathParts.length === 1) {
|
|
274
|
-
pathHierarchy.push({
|
|
275
|
-
id: o.id,
|
|
276
|
-
label: sourceNode.name || sourceNode.type+":"+sourceNode.id
|
|
277
|
-
})
|
|
272
|
+
if (pathParts.length === 1 && pathParts[0] !== "global") {
|
|
273
|
+
pathHierarchy.push({ id: o.id, label: getNodeLabel(sourceNode) })
|
|
278
274
|
}
|
|
279
275
|
if (o._alias) {
|
|
280
276
|
let aliasNode = RED.nodes.node(o._alias)
|
|
281
277
|
if (aliasNode) {
|
|
282
|
-
pathHierarchy.push({
|
|
283
|
-
id: o._alias,
|
|
284
|
-
label: aliasNode.name || aliasNode.type+":"+aliasNode.id
|
|
285
|
-
})
|
|
278
|
+
pathHierarchy.push({ id: o._alias, label: getNodeLabel(aliasNode) })
|
|
286
279
|
}
|
|
287
280
|
}
|
|
288
281
|
} else {
|
package/core/common/60-link.js
CHANGED
|
@@ -29,23 +29,23 @@ module.exports = function(RED) {
|
|
|
29
29
|
"use strict";
|
|
30
30
|
const crypto = require("crypto");
|
|
31
31
|
const targetCache = (function () {
|
|
32
|
-
|
|
33
|
-
function getIndex(/** @type {[LinkTarget]}*/ targets, id) {
|
|
32
|
+
let registry = { id: {}, name: {} }
|
|
33
|
+
function getIndex (/** @type {[LinkTarget]} */ targets, id) {
|
|
34
34
|
for (let index = 0; index < (targets || []).length; index++) {
|
|
35
|
-
const element = targets[index]
|
|
35
|
+
const element = targets[index]
|
|
36
36
|
if (element.id === id) {
|
|
37
|
-
return index
|
|
37
|
+
return index
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
return -1
|
|
40
|
+
return -1
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Generate a target object from a node
|
|
44
|
-
* @param {LinkInNode} node
|
|
44
|
+
* @param {LinkInNode} node
|
|
45
45
|
* @returns {LinkTarget} a link target object
|
|
46
46
|
*/
|
|
47
|
-
function generateTarget(node) {
|
|
48
|
-
const isSubFlow = node._flow.TYPE ===
|
|
47
|
+
function generateTarget (node) {
|
|
48
|
+
const isSubFlow = node._flow.TYPE === 'subflow'
|
|
49
49
|
return {
|
|
50
50
|
id: node.id,
|
|
51
51
|
name: node.name || node.id,
|
|
@@ -58,72 +58,72 @@ module.exports = function(RED) {
|
|
|
58
58
|
/**
|
|
59
59
|
* Get a list of targets registerd to this name
|
|
60
60
|
* @param {string} name Name of the target
|
|
61
|
-
* @param {boolean} [excludeSubflows] set `true` to exclude
|
|
61
|
+
* @param {boolean} [excludeSubflows] set `true` to exclude
|
|
62
62
|
* @returns {[LinkTarget]} Targets registerd to this name.
|
|
63
63
|
*/
|
|
64
|
-
getTargets(name, excludeSubflows) {
|
|
65
|
-
const targets = registry.name[name] || []
|
|
64
|
+
getTargets (name, excludeSubflows) {
|
|
65
|
+
const targets = registry.name[name] || []
|
|
66
66
|
if (excludeSubflows) {
|
|
67
|
-
return targets.filter(e => e.isSubFlow
|
|
67
|
+
return targets.filter(e => e.isSubFlow !== true)
|
|
68
68
|
}
|
|
69
|
-
return targets
|
|
69
|
+
return targets
|
|
70
70
|
},
|
|
71
71
|
/**
|
|
72
72
|
* Get a single target by registered name.
|
|
73
73
|
* To restrict to a single flow, include the `flowId`
|
|
74
74
|
* If there is no targets OR more than one target, null is returned
|
|
75
75
|
* @param {string} name Name of the node
|
|
76
|
-
* @param {string} [flowId]
|
|
76
|
+
* @param {string} [flowId]
|
|
77
77
|
* @returns {LinkTarget} target
|
|
78
78
|
*/
|
|
79
|
-
getTarget(name, flowId) {
|
|
80
|
-
/** @type {[LinkTarget]}*/
|
|
81
|
-
let possibleTargets = this.getTargets(name)
|
|
82
|
-
/** @type {LinkTarget}*/
|
|
83
|
-
let target
|
|
79
|
+
getTarget (name, flowId) {
|
|
80
|
+
/** @type {[LinkTarget]} */
|
|
81
|
+
let possibleTargets = this.getTargets(name)
|
|
82
|
+
/** @type {LinkTarget} */
|
|
83
|
+
let target
|
|
84
84
|
if (possibleTargets.length && flowId) {
|
|
85
|
-
possibleTargets = possibleTargets.filter(e => e.flowId
|
|
85
|
+
possibleTargets = possibleTargets.filter(e => e.flowId === flowId)
|
|
86
86
|
}
|
|
87
87
|
if (possibleTargets.length === 1) {
|
|
88
|
-
target = possibleTargets[0]
|
|
88
|
+
target = possibleTargets[0]
|
|
89
89
|
}
|
|
90
|
-
return target
|
|
90
|
+
return target
|
|
91
91
|
},
|
|
92
92
|
/**
|
|
93
93
|
* Get a target by node ID
|
|
94
94
|
* @param {string} nodeId ID of the node
|
|
95
95
|
* @returns {LinkTarget} target
|
|
96
96
|
*/
|
|
97
|
-
getTargetById(nodeId) {
|
|
98
|
-
return registry.id[nodeId]
|
|
97
|
+
getTargetById (nodeId) {
|
|
98
|
+
return registry.id[nodeId]
|
|
99
99
|
},
|
|
100
|
-
register(/** @type {LinkInNode} */ node) {
|
|
101
|
-
const target = generateTarget(node)
|
|
102
|
-
const tByName = this.getTarget(target.name, target.flowId)
|
|
100
|
+
register (/** @type {LinkInNode} */ node) {
|
|
101
|
+
const target = generateTarget(node)
|
|
102
|
+
const tByName = this.getTarget(target.name, target.flowId)
|
|
103
103
|
if (!tByName || tByName.id !== target.id) {
|
|
104
|
-
registry.name[target.name] = registry.name[target.name] || []
|
|
104
|
+
registry.name[target.name] = registry.name[target.name] || []
|
|
105
105
|
registry.name[target.name].push(target)
|
|
106
106
|
}
|
|
107
|
-
registry.id[target.id] = target
|
|
108
|
-
return target
|
|
107
|
+
registry.id[target.id] = target
|
|
108
|
+
return target
|
|
109
109
|
},
|
|
110
|
-
remove(node) {
|
|
111
|
-
const target = generateTarget(node)
|
|
112
|
-
const targs = this.getTargets(target.name)
|
|
113
|
-
const idx = getIndex(targs, target.id)
|
|
110
|
+
remove (node) {
|
|
111
|
+
const target = generateTarget(node)
|
|
112
|
+
const targs = this.getTargets(target.name)
|
|
113
|
+
const idx = getIndex(targs, target.id)
|
|
114
114
|
if (idx > -1) {
|
|
115
|
-
targs.splice(idx, 1)
|
|
115
|
+
targs.splice(idx, 1)
|
|
116
116
|
}
|
|
117
117
|
if (targs.length === 0) {
|
|
118
|
-
delete registry.name[
|
|
118
|
+
delete registry.name[target.name]
|
|
119
119
|
}
|
|
120
|
-
delete registry.id[target.id]
|
|
120
|
+
delete registry.id[target.id]
|
|
121
121
|
},
|
|
122
|
-
clear() {
|
|
123
|
-
registry = { id: {}, name: {} }
|
|
122
|
+
clear () {
|
|
123
|
+
registry = { id: {}, name: {} }
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
})()
|
|
126
|
+
})()
|
|
127
127
|
|
|
128
128
|
function LinkInNode(n) {
|
|
129
129
|
RED.nodes.createNode(this,n);
|
|
@@ -459,30 +459,38 @@ RED.debug = (function() {
|
|
|
459
459
|
function showMessageMenu(button,dbgMessage,sourceId) {
|
|
460
460
|
activeMenuMessage = dbgMessage;
|
|
461
461
|
if (!menuOptionMenu) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
462
|
+
var opts = [
|
|
463
|
+
{id:"red-ui-debug-msg-menu-item-collapse",label:RED._("node-red:debug.messageMenu.collapseAll"),onselect:function(){
|
|
464
|
+
activeMenuMessage.collapse();
|
|
465
|
+
}},
|
|
466
|
+
];
|
|
467
|
+
if (activeMenuMessage.clearPinned) {
|
|
468
|
+
opts.push(
|
|
467
469
|
{id:"red-ui-debug-msg-menu-item-clear-pins",label:RED._("node-red:debug.messageMenu.clearPinned"),onselect:function(){
|
|
468
470
|
activeMenuMessage.clearPinned();
|
|
469
471
|
}},
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
opts.push(
|
|
475
|
+
null,
|
|
476
|
+
{id:"red-ui-debug-msg-menu-item-filter", label:RED._("node-red:debug.messageMenu.filterNode"),onselect:function(){
|
|
477
|
+
var candidateNodes = RED.nodes.filterNodes({type:'debug'});
|
|
478
|
+
candidateNodes.forEach(function(n) {
|
|
479
|
+
filteredNodes[n.id] = true;
|
|
480
|
+
});
|
|
481
|
+
delete filteredNodes[sourceId];
|
|
482
|
+
$("#red-ui-sidebar-debug-filterSelected").trigger("click");
|
|
483
|
+
RED.settings.set('debug.filteredNodes',Object.keys(filteredNodes))
|
|
484
|
+
refreshMessageList();
|
|
485
|
+
}},
|
|
486
|
+
{id:"red-ui-debug-msg-menu-item-clear-filter",label:RED._("node-red:debug.messageMenu.clearFilter"),onselect:function(){
|
|
487
|
+
$("#red-ui-sidebar-debug-filterAll").trigger("click");
|
|
488
|
+
refreshMessageList();
|
|
489
|
+
}}
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
menuOptionMenu = RED.menu.init({id:"red-ui-debug-msg-option-menu",
|
|
493
|
+
options: opts
|
|
486
494
|
});
|
|
487
495
|
menuOptionMenu.css({
|
|
488
496
|
position: "absolute"
|
|
@@ -168,9 +168,9 @@ module.exports = function(RED) {
|
|
|
168
168
|
return getFromValueType(RED.util.getMessageProperty(msg,rule.from),done);
|
|
169
169
|
} else if (rule.fromt === 'flow' || rule.fromt === 'global') {
|
|
170
170
|
var contextKey = RED.util.parseContextStore(rule.from);
|
|
171
|
-
if (/\[msg\./.test(
|
|
171
|
+
if (/\[msg\./.test(contextKey.key)) {
|
|
172
172
|
// The key has a nest msg. reference to evaluate first
|
|
173
|
-
|
|
173
|
+
contextKey.key = RED.util.normalisePropertyExpression(contextKey.key,msg,true);
|
|
174
174
|
}
|
|
175
175
|
node.context()[rule.fromt].get(contextKey.key, contextKey.store, (err,fromValue) => {
|
|
176
176
|
if (err) {
|