Fixed blank screen issue while opening query tools in new tab from native menu. #5503

This commit is contained in:
Nikhil Mohite
2022-12-08 19:17:12 +05:30
committed by GitHub
parent 8f5a58a163
commit cc0d467927
6 changed files with 71 additions and 25 deletions

View File

@@ -9,11 +9,13 @@
import _ from 'lodash';
import $ from 'jquery';
import url_for from './url_for';
import gettext from 'sources/gettext';
import 'wcdocker';
import Notify from './helpers/Notifier';
import { hasTrojanSource } from 'anti-trojan-source';
import convert from 'convert-units';
import getApiInstance from './api_instance';
let wcDocker = window.wcDocker;
@@ -665,3 +667,38 @@ export function fullHexColor(shortHex) {
}
return shortHex;
}
export function openNewWindow(toolForm, title) {
let {name: browser} = getBrowser();
if(browser == 'Nwjs') {
let api = getApiInstance();
api({
url: url_for('tools.initialize', null),
method: 'GET',
})
.then(function () {
openWindow(toolForm, title);
})
.catch(function (error) {
Notify.error(gettext(`Error in Tool initialize ${error.response.data}`));
});
}
else {
openWindow(toolForm, title);
}
}
function openWindow(toolForm, title) {
let newWin = window.open('', '_blank');
if (newWin) {
newWin.document.write(toolForm);
newWin.document.title = title;
let pgBrowser = window.pgAdmin.Browser;
// Send the signal to runtime, so that proper zoom level will be set.
setTimeout(function() {
pgBrowser.send_signal_to_runtime('Runtime new window opened');
}, 500);
} else {
return false;
}
}