Only show plate detection popup to users with control permission

The plate detection alert popup (shown when objects are detected on
build plate and print is paused) was visible to all users. Now it
only shows to users who have the printers:control permission.

- Added hasPermission('printers:control') check before showing alert
- When auth disabled: all users see it (backward compatible)
- When auth enabled: only users with printers:control permission see it

Addresses #244
This commit is contained in:
maziggy
2026-02-05 08:21:55 +01:00
parent 379ba726e1
commit d950b48023
+6 -1
View File
@@ -313,8 +313,13 @@ export function Layout() {
}, [location.pathname, isMobile]);
// Listen for plate detection warnings (objects on plate, print paused)
// Only show to users with printers:control permission
useEffect(() => {
const handlePlateNotEmpty = (event: Event) => {
// Only show alert to users who can control printers
if (!hasPermission('printers:control')) {
return;
}
const detail = (event as CustomEvent).detail;
setPlateDetectionAlert({
printer_id: detail.printer_id,
@@ -324,7 +329,7 @@ export function Layout() {
};
window.addEventListener('plate-not-empty', handlePlateNotEmpty);
return () => window.removeEventListener('plate-not-empty', handlePlateNotEmpty);
}, []);
}, [hasPermission]);
// Global keyboard shortcuts for navigation
const handleKeyDown = useCallback((e: KeyboardEvent) => {