Reset the layout if pgAdmin4 detects the layout is in an inconsistent state. Fixes #6988

This commit is contained in:
Nikhil Mohite
2021-11-12 11:50:37 +05:30
committed by Akshay Joshi
parent d4bf7164f9
commit 8bf178b0a3
2 changed files with 20 additions and 0 deletions

View File

@@ -61,6 +61,25 @@ _.extend(pgBrowser, {
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(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();