mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Flag a node as removed when it is disabled
This commit is contained in:
parent
d28b8b5e8d
commit
fe4ef354ac
@ -263,7 +263,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This node has been removed
|
// This node has been removed or its flow disabled
|
||||||
if (removed[node.z] || !newConfig.allNodes.hasOwnProperty(id)) {
|
if (removed[node.z] || !newConfig.allNodes.hasOwnProperty(id)) {
|
||||||
removed[id] = node;
|
removed[id] = node;
|
||||||
// Mark the container as changed
|
// Mark the container as changed
|
||||||
@ -278,6 +278,11 @@ module.exports = {
|
|||||||
if (added[node.z]) {
|
if (added[node.z]) {
|
||||||
added[id] = node;
|
added[id] = node;
|
||||||
} else {
|
} else {
|
||||||
|
var currentState = node.d;
|
||||||
|
var newState = newConfig.allNodes[id].d;
|
||||||
|
if (!currentState && newState) {
|
||||||
|
removed[id] = node;
|
||||||
|
}
|
||||||
// This node has a material configuration change
|
// This node has a material configuration change
|
||||||
if (diffNodes(node,newConfig.allNodes[id]) || newConfig.allNodes[id].credentials) {
|
if (diffNodes(node,newConfig.allNodes[id]) || newConfig.allNodes[id].credentials) {
|
||||||
changed[id] = newConfig.allNodes[id];
|
changed[id] = newConfig.allNodes[id];
|
||||||
|
@ -777,5 +777,26 @@ describe('flows/util', function() {
|
|||||||
diffResult.removed.sort().should.eql(["1","2"]);
|
diffResult.removed.sort().should.eql(["1","2"]);
|
||||||
diffResult.rewired.should.have.length(0);
|
diffResult.rewired.should.have.length(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('marks a node as removed when its state changes enabled to disabled', function() {
|
||||||
|
var config = [{id:"1",type:"tab",disabled:false,label:"fred"},{id:"2",type:"test",bar:"b",wires:[["1"]],z:"1"},{id:"3",type:"test"}];
|
||||||
|
var newConfig = clone(config);
|
||||||
|
newConfig[1].d = true;
|
||||||
|
|
||||||
|
var originalConfig = flowUtil.parseConfig(config);
|
||||||
|
var changedConfig = flowUtil.parseConfig(newConfig);
|
||||||
|
|
||||||
|
originalConfig.missingTypes.should.have.length(0);
|
||||||
|
|
||||||
|
var diffResult = flowUtil.diffConfigs(originalConfig,changedConfig);
|
||||||
|
|
||||||
|
diffResult.added.should.have.length(0);
|
||||||
|
diffResult.changed.should.have.length(2);
|
||||||
|
diffResult.changed.sort().should.eql(["1","2"]);
|
||||||
|
diffResult.removed.should.have.length(1);
|
||||||
|
diffResult.removed.sort().should.eql(["2"]);
|
||||||
|
diffResult.rewired.should.have.length(0);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user