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

Add enable/disable-flow actions

This commit is contained in:
Nick O'Leary 2019-06-07 15:14:21 +01:00
parent 4cd6e20c91
commit 400071879f
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -60,6 +60,13 @@ RED.workspaces = (function() {
function showEditWorkspaceDialog(id) {
var workspace = RED.nodes.workspace(id);
if (!workspace) {
var subflow = RED.nodes.subflow(id);
if (subflow) {
RED.editor.editSubflow(subflow);
}
return;
}
RED.view.state(RED.state.EDITING);
var tabflowEditor;
var trayOptions = {
@ -331,6 +338,8 @@ RED.workspaces = (function() {
RED.actions.add("core:add-flow",function(opts) { addWorkspace(undefined,undefined,opts?opts.index:undefined)});
RED.actions.add("core:edit-flow",editWorkspace);
RED.actions.add("core:remove-flow",removeWorkspace);
RED.actions.add("core:enable-flow",enableWorkspace);
RED.actions.add("core:disable-flow",disableWorkspace);
RED.actions.add("core:list-flows",function() {
RED.actions.invoke("core:search","type:tab ");
@ -343,6 +352,48 @@ RED.workspaces = (function() {
showEditWorkspaceDialog(id||activeWorkspace);
}
function enableWorkspace(id) {
setWorkspaceState(id,false);
}
function disableWorkspace(id) {
setWorkspaceState(id,true);
}
function setWorkspaceState(id,disabled) {
var workspace = RED.nodes.workspace(id||activeWorkspace);
if (!workspace) {
return;
}
if (workspace.disabled !== disabled) {
var changes = { disabled: workspace.disabled };
workspace.disabled = disabled;
$("#red-ui-tab-"+(workspace.id.replace(".","-"))).toggleClass('red-ui-workspace-disabled',!!workspace.disabled);
$("#red-ui-workspace").toggleClass("red-ui-workspace-disabled",!!workspace.disabled);
var historyEvent = {
t: "edit",
changes:changes,
node: workspace,
dirty: RED.nodes.dirty()
}
workspace.changed = true;
RED.history.push(historyEvent);
RED.nodes.dirty(true);
RED.sidebar.config.refresh();
var selection = RED.view.selection();
if (!selection.nodes && !selection.links) {
RED.sidebar.info.refresh(workspace);
}
if (changes.hasOwnProperty('disabled')) {
RED.nodes.eachNode(function(n) {
if (n.z === workspace.id) {
n.dirty = true;
}
});
RED.view.redraw();
}
}
}
function removeWorkspace(ws) {
if (!ws) {
deleteWorkspace(RED.nodes.workspace(activeWorkspace));
@ -406,6 +457,8 @@ RED.workspaces = (function() {
},
resize: function() {
workspace_tabs.resize();
}
},
enable: enableWorkspace,
disable: disableWorkspace
}
})();