1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

[groups] Add undo of group import

This commit is contained in:
Nick O'Leary 2020-03-13 11:27:13 +00:00
parent fc3d0ab053
commit 0ef3471f8f
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 33 additions and 8 deletions

View File

@ -21,6 +21,7 @@ RED.history = (function() {
var i;
var len;
var node;
var group;
var subflow;
var modifiedTabs = {};
var inverseEv;
@ -74,6 +75,15 @@ RED.history = (function() {
RED.nodes.removeLink(ev.links[i]);
}
}
if (ev.groups) {
inverseEv.groups = [];
for (i=0;i<ev.groups.length;i++) {
group = ev.groups[i];
modifiedTabs[group.z] = true;
inverseEv.groups.push(group);
RED.nodes.removeGroup(group);
}
}
if (ev.workspaces) {
inverseEv.workspaces = [];
for (i=0;i<ev.workspaces.length;i++) {
@ -208,6 +218,14 @@ RED.history = (function() {
inverseEv.links.push(ev.links[i]);
}
}
if (ev.groups) {
inverseEv.groups = [];
for (i=0;i<ev.groups.length;i++) {
RED.nodes.addGroup(ev.groups[i])
modifiedTabs[ev.groups[i].z] = true;
inverseEv.groups.push(ev.groups[i].id);
}
}
if (ev.createdLinks) {
inverseEv.removedLinks = [];
for (i=0;i<ev.createdLinks.length;i++) {
@ -450,6 +468,8 @@ RED.history = (function() {
if (ev.order) {
RED.workspaces.order(ev.order);
}
} else if (ev.t == "createGroup") {
}
Object.keys(modifiedTabs).forEach(function(id) {

View File

@ -1378,7 +1378,7 @@ RED.nodes = (function() {
}
RED.workspaces.refresh();
return [new_nodes,new_links,new_workspaces,new_subflows,missingWorkspace];
return [new_nodes,new_links,new_groups,new_workspaces,new_subflows,missingWorkspace];
}
// TODO: supports filter.z|type
@ -1469,6 +1469,9 @@ RED.nodes = (function() {
nodeTabMap = {};
configNodes = {};
workspacesOrder = [];
groups = {};
groupsByZ = {};
var subflowIds = Object.keys(subflows);
subflowIds.forEach(function(id) {
RED.subflow.removeSubflow(id)

View File

@ -1885,7 +1885,7 @@ if (DEBUG_EVENTS) { console.warn("clearSelection", mouse_mode); }
})
RED.nodes.removeGroup(g);
}
};
}
if (removedSubflowOutputs.length > 0) {
result = RED.subflow.removeOutput(removedSubflowOutputs);
if (result) {
@ -4057,12 +4057,12 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
g.append('rect').classed("red-ui-flow-group-outline",true)
.attr('rx',1).attr('ry',1).style({
.attr('rx',0.5).attr('ry',0.5).style({
"fill":"none",
"stroke": "#ff7f0e",
"pointer-events": "stroke",
"stroke-opacity": 0,
"stroke-width": 15
"stroke-width": 12
})
g.append('rect').classed("red-ui-flow-group-body",true)
@ -4110,7 +4110,7 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
g.selectAll(".red-ui-flow-group-outline")
.attr("width",d.w)
.attr("height",d.h)
.style("stroke-opacity",function(d) { if (d.selected) { return 0.3 } return 0});
.style("stroke-opacity",function(d) { if (d.selected) { return 0.8 } return 0});
g.selectAll(".red-ui-flow-group-body")
.attr("width",d.w)
@ -4190,9 +4190,10 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
if (result) {
var new_nodes = result[0];
var new_links = result[1];
var new_workspaces = result[2];
var new_subflows = result[3];
var new_default_workspace = result[4];
var new_groups = result[2];
var new_workspaces = result[3];
var new_subflows = result[4];
var new_default_workspace = result[5];
if (addNewFlow && new_default_workspace) {
RED.workspaces.show(new_default_workspace.id);
}
@ -4265,6 +4266,7 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
t:"add",
nodes:new_node_ids,
links:new_links,
groups:new_groups,
workspaces:new_workspaces,
subflows:new_subflows,
dirty:RED.nodes.dirty()