Prevent shortcut deploy when deploy button shaded

fixes #3509
This commit is contained in:
Steve-Mcl 2022-04-04 17:06:29 +01:00
parent 77e2e44abc
commit 780e41d6a6
1 changed files with 199 additions and 196 deletions

View File

@ -320,18 +320,22 @@ RED.deploy = (function() {
}); });
} }
function save(skipValidation, force) { function save(skipValidation, force) {
if (!$("#red-ui-header-button-deploy").hasClass("disabled")) { if ($("#red-ui-header-button-deploy").hasClass("disabled")) {
return; //deploy is disabled
}
if ($("#red-ui-header-shade").is(":visible")) {
return; //deploy is shaded
}
if (!RED.user.hasPermission("flows.write")) { if (!RED.user.hasPermission("flows.write")) {
RED.notify(RED._("user.errors.deploy"), "error"); RED.notify(RED._("user.errors.deploy"), "error");
return; return;
} }
if (!skipValidation) { if (!skipValidation) {
var hasUnknown = false; let hasUnknown = false;
var hasInvalid = false; let hasInvalid = false;
var hasUnusedConfig = false; let hasUnusedConfig = false;
const unknownNodes = [];
var unknownNodes = []; const invalidNodes = [];
var invalidNodes = [];
RED.nodes.eachConfig(function (node) { RED.nodes.eachConfig(function (node) {
if (node.valid === undefined) { if (node.valid === undefined) {
@ -359,7 +363,7 @@ RED.deploy = (function() {
hasUnknown = unknownNodes.length > 0; hasUnknown = unknownNodes.length > 0;
hasInvalid = invalidNodes.length > 0; hasInvalid = invalidNodes.length > 0;
var unusedConfigNodes = []; const unusedConfigNodes = [];
RED.nodes.eachConfig(function (node) { RED.nodes.eachConfig(function (node) {
if ((node._def.hasUsers !== false) && (node.users.length === 0)) { if ((node._def.hasUsers !== false) && (node.users.length === 0)) {
unusedConfigNodes.push(getNodeInfo(node)); unusedConfigNodes.push(getNodeInfo(node));
@ -367,10 +371,10 @@ RED.deploy = (function() {
} }
}); });
var showWarning = false; let showWarning = false;
var notificationMessage; let notificationMessage;
var notificationButtons = []; let notificationButtons = [];
var notification; let notification;
if (hasUnknown && !ignoreDeployWarnings.unknown) { if (hasUnknown && !ignoreDeployWarnings.unknown) {
showWarning = true; showWarning = true;
notificationMessage = "<p>" + RED._('deploy.confirm.unknown') + "</p>" + notificationMessage = "<p>" + RED._('deploy.confirm.unknown') + "</p>" +
@ -427,14 +431,14 @@ RED.deploy = (function() {
} }
} }
var nns = RED.nodes.createCompleteNodeSet(); const nns = RED.nodes.createCompleteNodeSet();
const startTime = Date.now();
var startTime = Date.now();
$(".red-ui-deploy-button-content").css('opacity', 0); $(".red-ui-deploy-button-content").css('opacity', 0);
$(".red-ui-deploy-button-spinner").show(); $(".red-ui-deploy-button-spinner").show();
$("#red-ui-header-button-deploy").addClass("disabled"); $("#red-ui-header-button-deploy").addClass("disabled");
var data = {flows:nns}; const data = { flows: nns };
if (!force) { if (!force) {
data.rev = RED.nodes.version(); data.rev = RED.nodes.version();
@ -507,7 +511,7 @@ RED.deploy = (function() {
} }
}).always(function () { }).always(function () {
deployInflight = false; deployInflight = false;
var delta = Math.max(0,300-(Date.now()-startTime)); const delta = Math.max(0, 300 - (Date.now() - startTime));
setTimeout(function () { setTimeout(function () {
$(".red-ui-deploy-button-content").css('opacity', 1); $(".red-ui-deploy-button-content").css('opacity', 1);
$(".red-ui-deploy-button-spinner").hide(); $(".red-ui-deploy-button-spinner").hide();
@ -518,7 +522,6 @@ RED.deploy = (function() {
}, delta); }, delta);
}); });
} }
}
return { return {
init: init, init: init,
setDeployInflight: function(state) { setDeployInflight: function(state) {