From aa5b1d50b9722d1a96b181233c29cb7ae29edbce Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Tue, 1 Feb 2022 14:11:18 +0530 Subject: [PATCH] Fixed issues introduce by SonarQube fixes. --- web/pgadmin/browser/static/js/browser.js | 2 -- web/pgadmin/browser/static/js/error.js | 16 +++++++--------- web/pgadmin/static/js/backgrid.pgadmin.js | 11 ++--------- web/pgadmin/tools/debugger/static/js/direct.js | 6 +++--- .../schema_diff/static/js/schema_diff_ui.js | 10 +++++++--- .../tools/sqleditor/static/js/sqleditor.js | 18 ++++++++---------- 6 files changed, 27 insertions(+), 36 deletions(-) diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index 3edfd7e79..7cb3e7002 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -556,8 +556,6 @@ define('pgadmin.browser', [ 'the original/corrupt file using a tool such as DB Browser for SQLite if desired.'+ '

Original file: ' + res.data + '
Replacement file: ' + res.data.substring(0, res.data.length - 14), - function() { /*This is intentional (SonarQube)*/ - } ); } }).fail(function(xhr, status, error) { diff --git a/web/pgadmin/browser/static/js/error.js b/web/pgadmin/browser/static/js/error.js index b418fd9c6..b4603d883 100644 --- a/web/pgadmin/browser/static/js/error.js +++ b/web/pgadmin/browser/static/js/error.js @@ -48,15 +48,13 @@ define( text += ''; Notify.alert( _.unescape(title), - text - ) - .set({'closable': true, - 'onok': function() { - if(callback) { - callback(); - } - }, - }); + text, + function() { + if(callback) { + callback(); + } + } + ); }, }); diff --git a/web/pgadmin/static/js/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid.pgadmin.js index 927ab96c2..b997a0c69 100644 --- a/web/pgadmin/static/js/backgrid.pgadmin.js +++ b/web/pgadmin/static/js/backgrid.pgadmin.js @@ -453,10 +453,7 @@ define([ ); } } else { - Notify.alert(gettext('Edit object'), gettext('This object is not user editable.'), - function() { - return true; - }); + Notify.alert(gettext('Edit object'), gettext('This object is not user editable.')); } }, render: function() { @@ -548,11 +545,7 @@ define([ } ); } else { - Notify.alert(gettext('Delete object'), gettext('This object cannot be deleted.'), - function() { - return true; - } - ); + Notify.alert(gettext('Delete object'), gettext('This object cannot be deleted.')); } }, exitEditMode: function() { diff --git a/web/pgadmin/tools/debugger/static/js/direct.js b/web/pgadmin/tools/debugger/static/js/direct.js index eccdc4362..00ad8dc6b 100644 --- a/web/pgadmin/tools/debugger/static/js/direct.js +++ b/web/pgadmin/tools/debugger/static/js/direct.js @@ -449,7 +449,7 @@ define([ ); } }) - .fail(self.raisePollingError()); + .fail(self.raisePollingError); }, poll_timeout); }, @@ -623,7 +623,7 @@ define([ pgTools.DirectDebug.is_polling_required = false; } }) - .fail(self.raisePollingError()); + .fail(self.raisePollingError); }, poll_end_timeout); }, @@ -682,7 +682,7 @@ define([ self.poll_end_execution_result(trans_id); } }) - .fail(self.raisePollingError()); + .fail(self.raisePollingError); } }) .fail(function(xhr) { diff --git a/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js b/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js index 0e92a4545..d47c266a4 100644 --- a/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js +++ b/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js @@ -116,10 +116,14 @@ export default class SchemaDiffUI { raise_error_on_fail(alert_title, xhr) { try { - var err = JSON.parse(xhr.responseText); - Notify.alert(alert_title, err.errormsg); + if (_.isUndefined(xhr.responseText)) { + Notify.alert(alert_title, gettext('Unable to get the response text.')); + } else { + var err = JSON.parse(xhr.responseText); + Notify.alert(alert_title, err.errormsg); + } } catch (e) { - Notify.alert(alert_title, e.statusText); + Notify.alert(alert_title, gettext(e.message)); } } diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index de48369de..800e4425e 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -2372,16 +2372,14 @@ define('tools.querytool', [ pgWindow.default.pgAdmin && pgWindow.default.pgAdmin.Browser && pgWindow.default.pgAdmin.Browser.preference_version() <= 0) { - Notify.alert() - .setting({ - 'title': gettext('Connection lost'), - 'label':gettext('Close'), - 'message': gettext('The pgAdmin browser window has been closed and the connection to the server is lost. Please close this window and open a new pgAdmin session.'), - 'onok': function(){ - //Close the window after connection is lost - window.close(); - }, - }).show(); + Notify.alert(gettext('Connection lost'), + gettext('The pgAdmin browser window has been closed and the connection to the server is lost. Please close this window and open a new pgAdmin session.'), + function(){ + //Close the window after connection is lost + window.close(); + }, + gettext('Close') + ); } };