From dc8832192d813662eeb2ae4ec8a4858ff4cfb8d8 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Fri, 26 May 2023 18:30:28 +0530 Subject: [PATCH] When opening pgAdmin the layout should be auto reset if it is corrupted. Reset layout menu should work if layout is corrupted while using pgAdmin. #6266 --- web/pgadmin/browser/static/js/MainMenuFactory.js | 6 +++--- web/pgadmin/browser/static/js/layout.js | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/web/pgadmin/browser/static/js/MainMenuFactory.js b/web/pgadmin/browser/static/js/MainMenuFactory.js index c85aebea7..8ddeaf087 100644 --- a/web/pgadmin/browser/static/js/MainMenuFactory.js +++ b/web/pgadmin/browser/static/js/MainMenuFactory.js @@ -85,9 +85,9 @@ export default class MainMenuFactory { return new MenuItem({...options, callback: () => { // Some callbacks registered in 'callbacks' check and call specifiec callback function if (options.module && 'callbacks' in options.module && options.module.callbacks[options.callback]) { - options.module.callbacks[options.callback].apply(options.module, [options.data, pgAdmin.Browser.tree.selected()]); + options.module.callbacks[options.callback].apply(options.module, [options.data, pgAdmin.Browser.tree?.selected()]); } else if (options.module && options.module[options.callback]) { - options.module[options.callback].apply(options.module, [options.data, pgAdmin.Browser.tree.selected()]); + options.module[options.callback].apply(options.module, [options.data, pgAdmin.Browser.tree?.selected()]); } else if (options?.callback) { options.callback(options); } else { @@ -125,4 +125,4 @@ export default class MainMenuFactory { return {flag,showMenu:undefined}; } } -} \ No newline at end of file +} diff --git a/web/pgadmin/browser/static/js/layout.js b/web/pgadmin/browser/static/js/layout.js index cf813946e..ade9709d6 100644 --- a/web/pgadmin/browser/static/js/layout.js +++ b/web/pgadmin/browser/static/js/layout.js @@ -62,8 +62,7 @@ _.extend(pgBrowser, { docker.restore(layout); if(checkLayout) { // Check restore layout is restored pgAdmin 4 layout successfully if not then reset layout to default pgAdmin 4 layout. - let _panel = docker.findPanels('properties'); - if(_panel.length == 0 && defaultLayoutCallback){ + if((docker.findPanels('properties').length == 0 || docker.findPanels('browser').length == 0) && defaultLayoutCallback){ // clear the wcDocker before reset layout. docker.clear(); Notify.info(gettext('pgAdmin has reset the layout because the previously saved layout is invalid.'), null);