(pgadminMenus, pgAdminMainScreen)
| 32 | |
| 33 | // Binds click events to all menu and submenu items recursively. |
| 34 | function bindMenuClicks(pgadminMenus, pgAdminMainScreen) { |
| 35 | return pgadminMenus.map((menuItem) => ({ |
| 36 | ...menuItem, |
| 37 | submenu: menuItem.submenu?.map((subMenuItem) => { |
| 38 | const smName = `${menuItem.name}_${subMenuItem.name}`; |
| 39 | return { |
| 40 | ...subMenuItem, |
| 41 | accelerator: convertShortcutToAccelerator(subMenuItem.shortcut), |
| 42 | click: (_menuItem, _browserWindow, event)=>{ |
| 43 | if(event?.triggeredByAccelerator) { |
| 44 | // We will ignore the click event if it is triggered by an accelerator. |
| 45 | // We use accelerator to only show the shortcut title in the menu. |
| 46 | // The actual shortcut is already handled by pgAdmin. |
| 47 | return; |
| 48 | } |
| 49 | pgAdminMainScreen.webContents.send('menu-click', smName); |
| 50 | }, |
| 51 | submenu: subMenuItem.submenu?.map((deeperSubMenuItem) => ({ |
| 52 | ...deeperSubMenuItem, |
| 53 | accelerator: convertShortcutToAccelerator(deeperSubMenuItem.shortcut), |
| 54 | click: (_menuItem, _browserWindow, event)=>{ |
| 55 | if(event?.triggeredByAccelerator) { |
| 56 | // We will ignore the click event if it is triggered by an accelerator. |
| 57 | // We use accelerator to only show the shortcut title in the menu. |
| 58 | // The actual shortcut is already handled by pgAdmin. |
| 59 | return; |
| 60 | } |
| 61 | pgAdminMainScreen.webContents.send('menu-click', `${smName}_${deeperSubMenuItem.name}`); |
| 62 | }, |
| 63 | })), |
| 64 | }; |
| 65 | }), |
| 66 | })); |
| 67 | } |
| 68 | |
| 69 | // Handles auto-update related menu items for macOS. |
| 70 | // Adds or disables update menu items based on config state. |
no test coverage detected