mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-08-19 01:15:04 -05:00
Add support for showing pgAdmin shortcuts on Electron menus. #1923
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -375,6 +375,7 @@ define('pgadmin.browser', [
|
||||
_m.callback = () => {
|
||||
showQuickSearch();
|
||||
};
|
||||
_m.shortcut_preference =['browser', 'open_quick_search'];
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user