diff --git a/docs/en_US/keyboard_shortcuts.rst b/docs/en_US/keyboard_shortcuts.rst index 45b08e030..984919bbb 100644 --- a/docs/en_US/keyboard_shortcuts.rst +++ b/docs/en_US/keyboard_shortcuts.rst @@ -48,6 +48,8 @@ When using main browser window, the following keyboard shortcuts are available: +----------------------------+--------------------+------------------------------------+ | Shift + Alt + ] | Shift + Option + ] | Tabbed panel forward | +----------------------------+--------------------+------------------------------------+ + | Shift + Alt + w | Shift + Ctrl + w | Close tab panel | + +----------------------------+--------------------+------------------------------------+ | Shift + Alt + l | Shift + Option + l | Tools main menu | +----------------------------+--------------------+------------------------------------+ | Shift + Alt + v | Shift + Option + v | View data | diff --git a/web/pgadmin/browser/register_browser_preferences.py b/web/pgadmin/browser/register_browser_preferences.py index 1b1f2acb3..78067f4d5 100644 --- a/web/pgadmin/browser/register_browser_preferences.py +++ b/web/pgadmin/browser/register_browser_preferences.py @@ -156,6 +156,21 @@ def register_browser_preferences(self): fields=fields ) + self.preference.register( + 'keyboard_shortcuts', + 'close_tab_panel', + gettext('Close tab panel'), + 'keyboardshortcut', + { + 'alt': False, + 'shift': True, + 'control': True, + 'key': {'key_code': 87, 'char': 'w'} + }, + category_label=PREF_LABEL_KEYBOARD_SHORTCUTS, + fields=fields + ) + self.preference.register( 'keyboard_shortcuts', 'tabbed_panel_forward', diff --git a/web/pgadmin/browser/static/js/keyboard.js b/web/pgadmin/browser/static/js/keyboard.js index 9d4605229..cd35d3128 100644 --- a/web/pgadmin/browser/static/js/keyboard.js +++ b/web/pgadmin/browser/static/js/keyboard.js @@ -15,6 +15,7 @@ import gettext from 'sources/gettext'; import pgWindow from 'sources/window'; import usePreferences from '../../../preferences/static/js/store'; + const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {}; pgBrowser.keyboardNavigation = pgBrowser.keyboardNavigation || {}; @@ -51,6 +52,7 @@ _.extend(pgBrowser.keyboardNavigation, { 'direct_debugging': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'direct_debugging')?.value), 'add_grid_row': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'add_grid_row')?.value), 'open_quick_search': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'open_quick_search')?.value), + 'close_tab_panel': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'close_tab_panel')?.value), }; this.shortcutMethods = { @@ -59,7 +61,7 @@ _.extend(pgBrowser.keyboardNavigation, { this.keyboardShortcut.object_shortcut, this.keyboardShortcut.tools_shortcut, this.keyboardShortcut.help_shortcut], }}, // Main menu - 'bindRightPanel': {'shortcuts': [this.keyboardShortcut.tabbed_panel_backward, this.keyboardShortcut.tabbed_panel_forward]}, // Main window panels + 'bindRightPanel': {'shortcuts': [this.keyboardShortcut.tabbed_panel_backward, this.keyboardShortcut.tabbed_panel_forward, this.keyboardShortcut.close_tab_panel]}, // Main window panels 'bindLeftTree': {'shortcuts': this.keyboardShortcut.left_tree_shortcut}, // Main menu, 'bindSubMenuQueryTool': {'shortcuts': this.keyboardShortcut.sub_menu_query_tool}, // Sub menu - Open Query Tool, 'bindSubMenuViewData': {'shortcuts': this.keyboardShortcut.sub_menu_view_data}, // Sub menu - Open View Data, @@ -189,6 +191,13 @@ _.extend(pgBrowser.keyboardNavigation, { _focusTab: function(dockLayoutTabs, activeTabIdx, shortcut_obj, combo){ if (combo.key === shortcut_obj.tabbed_panel_backward) activeTabIdx = (activeTabIdx + dockLayoutTabs.length - 1) % dockLayoutTabs.length; else if (combo.key === shortcut_obj.tabbed_panel_forward) activeTabIdx = (activeTabIdx + 1) % dockLayoutTabs.length; + else if (combo.key === shortcut_obj.close_tab_panel) { + const panelId = dockLayoutTabs[activeTabIdx].id?.slice(14); + if (panelId) { + pgAdmin.Browser.docker.close(panelId); + activeTabIdx = activeTabIdx % dockLayoutTabs.length; + } + } dockLayoutTabs[activeTabIdx]?.click(); dockLayoutTabs[activeTabIdx]?.focus(); },