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

Add actions to change deploy type

This commit is contained in:
Nick O'Leary 2019-06-12 10:06:58 +01:00
parent 4d37c28bc7
commit 8abc5b3889
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 31 additions and 19 deletions

View File

@ -98,21 +98,10 @@ RED.menu = (function() {
return; return;
} }
if (opt.toggle) { if (opt.toggle) {
var selected = isSelected(opt.id); if (opt.toggle === true) {
if (typeof opt.toggle === "string") { setSelected(opt.id, !isSelected(opt.id));
if (!selected) {
for (var m in menuItems) {
if (menuItems.hasOwnProperty(m)) {
var mi = menuItems[m];
if (mi.id != opt.id && opt.toggle == mi.toggle) {
setSelected(mi.id,false);
}
}
}
setSelected(opt.id,true);
}
} else { } else {
setSelected(opt.id, !selected); setSelected(opt.id, true);
} }
} else { } else {
triggerAction(opt.id); triggerAction(opt.id);
@ -209,8 +198,9 @@ RED.menu = (function() {
} }
function setSelected(id,state) { function setSelected(id,state) {
var alreadySet = false;
if (isSelected(id) == state) { if (isSelected(id) == state) {
return; alreadySet = true;
} }
var opt = menuItems[id]; var opt = menuItems[id];
if (state) { if (state) {
@ -218,11 +208,27 @@ RED.menu = (function() {
} else { } else {
$("#"+id).removeClass("active"); $("#"+id).removeClass("active");
} }
if (opt && opt.onselect) { if (opt) {
if (opt.toggle && typeof opt.toggle === "string") {
if (state) {
for (var m in menuItems) {
if (menuItems.hasOwnProperty(m)) {
var mi = menuItems[m];
if (mi.id != opt.id && opt.toggle == mi.toggle) {
setSelected(mi.id,false);
}
}
}
}
}
if (!alreadySet && opt.onselect) {
triggerAction(opt.id,state); triggerAction(opt.id,state);
} }
}
if (!alreadySet) {
RED.settings.set(opt.setting||("menu-"+opt.id), state); RED.settings.set(opt.setting||("menu-"+opt.id), state);
} }
}
function toggleSelected(id) { function toggleSelected(id) {
setSelected(id,!isSelected(id)); setSelected(id,!isSelected(id));

View File

@ -99,7 +99,13 @@ RED.deploy = (function() {
}); });
RED.actions.add("core:deploy-flows",save); RED.actions.add("core:deploy-flows",save);
if (type === "default") {
RED.actions.add("core:restart-flows",restart); RED.actions.add("core:restart-flows",restart);
RED.actions.add("core:set-deploy-type-to-full",function() { RED.menu.setSelected("deploymenu-item-full",true);});
RED.actions.add("core:set-deploy-type-to-modified-flows",function() { RED.menu.setSelected("deploymenu-item-flow",true); });
RED.actions.add("core:set-deploy-type-to-modified-nodes",function() { RED.menu.setSelected("deploymenu-item-node",true); });
}
RED.events.on('nodes:change',function(state) { RED.events.on('nodes:change',function(state) {