From 5a6568e7c2c08efe206432601a9fbe3f1e5b2354 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Wed, 10 Feb 2021 17:32:27 +0900 Subject: [PATCH] allow filtering of debug node output within subflow --- .../core/common/lib/debug/debug-utils.js | 52 ++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/common/lib/debug/debug-utils.js b/packages/node_modules/@node-red/nodes/core/common/lib/debug/debug-utils.js index 64068ea86..ae35e57bd 100644 --- a/packages/node_modules/@node-red/nodes/core/common/lib/debug/debug-utils.js +++ b/packages/node_modules/@node-red/nodes/core/common/lib/debug/debug-utils.js @@ -120,7 +120,7 @@ RED.debug = (function() { filteredNodes[node.id] = !$(this).prop('checked'); $(".red-ui-debug-msg-node-"+node.id.replace(/\./g,"_")).toggleClass('hide',filteredNodes[node.id]); }); - if (!node.active || RED.nodes.workspace(node.z).disabled) { + if ((node.hasOwnProperty("active") && !node.active) || RED.nodes.workspace(node.z).disabled) { container.addClass('disabled'); muteControl.checkboxSet('disable'); } @@ -233,6 +233,35 @@ RED.debug = (function() { } + function containsDebug(sid, map) { + if (sid in map) { + return true; + } + var nodes = RED.nodes.filterNodes({z: sid}); + var contain = false; + nodes.forEach(function (n) { + if (contain) { + return; + } + var nt = n.type; + if (nt === "debug") { + contain = true; + return; + } + if (nt.substring(0, 8) === "subflow:") { + var id = nt.substring(8); + if (containsDebug(id, map)) { + contain = true; + return; + } + } + }); + if (contain) { + map[sid] = true; + } + return contain; + } + function refreshDebugNodeList() { debugNodeList.editableList('empty'); var candidateNodes = RED.nodes.filterNodes({type:'debug'}); @@ -243,7 +272,18 @@ RED.debug = (function() { }); candidateNodes = candidateNodes.filter(function(node) { return workspaceOrderMap.hasOwnProperty(node.z); - }) + }); + var map = {}; + RED.nodes.eachNode(function (n) { + var nt = n.type; + if ((n.z in workspaceOrderMap) && + (nt.substring(0, 8) === "subflow:")) { + var sid = nt.substring(8); + if (containsDebug(sid, map)) { + candidateNodes.push(n); + } + } + }); candidateNodes.sort(function(A,B) { var wsA = workspaceOrderMap[A.z]; var wsB = workspaceOrderMap[B.z]; @@ -253,7 +293,7 @@ RED.debug = (function() { var labelA = RED.utils.getNodeLabel(A,A.id); var labelB = RED.utils.getNodeLabel(B,B.id); return labelA.localeCompare(labelB); - }) + }); var currentWs = null; var nodeList = []; candidateNodes.forEach(function(node) { @@ -262,10 +302,8 @@ RED.debug = (function() { nodeList.push(RED.nodes.workspace(node.z)); } nodeList.push(node); - }) - - - debugNodeList.editableList('addItems',nodeList) + }); + debugNodeList.editableList('addItems',nodeList); } function getTimestamp() {