public inbox for [email protected]
help / color / mirror / Atom feedFrom: Murtuza Zabuawala <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][RM#3319] Fix the cancel query button glitch in query tool
Date: Mon, 2 Jul 2018 10:28:52 +0530
Message-ID: <CAKKotZSjLmQk-T38TdC13uOmpibBTPFr6qk643wgMEW5r26y_w@mail.gmail.com> (raw)
Hi,
PFA patch to fix the issue where cancel button remains enabled even after
the query execution completes, I have moved the enable/disable logic for
that button with rest of the buttons in '*disable_tool_buttons*' method &
removed tests which are not required as we are already testing '
*disable_tool_buttons*' method.
*I had to fix it coz it was annoying me :)*
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
[application/octet-stream] RM_3319.diff (9.2K, 3-RM_3319.diff)
download | inline diff:
diff --git a/web/pgadmin/static/js/sqleditor/execute_query.js b/web/pgadmin/static/js/sqleditor/execute_query.js
index 9aa025b..cb9420e 100644
--- a/web/pgadmin/static/js/sqleditor/execute_query.js
+++ b/web/pgadmin/static/js/sqleditor/execute_query.js
@@ -240,12 +240,10 @@ class ExecuteQuery {
enableSQLEditorButtons() {
this.sqlServerObject.disable_tool_buttons(false);
- $('#btn-cancel-query').prop('disabled', true);
}
disableSQLEditorButtons() {
this.sqlServerObject.disable_tool_buttons(true);
- $('#btn-cancel-query').prop('disabled', false);
}
static wasConnectionLostToPythonServer(httpResponse) {
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index ce39769..c360421 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -3370,6 +3370,10 @@ define('tools.querytool', [
$('#btn-edit-dropdown').prop('disabled', disabled);
$('#btn-edit').prop('disabled', disabled);
$('#btn-load-file').prop('disabled', disabled);
+ if (this.is_query_tool) {
+ // Cancel query tool needs opposite behaviour
+ $('#btn-cancel-query').prop('disabled', !disabled);
+ }
},
// This function will fetch the sql query from the text box
@@ -3461,8 +3465,6 @@ define('tools.querytool', [
// This function will cancel the running query.
_cancel_query: function() {
var self = this;
-
- $('#btn-cancel-query').prop('disabled', true);
$.ajax({
url: url_for('sqleditor.cancel_transaction', {
'trans_id': self.transId,
@@ -3470,12 +3472,10 @@ define('tools.querytool', [
method: 'POST',
contentType: 'application/json',
success: function(res) {
- if (res.data.status) {
- self.disable_tool_buttons(false);
- } else {
- self.disable_tool_buttons(false);
+ if (!res.data.status) {
alertify.alert(gettext('Cancel Query Error'), res.data.result);
}
+ self.disable_tool_buttons(false);
is_query_running = false;
setTimeout(() => { self.gridView.query_tool_obj.focus(); }, 200);
},
diff --git a/web/regression/javascript/sqleditor/execute_query_spec.js b/web/regression/javascript/sqleditor/execute_query_spec.js
index 0c0953c..7f42a9a 100644
--- a/web/regression/javascript/sqleditor/execute_query_spec.js
+++ b/web/regression/javascript/sqleditor/execute_query_spec.js
@@ -228,15 +228,6 @@ describe('ExecuteQuery', () => {
done();
}, 0);
});
-
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- expect(cancelButtonSpy)
- .toHaveBeenCalledWith('disabled', true);
- done();
- }, 0);
- });
});
describe('when query was cancelled', () => {
@@ -333,15 +324,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- expect(cancelButtonSpy)
- .toHaveBeenCalledWith('disabled', true);
- done();
- }, 0);
- });
-
it('should not login is displayed', (done) => {
setTimeout(
() => {
@@ -406,15 +388,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- expect(cancelButtonSpy)
- .toHaveBeenCalledWith('disabled', true);
- done();
- }, 0);
- });
-
it('should login is displayed', (done) => {
setTimeout(
() => {
@@ -483,15 +456,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- expect(cancelButtonSpy)
- .toHaveBeenCalledWith('disabled', true);
- done();
- }, 0);
- });
-
it('should login is not displayed', (done) => {
setTimeout(
() => {
@@ -558,15 +522,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- expect(cancelButtonSpy)
- .toHaveBeenCalledWith('disabled', true);
- done();
- }, 0);
- });
-
it('should login is displayed', (done) => {
setTimeout(
() => {
@@ -630,15 +585,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- expect(cancelButtonSpy)
- .toHaveBeenCalledWith('disabled', true);
- done();
- }, 0);
- });
-
it('should login is not displayed', (done) => {
setTimeout(
() => {
@@ -970,14 +916,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should not disable the cancel button', (done) => {
- setTimeout(
- () => {
- expect(cancelButtonSpy).not
- .toHaveBeenCalled();
- done();
- }, 0);
- });
});
describe('when cannot reach the Python Server', () => {
@@ -1251,15 +1189,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('disable the cancel query button', (done) => {
- setTimeout(() => {
- let buttonFlash = $('#btn-cancel-query');
-
- expect(buttonFlash.prop('disabled')).toEqual(true);
- done();
- }, 0);
- });
-
it('enable the query tool buttons', (done) => {
setTimeout(() => {
expect(sqlEditorMock.disable_tool_buttons).toHaveBeenCalledWith(false);
@@ -1369,16 +1298,6 @@ describe('ExecuteQuery', () => {
done();
}, 0);
});
-
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- let buttonFlash = $('#btn-cancel-query');
-
- expect(buttonFlash.prop('disabled')).toEqual(true);
- done();
- }, 0);
- });
});
describe('when error is returned by the server', () => {
@@ -1428,16 +1347,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- let buttonFlash = $('#btn-cancel-query');
-
- expect(buttonFlash.prop('disabled')).toEqual(true);
- done();
- }, 0);
- });
-
it('should not save the state', () => {
setTimeout(() => {
expect(sqlEditorMock.saveState).not.toHaveBeenCalled();
@@ -1496,16 +1405,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- let buttonFlash = $('#btn-cancel-query');
-
- expect(buttonFlash.prop('disabled')).toEqual(true);
- done();
- }, 0);
- });
-
it('should save the state', () => {
setTimeout(() => {
expect(sqlEditorMock.saveState).toHaveBeenCalledWith(
@@ -1567,16 +1466,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- let buttonFlash = $('#btn-cancel-query');
-
- expect(buttonFlash.prop('disabled')).toEqual(true);
- done();
- }, 0);
- });
-
it('should not save the state', () => {
setTimeout(() => {
expect(sqlEditorMock.saveState).not.toHaveBeenCalled();
@@ -1641,16 +1530,6 @@ describe('ExecuteQuery', () => {
}, 0);
});
- it('should disable the cancel button', (done) => {
- setTimeout(
- () => {
- let buttonFlash = $('#btn-cancel-query');
-
- expect(buttonFlash.prop('disabled')).toEqual(true);
- done();
- }, 0);
- });
-
it('should save the state', () => {
setTimeout(() => {
expect(sqlEditorMock.saveState).toHaveBeenCalledWith(
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin4][RM#3319] Fix the cancel query button glitch in query tool
In-Reply-To: <CAKKotZSjLmQk-T38TdC13uOmpibBTPFr6qk643wgMEW5r26y_w@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox