-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: system tray custom menu & podman update modal (#597)
* added podman modal * fixed developer menu, added mac os version check for podman 5 * fixed preferences modal width * fixed banner configs, added updateAvailable * added openPodmanModal * added window focus/creation when selecting podman status * added node package open through tray * added alert dialog * custom menu working * added theme support, and first try at ipc commands * separate out native and custom menu, add node status checking func * improved node package status for running * added svg icons * added styling for stopped nodes * stronger logic for status and icons * style changes. prepare to try react component * refined podman status * improved logic on banners * disable click prevention in case user quits modal * added additional errors for nodes * added additional positioning for other OS * fix: put tray files in assets as main loads them * replaced icons, added conditional on separator * stop all nodes and podman machine on tray quit * enabled custom tray only for mac * use modelRoutes.podman in sidebar --------- Authored-by: corn-potage
- Loading branch information
1 parent
4c1e078
commit 393704e
Showing
30 changed files
with
846 additions
and
240 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Tray Menu</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 6px; | ||
font-size: 12.5px; | ||
font-family: Arial, sans-serif; | ||
/* background: #2b2b2b; */ | ||
color: black; | ||
} | ||
|
||
body.dark { | ||
color: white; /* Color for dark theme */ | ||
} | ||
|
||
body.light { | ||
color: black; /* Color for light theme */ | ||
} | ||
|
||
.menu-item { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 4px 10px; | ||
} | ||
|
||
.light .menu-item.stopped { | ||
color: rgba(0, 0, 0, 0.25); | ||
} | ||
|
||
.dark .menu-item.stopped { | ||
color: rgba(255,255,255,0.25); | ||
} | ||
|
||
.menu-item:hover { | ||
border-radius: 4px; | ||
color: white; | ||
background: rgba(0, 122, 255, 0.8); | ||
} | ||
|
||
.menu-item.stopped:hover { | ||
background: none; | ||
} | ||
|
||
.dark .separator { | ||
border-bottom: 1px solid rgba(255, 255, 255, 0.1) | ||
} | ||
|
||
.light .separator { | ||
border-bottom: 1px solid rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.separator { | ||
margin: 3px 0; | ||
} | ||
|
||
.menu-status-container { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.light .menu-status-container { | ||
color: rgba(0, 0, 0, 0.5); | ||
} | ||
|
||
.light .menu-item.stopped .menu-status-container { | ||
color: rgba(0, 0, 0, 0.25); | ||
} | ||
|
||
.dark .menu-status-container { | ||
color: rgba(255,255,255,0.5); | ||
} | ||
|
||
.dark .menu-item.stopped .menu-status-container { | ||
color: rgba(255,255,255,0.25); | ||
} | ||
|
||
.menu-status { | ||
text-transform: capitalize; | ||
} | ||
|
||
.menu-status-icon { | ||
display: flex; | ||
align-items: center; | ||
margin-right: 5px; | ||
} | ||
|
||
.status-icon { | ||
width: 12px; /* Adjust size as needed */ | ||
height: 12px; /* Adjust size as needed */ | ||
vertical-align: middle; /* Align icon with text */ | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="menu-container"></div> | ||
<script src="trayIndex.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
const { ipcRenderer } = require('electron'); | ||
|
||
const getIconKey = (status) => { | ||
switch (status) { | ||
case 'running': | ||
case 'starting': | ||
return 'syncing'; | ||
//TODO: consider camelcased strings | ||
case 'error running': | ||
case 'error starting': | ||
case 'error stopping': | ||
case 'notInstalled': | ||
case 'notRunning': | ||
case 'isOutdated': | ||
return 'error'; | ||
default: | ||
return status; | ||
} | ||
}; | ||
|
||
const getStatusText = (status) => { | ||
switch (status) { | ||
case 'notInstalled': | ||
return 'Not Installed'; | ||
case 'notRunning': | ||
return 'Not Running'; | ||
case 'isOutdated': | ||
return 'Update Now'; | ||
default: | ||
return status; | ||
} | ||
}; | ||
|
||
ipcRenderer.on( | ||
'update-menu', | ||
(event, { nodePackageTrayMenu, podmanMenuItem, statusIcons }) => { | ||
const menuItems = [ | ||
...nodePackageTrayMenu.map((item) => ({ | ||
name: item.name, | ||
status: item.status, | ||
action: () => ipcRenderer.send('node-package-click', item.id), | ||
})), | ||
...(nodePackageTrayMenu.length >= 1 ? [{ separator: true }] : []), | ||
...(podmanMenuItem.status !== 'isRunning' | ||
? [ | ||
{ | ||
name: 'Podman', | ||
status: podmanMenuItem.status, | ||
action: () => ipcRenderer.send('podman-click'), | ||
}, | ||
{ separator: true }, | ||
] | ||
: []), | ||
{ | ||
name: 'Open NiceNode', | ||
action: () => ipcRenderer.send('show-main-window'), | ||
}, | ||
{ name: 'Quit', action: () => ipcRenderer.send('quit-app') }, | ||
]; | ||
|
||
const container = document.getElementById('menu-container'); | ||
container.innerHTML = ''; // Clear existing items | ||
|
||
menuItems.forEach((item) => { | ||
if (item.separator) { | ||
const separator = document.createElement('div'); | ||
separator.className = 'separator'; | ||
container.appendChild(separator); | ||
} else { | ||
const menuItem = document.createElement('div'); | ||
menuItem.className = 'menu-item'; | ||
|
||
if (item.status === 'stopped') { | ||
menuItem.classList.add('stopped'); | ||
} | ||
|
||
const nameSpan = document.createElement('span'); | ||
nameSpan.textContent = item.name; | ||
menuItem.appendChild(nameSpan); | ||
|
||
if (item.status) { | ||
const statusContainer = document.createElement('div'); | ||
statusContainer.className = 'menu-status-container'; | ||
|
||
const statusIconContainer = document.createElement('div'); | ||
statusIconContainer.className = 'menu-status-icon'; | ||
|
||
const statusIcon = document.createElement('div'); | ||
statusIcon.innerHTML = | ||
statusIcons[getIconKey(item.status)] || statusIcons.default; | ||
statusIcon.className = 'status-icon'; | ||
|
||
const statusText = document.createElement('div'); | ||
statusText.className = 'menu-status'; | ||
statusText.textContent = getStatusText(item.status); | ||
|
||
statusIconContainer.appendChild(statusIcon); | ||
statusContainer.appendChild(statusIconContainer); | ||
statusContainer.appendChild(statusText); | ||
menuItem.appendChild(statusContainer); | ||
} | ||
|
||
menuItem.addEventListener('click', item.action); | ||
|
||
container.appendChild(menuItem); | ||
} | ||
}); | ||
ipcRenderer.send('adjust-height', document.body.scrollHeight); | ||
}, | ||
); | ||
|
||
ipcRenderer.on('set-theme', (event, theme) => { | ||
applyTheme(theme); | ||
}); | ||
|
||
// Apply theme-based styles | ||
const applyTheme = (theme) => { | ||
const body = document.body; | ||
const menuItems = document.querySelectorAll('.menu-item'); | ||
if (theme === 'dark') { | ||
body.classList.add('dark'); | ||
body.classList.remove('light'); | ||
} else { | ||
body.classList.add('light'); | ||
body.classList.remove('dark'); | ||
} | ||
}; | ||
|
||
ipcRenderer.on('update-menu', (event, updatedItems) => { | ||
// Update menu items if necessary | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.