refactor: improve navigation and settings locks

This commit is contained in:
Carlos Valente
2025-08-11 06:35:54 +02:00
committed by Carlos Valente
parent 836fa52757
commit efceb930e5
8 changed files with 49 additions and 37 deletions
@@ -8,14 +8,14 @@ import ViewLockedIcon from './view-locked-icon/ViewLockedIcon';
import NavigationMenu from './NavigationMenu';
interface ViewNavigationMenuProps {
/** prevent navigation and settings*/
isViewLocked?: boolean;
/** prevent navigation */
isNavigationLocked?: boolean;
/** prevent showing settings */
suppressSettings?: boolean;
}
export default memo(ViewNavigationMenu);
function ViewNavigationMenu({ isViewLocked, suppressSettings }: ViewNavigationMenuProps) {
function ViewNavigationMenu({ isNavigationLocked, suppressSettings }: ViewNavigationMenuProps) {
const [isMenuOpen, menuHandler] = useDisclosure();
const { open: showEditFormDrawer } = useViewParamsEditorStore();
@@ -23,7 +23,7 @@ function ViewNavigationMenu({ isViewLocked, suppressSettings }: ViewNavigationMe
[
'Space',
() => {
if (isViewLocked) return;
if (isNavigationLocked) return;
menuHandler.toggle();
},
{ preventDefault: true },
@@ -31,24 +31,24 @@ function ViewNavigationMenu({ isViewLocked, suppressSettings }: ViewNavigationMe
[
'mod + ,',
() => {
if (isViewLocked || suppressSettings) return;
if (suppressSettings) return;
showEditFormDrawer();
},
{ preventDefault: true },
],
]);
if (isViewLocked) {
if (isNavigationLocked && suppressSettings) {
return <ViewLockedIcon />;
}
return (
<>
<FloatingNavigation
toggleMenu={menuHandler.toggle}
toggleSettings={suppressSettings ? undefined : () => showEditFormDrawer()}
toggleMenu={isNavigationLocked ? undefined : menuHandler.toggle}
toggleSettings={suppressSettings ? undefined : showEditFormDrawer}
/>
<NavigationMenu isOpen={isMenuOpen} onClose={menuHandler.close} />
{!isNavigationLocked && <NavigationMenu isOpen={isMenuOpen} onClose={menuHandler.close} />}
</>
);
}