From d950b4802359afa7753422743c473fe9ad336587 Mon Sep 17 00:00:00 2001 From: maziggy Date: Thu, 5 Feb 2026 08:21:55 +0100 Subject: [PATCH] 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 --- frontend/src/components/Layout.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Layout.tsx b/frontend/src/components/Layout.tsx index 355943de1..9f14cc0d9 100644 --- a/frontend/src/components/Layout.tsx +++ b/frontend/src/components/Layout.tsx @@ -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) => {