import { Form, useSubmit } 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' interface RenameProps { readonly machine: Machine readonly state: [boolean, Dispatch>] readonly magic?: string } export default function Rename({ machine, state, magic }: RenameProps) { const [name, setName] = useState(machine.givenName) const submit = useSubmit() 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.
{ submit(e.currentTarget) }} > {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
)}
) }