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

Merge pull request #3517 from Steve-Mcl/no-deploy-when-shaded

Prevent shortcut deploy when deploy button shaded
This commit is contained in:
Nick O'Leary 2022-04-05 23:31:45 +01:00 committed by GitHub
commit bba819ba84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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) {