mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-21 01:57:41 +02:00
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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user