1) Fix the tabbed panel backward/forward shortcut for tabs. #6808
2) Remove shortcuts for the dialog tab backward/forward. 3) Used hotkeys.js in place of mousetrap for listening to keyboard shortcuts.pull/7190/head^2
parent
9ad223c41c
commit
47b2bc8a83
|
@ -26,10 +26,6 @@ When using main browser window, the following keyboard shortcuts are available:
|
||||||
+----------------------------+-------------------------------------------------------+
|
+----------------------------+-------------------------------------------------------+
|
||||||
| Shift+Alt+d | Delete object |
|
| Shift+Alt+d | Delete object |
|
||||||
+----------------------------+-------------------------------------------------------+
|
+----------------------------+-------------------------------------------------------+
|
||||||
| Shift+Ctrl+[ | Dialog tab backward |
|
|
||||||
+----------------------------+-------------------------------------------------------+
|
|
||||||
| Shift+Ctrl+] | Dialog tab forward |
|
|
||||||
+----------------------------+-------------------------------------------------------+
|
|
||||||
| Shift+Alt+g | Direct debugging |
|
| Shift+Alt+g | Direct debugging |
|
||||||
+----------------------------+-------------------------------------------------------+
|
+----------------------------+-------------------------------------------------------+
|
||||||
| Shift+Alt+e | Edit object properties |
|
| Shift+Alt+e | Edit object properties |
|
||||||
|
@ -59,23 +55,6 @@ When using main browser window, the following keyboard shortcuts are available:
|
||||||
| Shift+Alt+v | View data |
|
| Shift+Alt+v | View data |
|
||||||
+----------------------------+-------------------------------------------------------+
|
+----------------------------+-------------------------------------------------------+
|
||||||
|
|
||||||
Dialog Tabs
|
|
||||||
***********
|
|
||||||
|
|
||||||
Use the shortcuts below to navigate the tabsets on dialogs:
|
|
||||||
|
|
||||||
.. table::
|
|
||||||
:class: longtable
|
|
||||||
:widths: 2 3
|
|
||||||
|
|
||||||
+----------------------------+-------------------------------------------------------+
|
|
||||||
| Shortcut for all platforms | Function |
|
|
||||||
+============================+=======================================================+
|
|
||||||
| Control+Shift+[ | Dialog tab backward |
|
|
||||||
+----------------------------+-------------------------------------------------------+
|
|
||||||
| Control+Shift+] | Dialog tab forward |
|
|
||||||
+----------------------------+-------------------------------------------------------+
|
|
||||||
|
|
||||||
Property Grid Controls
|
Property Grid Controls
|
||||||
**********************
|
**********************
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@
|
||||||
"dagre": "^0.8.4",
|
"dagre": "^0.8.4",
|
||||||
"date-fns": "^2.24.0",
|
"date-fns": "^2.24.0",
|
||||||
"diff-arrays-of-objects": "^1.1.8",
|
"diff-arrays-of-objects": "^1.1.8",
|
||||||
|
"hotkeys-js": "^3.13.3",
|
||||||
"html-to-image": "^1.11.11",
|
"html-to-image": "^1.11.11",
|
||||||
"immutability-helper": "^3.0.0",
|
"immutability-helper": "^3.0.0",
|
||||||
"insert-if": "^1.1.0",
|
"insert-if": "^1.1.0",
|
||||||
|
@ -119,7 +120,6 @@
|
||||||
"ml-matrix": "^6.5.0",
|
"ml-matrix": "^6.5.0",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"moment-timezone": "^0.5.34",
|
"moment-timezone": "^0.5.34",
|
||||||
"mousetrap": "^1.6.3",
|
|
||||||
"notificar": "^1.0.1",
|
"notificar": "^1.0.1",
|
||||||
"notistack": "^1.0.10",
|
"notistack": "^1.0.10",
|
||||||
"path-fx": "^2.0.0",
|
"path-fx": "^2.0.0",
|
||||||
|
|
|
@ -352,36 +352,6 @@ def register_browser_preferences(self):
|
||||||
fields=fields
|
fields=fields
|
||||||
)
|
)
|
||||||
|
|
||||||
self.preference.register(
|
|
||||||
'keyboard_shortcuts',
|
|
||||||
'dialog_tab_forward',
|
|
||||||
gettext('Dialog tab forward'),
|
|
||||||
'keyboardshortcut',
|
|
||||||
{
|
|
||||||
'alt': False,
|
|
||||||
'shift': True,
|
|
||||||
'control': True,
|
|
||||||
'key': {'key_code': 93, 'char': ']'}
|
|
||||||
},
|
|
||||||
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
|
|
||||||
fields=fields
|
|
||||||
)
|
|
||||||
|
|
||||||
self.preference.register(
|
|
||||||
'keyboard_shortcuts',
|
|
||||||
'dialog_tab_backward',
|
|
||||||
gettext('Dialog tab backward'),
|
|
||||||
'keyboardshortcut',
|
|
||||||
{
|
|
||||||
'alt': False,
|
|
||||||
'shift': True,
|
|
||||||
'control': True,
|
|
||||||
'key': {'key_code': 91, 'char': '['}
|
|
||||||
},
|
|
||||||
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
|
|
||||||
fields=fields
|
|
||||||
)
|
|
||||||
|
|
||||||
self.preference.register(
|
self.preference.register(
|
||||||
'keyboard_shortcuts',
|
'keyboard_shortcuts',
|
||||||
'sub_menu_refresh',
|
'sub_menu_refresh',
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import pgAdmin from '../../../static/js/pgadmin';
|
import pgAdmin from '../../../static/js/pgadmin';
|
||||||
import Mousetrap from 'mousetrap';
|
import hotkeys from 'hotkeys-js';
|
||||||
import * as commonUtils from '../../../static/js/utils';
|
import * as commonUtils from '../../../static/js/utils';
|
||||||
import gettext from 'sources/gettext';
|
import gettext from 'sources/gettext';
|
||||||
import pgWindow from 'sources/window';
|
import pgWindow from 'sources/window';
|
||||||
|
@ -19,30 +19,39 @@ const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
||||||
|
|
||||||
pgBrowser.keyboardNavigation = pgBrowser.keyboardNavigation || {};
|
pgBrowser.keyboardNavigation = pgBrowser.keyboardNavigation || {};
|
||||||
|
|
||||||
|
hotkeys.filter = function () {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
_.extend(pgBrowser.keyboardNavigation, {
|
_.extend(pgBrowser.keyboardNavigation, {
|
||||||
|
iframeEventsChannel:new BroadcastChannel('iframe-events'),
|
||||||
init: function() {
|
init: function() {
|
||||||
|
this.iframeEventsChannel.onmessage = (ev) =>{
|
||||||
|
hotkeys.trigger(ev.data);
|
||||||
|
};
|
||||||
|
|
||||||
usePreferences.subscribe((prefStore)=>{
|
usePreferences.subscribe((prefStore)=>{
|
||||||
Mousetrap.reset();
|
hotkeys.unbind();
|
||||||
if (prefStore.version > 0) {
|
if (prefStore.version > 0) {
|
||||||
this.keyboardShortcut = {
|
this.keyboardShortcut = {
|
||||||
...(prefStore.getPreferences('browser', 'main_menu_file')?.value) && {'file_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'main_menu_file')?.value)},
|
...(prefStore.getPreferences('browser', 'main_menu_file')?.value) && {'file_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'main_menu_file')?.value)},
|
||||||
...(prefStore.getPreferences('browser', 'main_menu_object')?.value) && {'object_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'main_menu_object')?.value)},
|
...(prefStore.getPreferences('browser', 'main_menu_object')?.value) && {'object_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'main_menu_object')?.value)},
|
||||||
...(prefStore.getPreferences('browser', 'main_menu_tools')?.value) && {'tools_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'main_menu_tools')?.value)},
|
...(prefStore.getPreferences('browser', 'main_menu_tools')?.value) && {'tools_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'main_menu_tools')?.value)},
|
||||||
...(prefStore.getPreferences('browser', 'main_menu_help')?.value) && {'help_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'main_menu_help')?.value)},
|
...(prefStore.getPreferences('browser', 'main_menu_help')?.value) && {'help_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'main_menu_help')?.value)},
|
||||||
'left_tree_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'browser_tree').value),
|
'left_tree_shortcut': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'browser_tree')?.value),
|
||||||
'tabbed_panel_backward': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'tabbed_panel_backward').value),
|
'tabbed_panel_backward': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'tabbed_panel_backward')?.value),
|
||||||
'tabbed_panel_forward': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'tabbed_panel_forward').value),
|
'tabbed_panel_forward': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'tabbed_panel_forward')?.value),
|
||||||
'sub_menu_query_tool': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_query_tool').value),
|
'sub_menu_query_tool': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_query_tool')?.value),
|
||||||
'sub_menu_view_data': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_view_data').value),
|
'sub_menu_view_data': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_view_data')?.value),
|
||||||
'sub_menu_search_objects': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_search_objects').value),
|
'sub_menu_search_objects': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_search_objects')?.value),
|
||||||
'sub_menu_properties': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_properties').value),
|
'sub_menu_properties': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_properties')?.value),
|
||||||
'sub_menu_create': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_create').value),
|
'sub_menu_create': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_create')?.value),
|
||||||
'sub_menu_delete': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_delete').value),
|
'sub_menu_delete': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_delete')?.value),
|
||||||
'sub_menu_refresh': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_refresh').value),
|
'sub_menu_refresh': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'sub_menu_refresh')?.value),
|
||||||
'context_menu': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'context_menu').value),
|
'context_menu': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'context_menu')?.value),
|
||||||
'direct_debugging': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'direct_debugging').value),
|
'direct_debugging': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'direct_debugging')?.value),
|
||||||
'add_grid_row': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'add_grid_row').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),
|
'open_quick_search': commonUtils.parseShortcutValue(prefStore.getPreferences('browser', 'open_quick_search')?.value),
|
||||||
|
|
||||||
};
|
};
|
||||||
this.shortcutMethods = {
|
this.shortcutMethods = {
|
||||||
|
@ -65,43 +74,58 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||||
'bindAddGridRow': {'shortcuts': this.keyboardShortcut.add_grid_row}, // Subnode Grid Add Row
|
'bindAddGridRow': {'shortcuts': this.keyboardShortcut.add_grid_row}, // Subnode Grid Add Row
|
||||||
'bindOpenQuickSearch': {'shortcuts': this.keyboardShortcut.open_quick_search}, // Subnode Grid Refresh Row
|
'bindOpenQuickSearch': {'shortcuts': this.keyboardShortcut.open_quick_search}, // Subnode Grid Refresh Row
|
||||||
};
|
};
|
||||||
|
this.shortcutsString=Object.values(this.shortcutMethods).map(i=>i.shortcuts).join(',');
|
||||||
|
// Checks if the tab is iframe or not, if iframe then calls the function 'setupIframeEventsBroadcast'
|
||||||
|
if (window.self != window.top) {
|
||||||
|
this.setupIframeEventsBroadcast();
|
||||||
|
} else {
|
||||||
this.bindShortcuts();
|
this.bindShortcuts();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//Sends the pressed keyboard shortcut from iframe to parent
|
||||||
|
triggerIframeEventsBroadcast: function(event,checkShortcuts=false){
|
||||||
|
const shortcut = {
|
||||||
|
alt:event?.altKey,
|
||||||
|
shift:event?.shiftKey,
|
||||||
|
control:event?.ctrlKey,
|
||||||
|
key:{
|
||||||
|
char:event?.key
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const currShortcutString = commonUtils.parseShortcutValue(shortcut);
|
||||||
|
if (checkShortcuts && !this.shortcutsString.split(',').includes(currShortcutString)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.iframeEventsChannel.postMessage(currShortcutString);
|
||||||
|
},
|
||||||
|
//listens to keyboard events and triggers the 'triggerIframeEventsBroadcast' for shortcuts
|
||||||
|
setupIframeEventsBroadcast:function() {
|
||||||
|
const self=this;
|
||||||
|
hotkeys(self.shortcutsString,(event)=>{
|
||||||
|
this.triggerIframeEventsBroadcast(event);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
bindShortcuts: function() {
|
bindShortcuts: function() {
|
||||||
const self = this;
|
const self = this;
|
||||||
_.each(self.shortcutMethods, (keyCombo, callback) => {
|
_.each(self.shortcutMethods, (keyCombo, callback) => {
|
||||||
self._bindWithMousetrap(keyCombo.shortcuts, self[callback], keyCombo.bindElem);
|
self._bindWithHotkeys(keyCombo.shortcuts, self[callback]);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_bindWithMousetrap: function(shortcuts, callback, bindElem) {
|
_bindWithHotkeys: function(shortcuts, callback) {
|
||||||
const self = this;
|
const self = this;
|
||||||
shortcuts ?? Mousetrap.unbind(shortcuts);
|
hotkeys(shortcuts.toString(), function (event, combo) {
|
||||||
if (bindElem) {
|
if(!combo){
|
||||||
const elem = document.querySelector(bindElem);
|
combo = this;
|
||||||
Mousetrap(elem).bind(shortcuts, function() {
|
|
||||||
callback.apply(this, arguments);
|
|
||||||
}.bind(elem));
|
|
||||||
} else {
|
|
||||||
Mousetrap.bind(shortcuts, function () {
|
|
||||||
callback.apply(self, arguments);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
callback.apply(self, [event, combo]);
|
||||||
unbindShortcuts: function() {
|
|
||||||
// Reset previous events on each instance
|
|
||||||
const self = this;
|
|
||||||
_.each(self.mousetrapInstances, (obj) => {
|
|
||||||
obj['instance'].reset();
|
|
||||||
});
|
});
|
||||||
// Clear already processed events
|
|
||||||
self.mousetrapInstances = [];
|
|
||||||
},
|
},
|
||||||
bindMainMenu: function(event, combo) {
|
bindMainMenu: function(event, combo) {
|
||||||
const shortcut_obj = this.keyboardShortcut;
|
const shortcut_obj = this.keyboardShortcut;
|
||||||
let menuLabel = null;
|
let menuLabel = null;
|
||||||
switch (combo) {
|
switch (combo.key) {
|
||||||
case shortcut_obj.file_shortcut:
|
case shortcut_obj.file_shortcut:
|
||||||
menuLabel = gettext('File');
|
menuLabel = gettext('File');
|
||||||
break;
|
break;
|
||||||
|
@ -123,35 +147,57 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
bindRightPanel: function(event, combo) {
|
bindRightPanel: function(event, combo) {
|
||||||
let allPanels = pgAdmin.Browser.docker.findPanels();
|
const self = this;
|
||||||
let activePanel = 0;
|
let dockLayoutTabs = document.activeElement?.closest('.dock-layout')?.querySelectorAll('.dock-tab-btn');
|
||||||
let nextPanel = allPanels.length - 1;
|
|
||||||
let prevPanel = 1;
|
|
||||||
let activePanelId = 0;
|
|
||||||
let activePanelFlag = false;
|
|
||||||
let shortcut_obj = this.keyboardShortcut;
|
let shortcut_obj = this.keyboardShortcut;
|
||||||
|
//if the focus is on the tab button
|
||||||
_.each(pgAdmin.Browser.docker.findPanels(), (panel, index) => {
|
if (document.activeElement.closest('.dock-tab-btn')) {
|
||||||
if (panel.isVisible() && !activePanelFlag && panel._type !== 'browser') {
|
let currDockTab = document.activeElement?.closest('.dock-tab-btn');
|
||||||
activePanelId = index;
|
if(dockLayoutTabs?.length > 1 && currDockTab) {
|
||||||
activePanelFlag = true;
|
for(let i=0; i<dockLayoutTabs.length; i++) {
|
||||||
|
if(dockLayoutTabs[i] == currDockTab) {
|
||||||
|
let activeTabIdx = i;
|
||||||
|
self._focusTab(dockLayoutTabs, activeTabIdx, shortcut_obj, combo);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (combo === shortcut_obj.tabbed_panel_backward) activePanel = (activePanelId > 0) ? activePanelId - 1 : prevPanel;
|
|
||||||
else if (combo === shortcut_obj.tabbed_panel_forward) activePanel = (activePanelId < nextPanel) ? activePanelId + 1 : nextPanel;
|
|
||||||
|
|
||||||
pgAdmin.Browser.docker.findPanels()[activePanel].focus();
|
|
||||||
setTimeout(() => {
|
|
||||||
if (document.activeElement instanceof HTMLIFrameElement) {
|
|
||||||
document.activeElement.blur();
|
|
||||||
}
|
}
|
||||||
}, 1000);
|
}
|
||||||
|
//if the tab is a iframe or the focus is within the content of tab
|
||||||
|
} else if (document.activeElement.nodeName === 'IFRAME' || document.activeElement.closest('.dock-tabpane.dock-tabpane-active')?.id) {
|
||||||
|
let activeTabId = '';
|
||||||
|
//if the tab is a iframe
|
||||||
|
if (document.activeElement.nodeName === 'IFRAME'){
|
||||||
|
dockLayoutTabs = document.activeElement?.closest('#root')?.querySelectorAll('.dock-tab-btn');
|
||||||
|
activeTabId = document.activeElement?.id;
|
||||||
|
//if the focus is within the content of tab
|
||||||
|
} else if (document.activeElement.closest('.dock-tabpane.dock-tabpane-active')?.id){
|
||||||
|
activeTabId = document.activeElement.closest('.dock-tabpane.dock-tabpane-active')?.id;
|
||||||
|
}
|
||||||
|
if(dockLayoutTabs?.length > 1 && activeTabId) {
|
||||||
|
for(let i=0; i<dockLayoutTabs.length; i++) {
|
||||||
|
let tabIdx = i;
|
||||||
|
let tabId = dockLayoutTabs[tabIdx].id?.slice(14);
|
||||||
|
if (tabId == activeTabId) {
|
||||||
|
self._focusTab(dockLayoutTabs, tabIdx, shortcut_obj, combo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if the focus is on the body or on the menu bar
|
||||||
|
} else if (document.activeElement === document.body || document.querySelector('div[data-test="app-menu-bar"]')) {
|
||||||
|
pgAdmin.Browser.docker.navigatePanel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_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;
|
||||||
|
dockLayoutTabs[activeTabIdx]?.click();
|
||||||
|
dockLayoutTabs[activeTabIdx]?.focus();
|
||||||
},
|
},
|
||||||
bindLeftTree: function() {
|
bindLeftTree: function() {
|
||||||
const tree = this.getTreeDetails();
|
const tree = this.getTreeDetails();
|
||||||
|
|
||||||
document.querySelector('[id="tree"]').focus();
|
document.querySelector('[id="id-object-explorer"]').focus();
|
||||||
tree.t.select(tree.i);
|
tree.t.select(tree.i);
|
||||||
},
|
},
|
||||||
bindSubMenuQueryTool: function() {
|
bindSubMenuQueryTool: function() {
|
||||||
|
@ -220,7 +266,7 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||||
pgAdmin.Browser.Node.callbacks.delete_obj.call(pgAdmin.Browser.Nodes[tree.t.itemData(tree.i)._type]);
|
pgAdmin.Browser.Node.callbacks.delete_obj.call(pgAdmin.Browser.Nodes[tree.t.itemData(tree.i)._type]);
|
||||||
},
|
},
|
||||||
bindSubMenuRefresh: function(event) {
|
bindSubMenuRefresh: function(event) {
|
||||||
event.preventDefault();
|
event?.preventDefault();
|
||||||
const tree = pgBrowser.keyboardNavigation.getTreeDetails();
|
const tree = pgBrowser.keyboardNavigation.getTreeDetails();
|
||||||
|
|
||||||
// Call refresh object callback
|
// Call refresh object callback
|
||||||
|
|
|
@ -116,6 +116,11 @@ export class LayoutDocker {
|
||||||
this.layoutObj.updateTab(panelId, null, true);
|
this.layoutObj.updateTab(panelId, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//it will navigate to nearest panel/tab
|
||||||
|
navigatePanel() {
|
||||||
|
this.layoutObj.navigateToPanel();
|
||||||
|
}
|
||||||
|
|
||||||
find(...args) {
|
find(...args) {
|
||||||
return this.layoutObj?.find(...args);
|
return this.layoutObj?.find(...args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,13 @@ import pgAdmin from 'sources/pgadmin';
|
||||||
|
|
||||||
export function parseShortcutValue(obj) {
|
export function parseShortcutValue(obj) {
|
||||||
let shortcut = '';
|
let shortcut = '';
|
||||||
|
if (!obj){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (obj.alt) { shortcut += 'alt+'; }
|
if (obj.alt) { shortcut += 'alt+'; }
|
||||||
if (obj.shift) { shortcut += 'shift+'; }
|
if (obj.shift) { shortcut += 'shift+'; }
|
||||||
if (obj.control) { shortcut += 'ctrl+'; }
|
if (obj.control) { shortcut += 'ctrl+'; }
|
||||||
shortcut += obj.key.char.toLowerCase();
|
shortcut += obj?.key.char?.toLowerCase();
|
||||||
return shortcut;
|
return shortcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ export default class ERDModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadComponent(container, params) {
|
async loadComponent(container, params) {
|
||||||
|
pgAdmin.Browser.keyboardNavigation.init();
|
||||||
await listenPreferenceBroadcast();
|
await listenPreferenceBroadcast();
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Theme>
|
<Theme>
|
||||||
|
|
|
@ -17,9 +17,8 @@ import pgWindow from 'sources/window';
|
||||||
import { copyToClipboard } from '../../../../static/js/clipboard';
|
import { copyToClipboard } from '../../../../static/js/clipboard';
|
||||||
import {generateTitle, refresh_db_node} from 'tools/sqleditor/static/js/sqleditor_title';
|
import {generateTitle, refresh_db_node} from 'tools/sqleditor/static/js/sqleditor_title';
|
||||||
import { BROWSER_PANELS } from '../../../../browser/static/js/constants';
|
import { BROWSER_PANELS } from '../../../../browser/static/js/constants';
|
||||||
import usePreferences from '../../../../preferences/static/js/store';
|
import usePreferences,{ listenPreferenceBroadcast } from '../../../../preferences/static/js/store';
|
||||||
|
import 'pgadmin.browser.keyboard';
|
||||||
|
|
||||||
export function setPanelTitle(psqlToolPanel, panelTitle) {
|
export function setPanelTitle(psqlToolPanel, panelTitle) {
|
||||||
psqlToolPanel.title('<span title="'+_.escape(panelTitle)+'">'+_.escape(panelTitle)+'</span>');
|
psqlToolPanel.title('<span title="'+_.escape(panelTitle)+'">'+_.escape(panelTitle)+'</span>');
|
||||||
}
|
}
|
||||||
|
@ -261,6 +260,8 @@ export function initialize(gettext, url_for, _, pgAdmin, csrfToken, Browser) {
|
||||||
pgAdmin.Browser.notifier.alert(gettext('Clipboard write permission required'), gettext('To copy data from PSQL terminal, Clipboard write permission required.'));
|
pgAdmin.Browser.notifier.alert(gettext('Clipboard write permission required'), gettext('To copy data from PSQL terminal, Clipboard write permission required.'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
self.pgAdmin.Browser.keyboardNavigation.triggerIframeEventsBroadcast(e,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !(e.ctrlKey && platform == 'win32');
|
return !(e.ctrlKey && platform == 'win32');
|
||||||
|
@ -297,6 +298,44 @@ export function initialize(gettext, url_for, _, pgAdmin, csrfToken, Browser) {
|
||||||
refresh_db_node(message, dbNode);
|
refresh_db_node(message, dbNode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
psql_mount: async function(params){
|
||||||
|
self.pgAdmin.Browser.keyboardNavigation.init();
|
||||||
|
await listenPreferenceBroadcast();
|
||||||
|
const term = self.pgAdmin.Browser.psql.psql_terminal();
|
||||||
|
/* Addon for fitAddon, webLinkAddon, SearchAddon */
|
||||||
|
const fitAddon = self.pgAdmin.Browser.psql.psql_Addon(term);
|
||||||
|
/* Update the theme for terminal as per pgAdmin 4 theme. */
|
||||||
|
self.pgAdmin.Browser.psql.set_theme(term);
|
||||||
|
/* Open the terminal */
|
||||||
|
term.open(document.getElementById('psql-terminal'));
|
||||||
|
/* Socket */
|
||||||
|
const socket = self.pgAdmin.Browser.psql.psql_socket();
|
||||||
|
self.pgAdmin.Browser.psql.psql_socket_io(socket, params.is_enable, params.sid, params.db, params.server_type, fitAddon, term, params.role);
|
||||||
|
|
||||||
|
self.pgAdmin.Browser.psql.psql_terminal_io(term, socket, params.platform);
|
||||||
|
self.pgAdmin.Browser.psql.check_db_name_change(params.db, params.o_db_name);
|
||||||
|
/* Set terminal size */
|
||||||
|
setTimeout(function(){
|
||||||
|
socket.emit('resize', {'cols': term.cols, 'rows': term.rows});
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
/* Resize the terminal */
|
||||||
|
function fitToscreen(){
|
||||||
|
fitAddon.fit();
|
||||||
|
socket.emit('resize', {'cols': term.cols, 'rows': term.rows});
|
||||||
|
}
|
||||||
|
|
||||||
|
function debounce(func, wait_ms) {
|
||||||
|
let timeout;
|
||||||
|
return function(...args) {
|
||||||
|
const context = this;
|
||||||
|
clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(() => func.apply(context, args), wait_ms);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onresize = debounce(fitToscreen, 25);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return pgBrowser.psql;
|
return pgBrowser.psql;
|
||||||
|
|
|
@ -19,40 +19,16 @@
|
||||||
require(
|
require(
|
||||||
['sources/generated/psql_tool'],
|
['sources/generated/psql_tool'],
|
||||||
function(pgBrowser) {
|
function(pgBrowser) {
|
||||||
const term = self.pgAdmin.Browser.psql.psql_terminal();
|
<!-- Call the PSQL mount-->
|
||||||
<!--Addon for fitAddon, webLinkAddon, SearchAddon -->
|
self.pgAdmin.Browser.psql.psql_mount({
|
||||||
const fitAddon = self.pgAdmin.Browser.psql.psql_Addon(term);
|
"is_enable": '{{is_enable}}',
|
||||||
<!-- Update the theme for terminal as per pgAdmin 4 theme.-->
|
"sid": '{{sid}}',
|
||||||
self.pgAdmin.Browser.psql.set_theme(term);
|
"db":'{{db|safe}}',
|
||||||
<!-- Open the terminal -->
|
"server_type": '{{server_type}}',
|
||||||
term.open(document.getElementById('psql-terminal'));
|
"role": '{{role|safe}}',
|
||||||
<!-- Socket-->
|
"platform": '{{platform}}',
|
||||||
const socket = self.pgAdmin.Browser.psql.psql_socket();
|
"o_db_name": '{{o_db_name|safe}}'
|
||||||
self.pgAdmin.Browser.psql.psql_socket_io(socket, '{{is_enable}}', '{{sid}}', '{{db|safe}}', '{{server_type}}', fitAddon, term, '{{role|safe}}');
|
})
|
||||||
self.pgAdmin.Browser.psql.psql_terminal_io(term, socket, '{{platform}}');
|
|
||||||
self.pgAdmin.Browser.psql.check_db_name_change('{{db|safe}}', '{{o_db_name|safe}}');
|
|
||||||
<!-- Set terminal size -->
|
|
||||||
setTimeout(function(){
|
|
||||||
socket.emit("resize", {"cols": term.cols, "rows": term.rows})
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
<!-- Resize the terminal -->
|
|
||||||
function fitToscreen(){
|
|
||||||
fitAddon.fit()
|
|
||||||
socket.emit("resize", {"cols": term.cols, "rows": term.rows})
|
|
||||||
}
|
|
||||||
|
|
||||||
function debounce(func, wait_ms) {
|
|
||||||
let timeout
|
|
||||||
return function(...args) {
|
|
||||||
const context = this
|
|
||||||
clearTimeout(timeout)
|
|
||||||
timeout = setTimeout(() => func.apply(context, args), wait_ms)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const wait_ms = 25;
|
|
||||||
window.onresize = debounce(fitToscreen, wait_ms);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import usePreferences, { listenPreferenceBroadcast } from '../../../../preferenc
|
||||||
import pgAdmin from 'sources/pgadmin';
|
import pgAdmin from 'sources/pgadmin';
|
||||||
import { PgAdminContext } from '../../../../static/js/BrowserComponent';
|
import { PgAdminContext } from '../../../../static/js/BrowserComponent';
|
||||||
|
|
||||||
|
|
||||||
export default class SchemaDiff {
|
export default class SchemaDiff {
|
||||||
static instance;
|
static instance;
|
||||||
|
|
||||||
|
@ -101,6 +100,7 @@ export default class SchemaDiff {
|
||||||
}
|
}
|
||||||
|
|
||||||
async load(container, trans_id) {
|
async load(container, trans_id) {
|
||||||
|
pgAdmin.Browser.keyboardNavigation.init();
|
||||||
await listenPreferenceBroadcast();
|
await listenPreferenceBroadcast();
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
|
|
|
@ -226,6 +226,7 @@ export default class SQLEditor {
|
||||||
let selectedNodeInfo = pgWindow.pgAdmin.Browser.tree.getTreeNodeHierarchy(
|
let selectedNodeInfo = pgWindow.pgAdmin.Browser.tree.getTreeNodeHierarchy(
|
||||||
pgWindow.pgAdmin.Browser.tree.selected()
|
pgWindow.pgAdmin.Browser.tree.selected()
|
||||||
);
|
);
|
||||||
|
pgAdmin.Browser.keyboardNavigation.init();
|
||||||
await listenPreferenceBroadcast();
|
await listenPreferenceBroadcast();
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Theme>
|
<Theme>
|
||||||
|
|
|
@ -9160,6 +9160,13 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"hotkeys-js@npm:^3.13.3":
|
||||||
|
version: 3.13.3
|
||||||
|
resolution: "hotkeys-js@npm:3.13.3"
|
||||||
|
checksum: fdd2b088671dbf2b2434ba40a4d604bf3f5cbe2f121233f8474f493a557d8a1cced0f1cb0c812b62e34ee9c2ad4ec6c4fd25035aa836ebe12da5dfa11f5afc2d
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"html-dom-parser@npm:5.0.4":
|
"html-dom-parser@npm:5.0.4":
|
||||||
version: 5.0.4
|
version: 5.0.4
|
||||||
resolution: "html-dom-parser@npm:5.0.4"
|
resolution: "html-dom-parser@npm:5.0.4"
|
||||||
|
@ -11898,13 +11905,6 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"mousetrap@npm:^1.6.3":
|
|
||||||
version: 1.6.5
|
|
||||||
resolution: "mousetrap@npm:1.6.5"
|
|
||||||
checksum: 1ce36af5ac57e1fab687e3da004cc18914275f8ceef33f16d01110edc5126a5dbaace578b1e61179f93a506e71a88fe886f305db537a3673cf9f73affd1dffa6
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"mozjpeg@npm:^8.0.0":
|
"mozjpeg@npm:^8.0.0":
|
||||||
version: 8.0.0
|
version: 8.0.0
|
||||||
resolution: "mozjpeg@npm:8.0.0"
|
resolution: "mozjpeg@npm:8.0.0"
|
||||||
|
@ -14867,6 +14867,7 @@ __metadata:
|
||||||
eslint-plugin-react: ^7.33.2
|
eslint-plugin-react: ^7.33.2
|
||||||
eslint-plugin-react-hooks: ^4.3.0
|
eslint-plugin-react-hooks: ^4.3.0
|
||||||
exports-loader: ^4.0.0
|
exports-loader: ^4.0.0
|
||||||
|
hotkeys-js: ^3.13.3
|
||||||
html-react-parser: ^5.0.6
|
html-react-parser: ^5.0.6
|
||||||
html-to-image: ^1.11.11
|
html-to-image: ^1.11.11
|
||||||
image-minimizer-webpack-plugin: ^3.8.2
|
image-minimizer-webpack-plugin: ^3.8.2
|
||||||
|
@ -14889,7 +14890,6 @@ __metadata:
|
||||||
ml-matrix: ^6.5.0
|
ml-matrix: ^6.5.0
|
||||||
moment: ^2.29.4
|
moment: ^2.29.4
|
||||||
moment-timezone: ^0.5.34
|
moment-timezone: ^0.5.34
|
||||||
mousetrap: ^1.6.3
|
|
||||||
notificar: ^1.0.1
|
notificar: ^1.0.1
|
||||||
notistack: ^1.0.10
|
notistack: ^1.0.10
|
||||||
path-fx: ^2.0.0
|
path-fx: ^2.0.0
|
||||||
|
|
Loading…
Reference in New Issue