Fixed an issue where reset layout message showing when the user opens the query tool.

refs #6988
This commit is contained in:
Nikhil Mohite 2021-11-15 16:34:25 +05:30 committed by Akshay Joshi
parent 33cc2a7514
commit 1408bad8ba
2 changed files with 11 additions and 18 deletions

View File

@ -430,7 +430,7 @@ define('pgadmin.browser', [
// Stored layout in database from the previous session
var layout = pgBrowser.utils.layout;
obj.restore_layout(obj.docker, layout, obj.buildDefaultLayout.bind(obj));
obj.restore_layout(obj.docker, layout, obj.buildDefaultLayout.bind(obj), true);
obj.docker.on(wcDocker.EVENT.LAYOUT_CHANGED, function() {
obj.save_current_layout('Browser/Layout', obj.docker);

View File

@ -56,30 +56,23 @@ _.extend(pgBrowser, {
}
},
restore_layout: function(docker, layout, defaultLayoutCallback) {
restore_layout: function(docker, layout, defaultLayoutCallback, checkLayout= false) {
// Try to restore the layout if there is one
if (layout != '') {
try {
docker.restore(layout);
// Check restore layout is restored pgAdmin 4 layout successfully if not then reset layout to default pgAdmin 4 layout.
var reset_layout_to_default = true;
for (const [key, value] of Object.entries(this.panels)) {
if(value.name !== 'browser' || key !== 'browser') {
var _panel = docker.findPanels(value.name);
if(_panel.length > 0){
reset_layout_to_default = false;
break;
if(checkLayout) {
// Check restore layout is restored pgAdmin 4 layout successfully if not then reset layout to default pgAdmin 4 layout.
var _panel = docker.findPanels('properties');
if(_panel.length == 0 && defaultLayoutCallback){
// clear the wcDocker before reset layout.
docker.clear();
Alertify.info(gettext('pgAdmin has detected some issues with the UI layout, so reset it to the default.'), 0);
if(defaultLayoutCallback){
defaultLayoutCallback(docker);
}
}
}
if(reset_layout_to_default && defaultLayoutCallback) {
// clear the wcDocker before reset layout.
docker.clear();
Alertify.info(gettext('pgAdmin has detected some issues with the UI layout, so reset it to the default.'), 0);
if(defaultLayoutCallback){
defaultLayoutCallback(docker);
}
}
}
catch(err) {
docker.clear();