From f71e2e804084512344a30be125b0246d9597bbea Mon Sep 17 00:00:00 2001 From: Nikhil Mohite Date: Fri, 29 Oct 2021 16:17:36 +0530 Subject: [PATCH] Fixed an issue where pgAdmin is not opening properly. Fixes #6809 --- docs/en_US/release_notes_6_2.rst | 1 + web/pgadmin/browser/static/js/browser.js | 22 +++++++++++--------- web/pgadmin/browser/static/js/layout.js | 21 ++++++++++++------- web/pgadmin/browser/static/js/preferences.js | 12 +++++------ 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/docs/en_US/release_notes_6_2.rst b/docs/en_US/release_notes_6_2.rst index 4836fe680..b3eb13839 100644 --- a/docs/en_US/release_notes_6_2.rst +++ b/docs/en_US/release_notes_6_2.rst @@ -20,5 +20,6 @@ Bug fixes | `Issue #5427 `_ - Fixed pgAdmin freezing issue by providing the error message for the operation that can't perform due to lock on the particular table. | `Issue #6780 `_ - Ensure that columns should be merged if the newly added column is present in the parent table. +| `Issue #6809 `_ - Fixed an issue where pgAdmin is not opening properly. | `Issue #6859 `_ - Fixed an issue where properties panel is not updated when any object is added from the browser tree. | `Issue #6949 `_ - Ensure that dialog should be opened when clicking on Reassign/Drop owned menu. diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index 45f18cb93..3f662a115 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -440,14 +440,16 @@ define('pgadmin.browser', [ initializeBrowserTree(obj); // Syntax highlight the SQL Pane - obj.editor = CodeMirror.fromTextArea( - document.getElementById('sql-textarea'), { - lineNumbers: true, - mode: 'text/x-pgsql', - readOnly: true, - extraKeys: pgAdmin.Browser.editor_shortcut_keys, - screenReaderLabel: gettext('SQL'), - }); + if(document.getElementById('sql-textarea')){ + obj.editor = CodeMirror.fromTextArea( + document.getElementById('sql-textarea'), { + lineNumbers: true, + mode: 'text/x-pgsql', + readOnly: true, + extraKeys: pgAdmin.Browser.editor_shortcut_keys, + screenReaderLabel: gettext('SQL'), + }); + } /* Cache may take time to load for the first time * Reflect the changes once cache is available */ @@ -465,8 +467,8 @@ define('pgadmin.browser', [ }); setTimeout(function() { - obj.editor.setValue('-- ' + select_object_msg); - obj.editor.refresh(); + obj?.editor?.setValue('-- ' + select_object_msg); + obj?.editor?.refresh(); }, 10); // Build the treeview context menu diff --git a/web/pgadmin/browser/static/js/layout.js b/web/pgadmin/browser/static/js/layout.js index 5f3138675..9491bfaa6 100644 --- a/web/pgadmin/browser/static/js/layout.js +++ b/web/pgadmin/browser/static/js/layout.js @@ -100,7 +100,10 @@ _.extend(pgBrowser, { }, lock_layout: function(docker, op) { - let menu_items = this.menus['file']['mnu_locklayout']['menu_items']; + let menu_items = []; + if('mnu_locklayout' in this.menus['file']) { + menu_items = this.menus['file']['mnu_locklayout']['menu_items']; + } switch(op) { case this.lock_layout_levels.PREVENT_DOCKING: @@ -114,13 +117,15 @@ _.extend(pgBrowser, { break; } - _.each(menu_items, function(menu_item) { - if(menu_item.name != ('mnu_lock_'+op)) { - menu_item.change_checked(false); - } else { - menu_item.change_checked(true); - } - }); + if(menu_items) { + _.each(menu_items, function(menu_item) { + if(menu_item.name != ('mnu_lock_'+op)) { + menu_item.change_checked(false); + } else { + menu_item.change_checked(true); + } + }); + } }, save_lock_layout: function(op) { diff --git a/web/pgadmin/browser/static/js/preferences.js b/web/pgadmin/browser/static/js/preferences.js index 98b006fc5..a41e68a11 100644 --- a/web/pgadmin/browser/static/js/preferences.js +++ b/web/pgadmin/browser/static/js/preferences.js @@ -124,14 +124,14 @@ _.extend(pgBrowser, { if(module === 'sqleditor' || module === null || typeof module === 'undefined') { let sqlEditPreferences = obj.get_preferences_for_module('sqleditor'); - $(obj.editor.getWrapperElement()).css( + $(obj?.editor?.getWrapperElement()).css( 'font-size',SqlEditorUtils.calcFontSize(sqlEditPreferences.sql_font_size) ); - obj.editor.setOption('tabSize', sqlEditPreferences.tab_size); - obj.editor.setOption('lineWrapping', sqlEditPreferences.wrap_code); - obj.editor.setOption('autoCloseBrackets', sqlEditPreferences.insert_pair_brackets); - obj.editor.setOption('matchBrackets', sqlEditPreferences.brace_matching); - obj.editor.refresh(); + obj?.editor?.setOption('tabSize', sqlEditPreferences.tab_size); + obj?.editor?.setOption('lineWrapping', sqlEditPreferences.wrap_code); + obj?.editor?.setOption('autoCloseBrackets', sqlEditPreferences.insert_pair_brackets); + obj?.editor?.setOption('matchBrackets', sqlEditPreferences.brace_matching); + obj?.editor?.refresh(); } },