Add application menu structure for macOS and Windows

- Implemented functions to build application menus for macOS, including 'About', 'Edit', 'File', and 'Window' menus.
- Enhanced the application menu template to include these new menu structures, improving user navigation and functionality.
- Ensured compatibility with macOS by conditionally adding the app menu based on the platform.
This commit is contained in:
Tom Butcher 2026-08-02 19:04:14 +01:00
parent 40ccacc9a8
commit 3b28aa4308

View File

@ -5,6 +5,63 @@ const SIDEBAR_MENU_ACTION_PREFIX = "sidebar-nav:";
let sidebarViewMenuSections = [];
let navigateHandler = null;
function buildMacAppMenu() {
return {
submenu: [
{
label: "About Farm Control",
action: `${SIDEBAR_MENU_ACTION_PREFIX}/dashboard/management/about`,
},
{ type: "separator" },
{ role: "hide" },
{ role: "hideOthers" },
{ role: "showAll" },
{ type: "separator" },
{ role: "quit" },
],
};
}
function buildEditMenu() {
return {
label: "Edit",
submenu: [
{ role: "undo" },
{ role: "redo" },
{ type: "separator" },
{ role: "cut" },
{ role: "copy" },
{ role: "paste" },
{ role: "pasteAndMatchStyle" },
{ role: "delete" },
{ type: "separator" },
{ role: "selectAll" },
{ type: "separator" },
{ role: "startSpeaking" },
{ role: "stopSpeaking" },
],
};
}
function buildFileMenu() {
return {
label: "File",
submenu: [{ role: "close" }],
};
}
function buildWindowMenu() {
return {
label: "Window",
submenu: [
{ role: "minimize" },
{ role: "zoom" },
{ type: "separator" },
{ role: "bringAllToFront" },
],
};
}
function toMenuItems(items = []) {
return items
.map((item) => {
@ -56,14 +113,14 @@ function buildApplicationMenuTemplate() {
}
const template = [
{ role: "fileMenu" },
{ role: "editMenu" },
buildFileMenu(),
buildEditMenu(),
{ label: "View", submenu: viewSubmenu },
{ role: "windowMenu" },
buildWindowMenu(),
];
if (process.platform === "darwin") {
template.unshift({ role: "appMenu" });
template.unshift(buildMacAppMenu());
}
return template;