diff --git a/packages/node_modules/@node-red/editor-api/lib/editor/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-api/lib/editor/locales/en-US/editor.json
index 0ffa9de61..12df08790 100644
--- a/packages/node_modules/@node-red/editor-api/lib/editor/locales/en-US/editor.json
+++ b/packages/node_modules/@node-red/editor-api/lib/editor/locales/en-US/editor.json
@@ -462,6 +462,7 @@
"flows": "flows",
"filterUnused":"unused",
"filterAll":"all",
+ "deleteUnused":"Delete unused",
"filtered": "__count__ hidden"
},
"context": {
diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js
index 438fbe359..364c350e9 100644
--- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js
+++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js
@@ -15,17 +15,16 @@
**/
RED.sidebar.config = (function() {
-
var content = document.createElement("div");
content.className = "sidebar-node-config";
$('
'
).appendTo(content);
-
var toolbar = $(''+
' '+
'
'+
@@ -36,7 +35,7 @@ RED.sidebar.config = (function() {
var subflowCategories = $("
").appendTo(content);
var showUnusedOnly = false;
-
+ var unused = [];
var categories = {};
function getOrCreateCategory(name,parent,label) {
@@ -110,6 +109,17 @@ RED.sidebar.config = (function() {
if (A.type > B.type) { return 1;}
return 0;
});
+
+ unused = nodes.filter(function(n) {
+ return n._def.hasUsers!==false && n.users.length === 0;
+ })
+
+ if (unused.length > 0) {
+ $('#workspace-config-node-delete-all').addClass("selected");
+ } else {
+ $('#workspace-config-node-delete-all').removeClass("selected");
+ }
+
if (showUnusedOnly) {
var hiddenCount = nodes.length;
nodes = nodes.filter(function(n) {
@@ -152,6 +162,7 @@ RED.sidebar.config = (function() {
entry.on('dblclick',function(e) {
RED.editor.editConfig("", node.type, node.id);
});
+
var userArray = node.users.map(function(n) { return n.id });
entry.on('mouseover',function(e) {
RED.nodes.eachNode(function(node) {
@@ -244,6 +255,41 @@ RED.sidebar.config = (function() {
}
}
});
+ $("#workspace-config-node-delete-all").on("click", function(e) {
+ e.preventDefault();
+ unused.forEach(function(node) {
+ var configTypeDef = RED.nodes.getType(node.type);
+ if (configTypeDef.oneditdelete) {
+ configTypeDef.oneditdelete.call(node);
+ }
+ var historyEvent = {
+ t:'delete',
+ nodes:[node],
+ changes: {},
+ dirty: RED.nodes.dirty()
+ }
+ for (var i=0; i