feat(desktop): add macOS app menu template builder

Adds buildAppMenuTemplate pure function to recovery.ts that produces the
three-submenu macOS app menu (App/Edit/Window), reusing MenuActions and
checkForUpdatesItem from T4. Includes Restart to Install Update item
conditionally on updateState=downloaded. Tests use destructuring to satisfy
noUncheckedIndexedAccess. 26 tests pass, tsc clean.
This commit is contained in:
Jannis Braun
2026-05-03 04:13:19 +02:00
parent 172f53e3a5
commit a9122d1fdf
2 changed files with 100 additions and 0 deletions
+57
View File
@@ -136,3 +136,60 @@ export function buildTrayMenuTemplate(
return items;
}
export function buildAppMenuTemplate(
appName: string,
state: RecoveryState,
actions?: Partial<MenuActions>,
): MenuItemConstructorOptions[] {
const appSubmenu: MenuItemConstructorOptions[] = [
{ role: 'about' },
{ type: 'separator' },
checkForUpdatesItem(state, () => actions?.onCheckForUpdates?.()),
];
if (state.updateState === 'downloaded') {
appSubmenu.push({
id: 'restart-to-install',
label: 'Restart to Install Update',
enabled: true,
click: actions?.onRestartToInstall,
});
}
appSubmenu.push(
{ type: 'separator' },
{ label: 'Change Instance', click: actions?.onChangeInstance },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideOthers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' },
);
return [
{ label: appName, submenu: appSubmenu },
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'selectAll' },
],
},
{
label: 'Window',
submenu: [
{ role: 'minimize' },
{ role: 'zoom' },
{ type: 'separator' },
{ role: 'front' },
],
},
];
}