I would like to duplicate flows as fast as I can delete them.
And when I mess up I can just disable them again.
click on workspace - ctrl-(or cmd)-a to select all, ctrl-c to copy - hit plus on tab bar to add new tab - ctrl-v to paste... click to fix position. Done
Thank you for your quickly.
Mostly the damage is all ready done realizing I was working on the orginal.
So If I do a copy of my current mistake to a new flow then trying to work my way back into the corrupt flow with ctrl-z it deletes or undo the copy I made to the new flow
If you have only deployed once... then there is a backup hidden in your user directory.
If your flow was called flows_fred.json
the previous version would be .flows_fred.json.backup
Well actually my node-red emails me the complete backup flows_...json on every deploy.
I then copy the whole contains onto clipboard and import it back deleting every flow I don't need
For now its a cat and mouse game what I should do is read back its contains determining flow or section from within the backup then importing only the selected back in.
Have you considered using "projects" mode? It has git history of changes!
omgosh that looks good I am going to look into that, Thanks!
I've added a menu option for this, not realising that cmd-a, cmd-c, plus icon, cmd-v was a thing:
It basically follows the path as how lock-flow and disable-flow are implemented, i.e., defining an action that is called when the menu item is selected.
For the actual "work", I defined the duplicateWorkspace
function:
function duplicateWorkspace(id) {
function getFlowDataFromCurrentWorkspace(id) {
var activeWorkspace = id || RED.workspaces.active();
var nodes = RED.nodes.groups(activeWorkspace);
nodes = nodes.concat(RED.nodes.junctions(activeWorkspace));
nodes = nodes.concat(RED.nodes.filterNodes({ z: activeWorkspace }));
RED.nodes.eachConfig(function (n) {
if (n.z === RED.workspaces.active() && n._def.hasUsers === false) {
// Grab any config nodes scoped to this flow that don't
// require any flow-nodes to use them
nodes.push(n);
}
});
var parentNode = RED.nodes.workspace(
activeWorkspace
) || RED.nodes.subflow(activeWorkspace);
nodes.unshift(parentNode);
return RED.nodes.createExportableNodeSet(nodes);
}
if (!id) { return; }
RED.view.importNodes(getFlowDataFromCurrentWorkspace(id),
{generateIds: true, addFlow: true, touchImport: true});
}
that's a hack-together function that best solved the problem of copy and replacing ids for an existing flow.
Just an idea for those that might like this.
Why? Because I spend a lot of time creating small flows that I copy and then extend ...
This is well done, but why enable touchImport
?
what does that even do? I don't know
I admit it, I added the feature, it worked, nothing broke and I moved on! The touchImport just looks nice there at the end ....