mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that confirmation dialog should be popped up before reload of query tool or debugger
if it is opened in a new browser tab. Fixes #4101
This commit is contained in:
committed by
Akshay Joshi
parent
4ac064de42
commit
49b318c39e
@@ -196,14 +196,14 @@ define([
|
||||
|
||||
let self = this;
|
||||
let cacheIntervalId = setInterval(function() {
|
||||
try {
|
||||
self.preferences = window.top.pgAdmin.Browser;
|
||||
if(pgBrowser.preference_version() > 0) {
|
||||
self.preferences = pgBrowser.get_preferences_for_module('debugger');
|
||||
clearInterval(cacheIntervalId);
|
||||
}
|
||||
catch(err) {
|
||||
clearInterval(cacheIntervalId);
|
||||
throw err;
|
||||
}
|
||||
},0);
|
||||
|
||||
pgBrowser.onPreferencesChange('debugger', function() {
|
||||
self.preferences = pgBrowser.get_preferences_for_module('debugger');
|
||||
});
|
||||
},
|
||||
// It will check weather the function is actually debuggable or not with pre-required condition.
|
||||
|
||||
@@ -10,12 +10,26 @@ try {
|
||||
var $ = pgDirectDebug.jquery;
|
||||
|
||||
pgDirectDebug.load({{ uniqueId }}, {{ debug_type }}, '{{ function_name_with_arguments }}', '{{layout|safe}}');
|
||||
window.onbeforeunload = function(ev) {
|
||||
$.ajax({
|
||||
url: "{{ url_for('debugger.index') }}close/{{ uniqueId }}",
|
||||
method: 'DELETE'
|
||||
|
||||
// Register unload event on window close.
|
||||
/* If opened in new tab, close the connection only on tab/window close and
|
||||
* not on refresh attempt because the user may cancel the reload
|
||||
*/
|
||||
if(window.opener) {
|
||||
$(window).on('unload', function(ev) {
|
||||
$.ajax({
|
||||
method: 'DELETE',
|
||||
url: "{{ url_for('debugger.index') }}close/{{ uniqueId }}"
|
||||
});
|
||||
});
|
||||
};
|
||||
} else {
|
||||
$(window).on('beforeunload', function(ev) {
|
||||
$.ajax({
|
||||
method: 'DELETE',
|
||||
url: "{{ url_for('debugger.index') }}close/{{ uniqueId }}"
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
function() {
|
||||
console.log(arguments);
|
||||
|
||||
Reference in New Issue
Block a user