Add support for showing pgAdmin shortcuts on Electron menus. #1923

This commit is contained in:
Aditya Toshniwal
2025-07-21 15:07:17 +05:30
parent 6dc5807192
commit bec47845be
9 changed files with 52 additions and 10 deletions
@@ -46,6 +46,12 @@ export default class MainMenuFactory {
});
}
static listenToElectronMenuClick() {
window.electronUI?.onMenuClick((menuName)=>{
MainMenuFactory.electronCallbacks[menuName]?.();
});
}
static createMainMenus() {
pgAdmin.Browser.MainMenus = [];
MAIN_MENUS.forEach((_menu) => {
@@ -61,10 +67,6 @@ export default class MainMenuFactory {
// enable disable will take care of dynamic menus.
MainMenuFactory.enableDisableMenus();
window.electronUI?.onMenuClick((menuName)=>{
MainMenuFactory.electronCallbacks[menuName]?.();
});
window.electronUI?.setMenus(MainMenuFactory.toElectron());
}
@@ -117,6 +119,7 @@ export default class MainMenuFactory {
};
let allMenus = pgAdmin.Browser?.all_menus_cache || {};
Object.values(allMenus).forEach(updateShortcuts);
MainMenuFactory.createMainMenus();
};
// Assign and Update menu shortcuts using preference.
+1
View File
@@ -375,6 +375,7 @@ define('pgadmin.browser', [
_m.callback = () => {
showQuickSearch();
};
_m.shortcut_preference =['browser', 'open_quick_search'];
}
return {
+4
View File
@@ -51,6 +51,10 @@ define('app', [
// Create menus after all modules are initialized.
MainMenuFactory.createMainMenus();
// Listen to menu click events and callback pgAdmin js code.
// This will be internally ignored if not running in electron.
MainMenuFactory.listenToElectronMenuClick();
const root = ReactDOM.createRoot(document.querySelector('#root'));
root.render(
<Theme>
@@ -85,7 +85,6 @@ export const PgMenuItem = (({hasCheck=false, checked=false, accesskey, shortcut,
<Box
sx={{
marginLeft: 'auto',
fontSize: '0.8em',
paddingLeft: '12px',
display: 'flex',
gap: '1px',
+1
View File
@@ -155,6 +155,7 @@ export class MenuItem {
priority: this.priority,
type: [true, false].includes(this.checked) ? 'checkbox' : this.type,
checked: this.checked,
shortcut: this.shortcut,
};
}