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:
@@ -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' },
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user