import { memo, PropsWithChildren } from 'react'; import { createPortal } from 'react-dom'; import { Link, useLocation } from 'react-router-dom'; import { Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerHeader, DrawerOverlay, useDisclosure, } from '@chakra-ui/react'; import { useFullscreen } from '@mantine/hooks'; import { IoArrowUp } from '@react-icons/all-files/io5/IoArrowUp'; import { IoContract } from '@react-icons/all-files/io5/IoContract'; import { IoExpand } from '@react-icons/all-files/io5/IoExpand'; import { IoLockClosedOutline } from '@react-icons/all-files/io5/IoLockClosedOutline'; import { IoSwapVertical } from '@react-icons/all-files/io5/IoSwapVertical'; import { isLocalhost } from '../../../externals'; import { navigatorConstants } from '../../../viewerConfig'; import { useElectronEvent } from '../../hooks/useElectronEvent'; import useInfo from '../../hooks-query/useInfo'; import { useClientStore } from '../../stores/clientStore'; import { useViewOptionsStore } from '../../stores/viewOptions'; import { isKeyEnter } from '../../utils/keyEvent'; import { handleLinks, linkToOtherHost, openLink } from '../../utils/linkUtils'; import { cx } from '../../utils/styleUtils'; import { RenameClientModal } from '../client-modal/RenameClientModal'; import CopyTag from '../copy-tag/CopyTag'; import style from './NavigationMenu.module.scss'; interface NavigationMenuProps { isOpen: boolean; onClose: () => void; } function NavigationMenu(props: NavigationMenuProps) { const { isOpen, onClose } = props; const id = useClientStore((store) => store.id); const name = useClientStore((store) => store.name); const { isOpen: isOpenRename, onOpen: onRenameOpen, onClose: onCloseRename } = useDisclosure(); const { fullscreen, toggle } = useFullscreen(); const { mirror, toggleMirror } = useViewOptionsStore(); const location = useLocation(); return createPortal( , document.body, ); } interface OtherAddressesProps { currentLocation: string; } function OtherAddresses(props: OtherAddressesProps) { const { currentLocation } = props; const { data } = useInfo(); // there is no point showing this if we only have one interface if (data.networkInterfaces.length < 2) { return null; } return (
Accessible on external networks
{data?.networkInterfaces?.map((nif) => { if (nif.name === 'localhost') { return null; } const address = linkToOtherHost(nif.address, currentLocation); return ( openLink(address)} label='Copy IP or navigate to address' > {nif.address} ); })}
); } interface ClientLinkProps { current: boolean; to: string; } function ClientLink(props: PropsWithChildren) { const { current, to, children } = props; const { isElectron } = useElectronEvent(); const classes = cx([style.link, current && style.current]); if (isElectron) { return ( ); } return ( {children} ); } export default memo(NavigationMenu);