From 75a7be41eb938cba2018ee84b22a49df1f7639e6 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sun, 10 Apr 2016 15:22:41 +0100 Subject: [PATCH] Better notification message when action is not permitted --- editor/js/ui/deploy.js | 8 +++++--- editor/js/ui/library.js | 12 ++++++++++-- red/api/locales/en-US/editor.json | 4 +++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/editor/js/ui/deploy.js b/editor/js/ui/deploy.js index 9495d6bb2..df36a6058 100644 --- a/editor/js/ui/deploy.js +++ b/editor/js/ui/deploy.js @@ -268,10 +268,12 @@ RED.deploy = (function() { RED.events.emit("deploy"); }).fail(function(xhr,textStatus,err) { RED.nodes.dirty(true); - if (xhr.responseText) { - RED.notify(RED._("notification.error",{message:xhr.responseText}),"error"); + if (xhr.status === 401) { + RED.notify(RED._("deploy.deployFailed",{message:RED._("user.notAuthorized")}),"error"); + } else if (xhr.responseText) { + RED.notify(RED._("deploy.deployFailed",{message:xhr.responseText}),"error"); } else { - RED.notify(RED._("notification.error",{message:RED._("deploy.errors.noResponse")}),"error"); + RED.notify(RED._("deploy.deployFailed",{message:RED._("deploy.errors.noResponse")}),"error"); } }).always(function() { $("#btn-deploy-icon").removeClass('spinner'); diff --git a/editor/js/ui/library.js b/editor/js/ui/library.js index 40ebe8faf..065ccd37b 100644 --- a/editor/js/ui/library.js +++ b/editor/js/ui/library.js @@ -344,7 +344,11 @@ RED.library = (function() { }).done(function(data,textStatus,xhr) { RED.notify(RED._("library.savedType", {type:options.type}),"success"); }).fail(function(xhr,textStatus,err) { - RED.notify(RED._("library.saveFailed",{message:xhr.responseText}),"error"); + if (xhr.status === 401) { + RED.notify(RED._("library.saveFailed",{message:RED._("user.notAuthorized")}),"error"); + } else { + RED.notify(RED._("library.saveFailed",{message:xhr.responseText}),"error"); + } }); } $( "#node-dialog-library-save-confirm" ).dialog({ @@ -444,7 +448,11 @@ RED.library = (function() { RED.library.loadFlowLibrary(); RED.notify(RED._("library.savedNodes"),"success"); }).fail(function(xhr,textStatus,err) { - RED.notify(RED._("library.saveFailed",{message:xhr.responseText}),"error"); + if (xhr.status === 401) { + RED.notify(RED._("library.saveFailed",{message:RED._("user.notAuthorized")}),"error"); + } else { + RED.notify(RED._("library.saveFailed",{message:xhr.responseText}),"error"); + } }); } $( this ).dialog( "close" ); diff --git a/red/api/locales/en-US/editor.json b/red/api/locales/en-US/editor.json index 10fbf478b..ce2d7a0e1 100644 --- a/red/api/locales/en-US/editor.json +++ b/red/api/locales/en-US/editor.json @@ -47,7 +47,8 @@ "user": { "loggedInAs": "Logged in as __name__", "login": "Login", - "loginFailed": "Login failed" + "loginFailed": "Login failed", + "notAuthorized": "Not authorized" }, "notification": { "warning": "Warning: __message__", @@ -84,6 +85,7 @@ "modifiedNodes": "Modified Nodes", "modifiedNodesDesc": "Only deploys nodes that have changed", "successfulDeploy": "Successfully deployed", + "deployFailed": "Deploy failed: __message__", "unusedConfigNodes":"You have some unused configuration nodes.", "unusedConfigNodesLink":"Click here to see them", "errors": {