import { type FetcherWithComponents } from '@remix-run/react' import { type Dispatch, type SetStateAction, useState } from 'react' import Code from '~/components/Code' import Dialog from '~/components/Dialog' import TextField from '~/components/TextField' import { type Machine } from '~/types' import { cn } from '~/utils/cn' type RenameProperties = { readonly machine: Machine; readonly fetcher: FetcherWithComponents; readonly state: [boolean, Dispatch>]; readonly magic?: string; } export default function Rename({ machine, fetcher, state, magic }: RenameProperties) { const [name, setName] = useState(machine.givenName) return ( {close => ( <> Edit machine name for {machine.givenName} This name is shown in the admin panel, in Tailscale clients, and used when generating MagicDNS names. {magic ? ( name.length > 0 && name !== machine.givenName ? (

This machine will be accessible by the hostname {' '} {name.toLowerCase().replaceAll(/\s+/g, '-')} {'. '} The hostname {' '} {machine.givenName} {' '} will no longer point to this machine.

) : (

This machine is accessible by the hostname {' '} {machine.givenName} .

) ) : undefined}
Cancel Rename
)}
) }