public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin4][RM#3319] Fix the cancel query button glitch in query tool
2+ messages / 2 participants
[nested] [flat]
* [pgAdmin4][RM#3319] Fix the cancel query button glitch in query tool
@ 2018-07-02 04:58 Murtuza Zabuawala <[email protected]>
2018-07-02 14:37 ` Re: [pgAdmin4][RM#3319] Fix the cancel query button glitch in query tool Dave Page <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Murtuza Zabuawala @ 2018-07-02 04:58 UTC (permalink / raw)
To: pgadmin-hackers
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(
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgAdmin4][RM#3319] Fix the cancel query button glitch in query tool
2018-07-02 04:58 [pgAdmin4][RM#3319] Fix the cancel query button glitch in query tool Murtuza Zabuawala <[email protected]>
@ 2018-07-02 14:37 ` Dave Page <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dave Page @ 2018-07-02 14:37 UTC (permalink / raw)
To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers
Thanks, patch applied.
On Mon, Jul 2, 2018 at 5:58 AM, Murtuza Zabuawala <
[email protected]> wrote:
> 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
>
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-07-02 14:37 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02 04:58 [pgAdmin4][RM#3319] Fix the cancel query button glitch in query tool Murtuza Zabuawala <[email protected]>
2018-07-02 14:37 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox