From 401d386812489e5b9555199e3d39c6ea853c4c03 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 5 May 2017 15:52:37 +0100 Subject: [PATCH] Add force-deploy option when conflict detected --- editor/js/ui/deploy.js | 24 ++++++++++++++++++------ red/api/locales/en-US/editor.json | 5 +++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/editor/js/ui/deploy.js b/editor/js/ui/deploy.js index 43800568f..237aa79b1 100644 --- a/editor/js/ui/deploy.js +++ b/editor/js/ui/deploy.js @@ -140,7 +140,16 @@ RED.deploy = (function() { if (ignoreChecked) { ignoreDeployWarnings[$( "#node-dialog-confirm-deploy-type" ).val()] = true; } - save(true,$( "#node-dialog-confirm-deploy-type" ).val() === "conflict"); + save(true,/conflict/.test($("#node-dialog-confirm-deploy-type" ).val())); + $( this ).dialog( "close" ); + } + }, + { + id: "node-dialog-confirm-deploy-overwrite", + text: RED._("deploy.confirm.button.overwrite"), + class: "primary", + click: function() { + save(true,/conflict/.test($("#node-dialog-confirm-deploy-type" ).val())); $( this ).dialog( "close" ); } } @@ -154,11 +163,13 @@ RED.deploy = (function() { ''); }, open: function() { - if ($( "#node-dialog-confirm-deploy-type" ).val() === "conflict") { + var deployType = $("#node-dialog-confirm-deploy-type" ).val(); + if (/conflict/.test(deployType)) { $( "#node-dialog-confirm-deploy" ).dialog('option','title', RED._('deploy.confirm.button.review')); $("#node-dialog-confirm-deploy-deploy").hide(); $("#node-dialog-confirm-deploy-review").addClass('disabled').show(); $("#node-dialog-confirm-deploy-merge").addClass('disabled').show(); + $("#node-dialog-confirm-deploy-overwrite").toggle(deployType === "deploy-conflict"); currentDiff = null; $("#node-dialog-confirm-deploy-conflict-checking").show(); $("#node-dialog-confirm-deploy-conflict-auto-merge").hide(); @@ -186,6 +197,7 @@ RED.deploy = (function() { } else { $( "#node-dialog-confirm-deploy" ).dialog('option','title', RED._('deploy.confirm.button.confirm')); $("#node-dialog-confirm-deploy-deploy").show(); + $("#node-dialog-confirm-deploy-overwrite").hide(); $("#node-dialog-confirm-deploy-review").hide(); $("#node-dialog-confirm-deploy-merge").hide(); $("#node-dialog-confirm-deploy-hide").parent().show(); @@ -226,7 +238,7 @@ RED.deploy = (function() { evt.preventDefault(); activeNotifyMessage.close(); var nns = RED.nodes.createCompleteNodeSet(); - resolveConflict(nns); + resolveConflict(nns,false); activeNotifyMessage = null; }) activeNotifyMessage = RED.notify(message,null,true); @@ -258,12 +270,12 @@ RED.deploy = (function() { return 0; } - function resolveConflict(currentNodes) { + function resolveConflict(currentNodes, activeDeploy) { $( "#node-dialog-confirm-deploy-config" ).hide(); $( "#node-dialog-confirm-deploy-unknown" ).hide(); $( "#node-dialog-confirm-deploy-unused" ).hide(); $( "#node-dialog-confirm-deploy-conflict" ).show(); - $( "#node-dialog-confirm-deploy-type" ).val("conflict"); + $( "#node-dialog-confirm-deploy-type" ).val(activeDeploy?"deploy-conflict":"background-conflict"); $( "#node-dialog-confirm-deploy" ).dialog( "open" ); } @@ -396,7 +408,7 @@ RED.deploy = (function() { if (xhr.status === 401) { RED.notify(RED._("deploy.deployFailed",{message:RED._("user.notAuthorized")}),"error"); } else if (xhr.status === 409) { - resolveConflict(nns); + resolveConflict(nns, true); } else if (xhr.responseText) { RED.notify(RED._("deploy.deployFailed",{message:xhr.responseText}),"error"); } else { diff --git a/red/api/locales/en-US/editor.json b/red/api/locales/en-US/editor.json index ad9c5be5e..023735b66 100644 --- a/red/api/locales/en-US/editor.json +++ b/red/api/locales/en-US/editor.json @@ -133,9 +133,10 @@ "button": { "ignore": "Ignore", "confirm": "Confirm deploy", - "review": "Review differences", + "review": "Review changes", "cancel": "Cancel", - "merge": "Merge changes" + "merge": "Merge", + "overwrite": "Ignore & deploy" }, "undeployedChanges": "You have undeployed changes.\n\nLeaving this page will lose these changes.", "improperlyConfigured": "The workspace contains some nodes that are not properly configured:",