mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
* [AI] Desktop client, E2E, loot-core, sync-server and tooling updates Co-authored-by: Cursor <cursoragent@cursor.com> * Refactor database handling in various modules to use async/await for improved readability and error handling. This includes updates to database opening and closing methods across multiple files, ensuring consistent asynchronous behavior. Additionally, minor adjustments were made to encryption functions to support async operations. * Refactor sync migration tests to utilize async/await for improved readability. Updated transaction handling to streamline event expectations and cleanup process. * Refactor various functions to utilize async/await for improved readability and error handling. Updated service stopping, encryption, and file upload/download methods to ensure consistent asynchronous behavior across the application. * Refactor BudgetFileSelection component to use async/await for onSelect method, enhancing error handling and readability. Update merge tests to utilize async/await for improved clarity in transaction merging expectations. * Refactor filesystem module to use async/await for init function and related database operations, enhancing error handling and consistency across file interactions. Updated tests to reflect asynchronous behavior in database operations and file writing. * Fix typo in init function declaration to ensure it returns a Promise<void> instead of Proise<void>. * Update VRT screenshots Auto-generated by VRT workflow PR: #6987 * Update tests to use async/await for init function in web filesystem, ensuring consistent asynchronous behavior in database operations. * Update VRT screenshot for payees filter test to reflect recent changes * [AI] Fix no-floating-promises lint error in desktop-electron Wrapped queuedClientWinLogs.map() with Promise.all and void operator to properly handle the array of promises for executing queued logs. Co-authored-by: Matiss Janis Aboltins <MatissJanis@users.noreply.github.com> * Refactor promise handling in global and sync event handlers * Update VRT screenshots Auto-generated by VRT workflow PR: #6987 --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Matiss Janis Aboltins <MatissJanis@users.noreply.github.com>
179 lines
3.9 KiB
TypeScript
179 lines
3.9 KiB
TypeScript
import { app, Menu } from 'electron';
|
|
import type { BrowserWindow, MenuItemConstructorOptions } from 'electron';
|
|
|
|
export function getMenu() {
|
|
const template: MenuItemConstructorOptions[] = [
|
|
{
|
|
label: 'File', // Kept purely for the keyboard shortcuts in Electron. Some shortcuts only work if they are in a menu (toggle devtools cannot be triggered in pure js).
|
|
submenu: [
|
|
{
|
|
label: 'Exit',
|
|
click(_item, focusedWindow) {
|
|
if (focusedWindow) {
|
|
const browserWindow = focusedWindow as BrowserWindow;
|
|
browserWindow.close();
|
|
}
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: 'View',
|
|
submenu: [
|
|
{
|
|
label: 'Reload',
|
|
accelerator: 'CmdOrCtrl+R',
|
|
click(_item, focusedWindow) {
|
|
if (focusedWindow) {
|
|
const browserWindow = focusedWindow as BrowserWindow;
|
|
browserWindow.reload();
|
|
}
|
|
},
|
|
},
|
|
{
|
|
label: 'Toggle Developer Tools',
|
|
accelerator:
|
|
process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
|
click(_item, focusedWindow) {
|
|
if (focusedWindow) {
|
|
const browserWindow = focusedWindow as BrowserWindow;
|
|
browserWindow.webContents.toggleDevTools();
|
|
}
|
|
},
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'resetZoom',
|
|
},
|
|
{
|
|
role: 'zoomIn',
|
|
},
|
|
{
|
|
role: 'zoomOut',
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'togglefullscreen',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: 'Edit',
|
|
submenu: [
|
|
{
|
|
label: 'Undo',
|
|
enabled: false,
|
|
accelerator: 'CmdOrCtrl+Z',
|
|
click: function (_menuItem, focusedWin) {
|
|
// Undo
|
|
if (focusedWin) {
|
|
void (focusedWin as BrowserWindow).webContents.executeJavaScript(
|
|
'__actionsForMenu.undo()',
|
|
);
|
|
}
|
|
},
|
|
},
|
|
{
|
|
label: 'Redo',
|
|
enabled: false,
|
|
accelerator: 'Shift+CmdOrCtrl+Z',
|
|
click: function (_menuItem, focusedWin) {
|
|
// Redo
|
|
if (focusedWin) {
|
|
void (focusedWin as BrowserWindow).webContents.executeJavaScript(
|
|
'__actionsForMenu.redo()',
|
|
);
|
|
}
|
|
},
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'cut',
|
|
},
|
|
{
|
|
role: 'copy',
|
|
},
|
|
{
|
|
role: 'paste',
|
|
},
|
|
{
|
|
role: 'pasteAndMatchStyle',
|
|
},
|
|
{
|
|
role: 'delete',
|
|
},
|
|
{
|
|
role: 'selectAll',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
role: 'window',
|
|
submenu: [
|
|
{
|
|
role: 'minimize',
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
if (process.platform === 'darwin') {
|
|
// Mac specific menu
|
|
const name = app.getName();
|
|
template.unshift({
|
|
label: name,
|
|
submenu: [
|
|
{
|
|
role: 'hide',
|
|
},
|
|
{
|
|
role: 'hideOthers',
|
|
},
|
|
{
|
|
role: 'unhide',
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'quit',
|
|
},
|
|
],
|
|
});
|
|
|
|
// Window menu
|
|
const windowIdx = template.findIndex(t => t.role === 'window');
|
|
template[windowIdx].submenu = [
|
|
{
|
|
label: 'Close',
|
|
accelerator: 'CmdOrCtrl+W',
|
|
role: 'close',
|
|
},
|
|
{
|
|
label: 'Minimize',
|
|
accelerator: 'CmdOrCtrl+M',
|
|
role: 'minimize',
|
|
},
|
|
{
|
|
label: 'Zoom',
|
|
role: 'zoom',
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
label: 'Bring All to Front',
|
|
role: 'front',
|
|
},
|
|
];
|
|
}
|
|
|
|
return Menu.buildFromTemplate(template);
|
|
}
|