import { ChevronDownIcon, CopyIcon } from '@primer/octicons-react' import { Link } from '@remix-run/react' import Menu from '~/components/Menu' import StatusCircle from '~/components/StatusCircle' import { toast } from '~/components/Toaster' import { type Machine, type Route, User } from '~/types' import { cn } from '~/utils/cn' import MenuOptions from './menu' interface Props { readonly machine: Machine readonly routes: Route[] readonly users: User[] readonly magic?: string } export default function MachineRow({ machine, routes, magic, users }: Props) { const expired = machine.expiry === '0001-01-01 00:00:00' || machine.expiry === '0001-01-01T00:00:00Z' ? false : new Date(machine.expiry).getTime() < Date.now() const tags = [ ...machine.forcedTags, ...machine.validTags, ] if (expired) { tags.unshift('Expired') } return (

{machine.givenName}

{machine.name}

{tags.map(tag => ( {tag} ))}
{machine.ipAddresses[0]} {machine.ipAddresses.map(ip => ( { await navigator.clipboard.writeText(ip) toast('Copied IP address to clipboard') }} > {ip} ))} {magic ? ( { const ip = `${machine.givenName}.${machine.user.name}.${magic}` await navigator.clipboard.writeText(ip) toast('Copied hostname to clipboard') }} > {machine.givenName} . {machine.user.name} . {magic} ) : undefined}

{machine.online && !expired ? 'Connected' : new Date( machine.lastSeen, ).toLocaleString()}

) }