headplane/app/routes/machines/dialogs/expire.tsx

58 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-12-31 10:30:14 +05:30
import { Form, useSubmit } from 'react-router';
2024-12-31 10:31:50 +05:30
import type { Dispatch, SetStateAction } from 'react';
2024-05-01 02:47:45 -04:00
2024-12-31 10:30:14 +05:30
import Dialog from '~/components/Dialog';
2024-12-31 10:31:50 +05:30
import type { Machine } from '~/types';
2024-12-31 10:30:14 +05:30
import { cn } from '~/utils/cn';
2024-05-01 02:47:45 -04:00
interface ExpireProps {
2024-12-31 10:30:14 +05:30
readonly machine: Machine;
readonly state: [boolean, Dispatch<SetStateAction<boolean>>];
2024-05-01 02:47:45 -04:00
}
export default function Expire({ machine, state }: ExpireProps) {
2024-12-31 10:30:14 +05:30
const submit = useSubmit();
2024-05-01 02:47:45 -04:00
return (
<Dialog>
<Dialog.Panel control={state}>
2024-12-31 10:30:14 +05:30
{(close) => (
2024-05-01 02:47:45 -04:00
<>
2024-12-31 10:30:14 +05:30
<Dialog.Title>Expire {machine.givenName}</Dialog.Title>
2024-05-01 02:47:45 -04:00
<Dialog.Text>
2024-12-31 10:30:14 +05:30
This will disconnect the machine from your Tailnet. In order to
reconnect, you will need to re-authenticate from the device.
2024-05-01 02:47:45 -04:00
</Dialog.Text>
<Form
method="POST"
onSubmit={(e) => {
2024-12-31 10:30:14 +05:30
submit(e.currentTarget);
}}
>
<input type="hidden" name="_method" value="expire" />
<input type="hidden" name="id" value={machine.id} />
<div className="mt-6 flex justify-end gap-2 mt-6">
2024-12-31 10:30:14 +05:30
<Dialog.Action variant="cancel" onPress={close}>
2024-05-01 02:47:45 -04:00
Cancel
</Dialog.Action>
<Dialog.Action
variant="confirm"
2024-05-01 02:47:45 -04:00
className={cn(
'bg-red-500 hover:border-red-700',
'dark:bg-red-600 dark:hover:border-red-700',
'pressed:bg-red-600 hover:bg-red-600',
'text-white dark:text-white',
2024-05-01 02:47:45 -04:00
)}
onPress={close}
>
Expire
</Dialog.Action>
</div>
</Form>
2024-05-01 02:47:45 -04:00
</>
)}
</Dialog.Panel>
</Dialog>
2024-12-31 10:30:14 +05:30
);
2024-05-01 02:47:45 -04:00
}