The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { Discovery } from "@t3tools/client-runtime/relay"; |
| 2 | import type { EnvironmentId } from "@t3tools/contracts"; |
| 3 | import { T, useGT, Var } from "gt-react"; |
| 4 | import { useState } from "react"; |
| 5 | |
| 6 | import { useRelayEnvironmentDiscovery } from "../../state/environments"; |
| 7 | import { |
| 8 | AlertDialog, |
| 9 | AlertDialogClose, |
| 10 | AlertDialogDescription, |
| 11 | AlertDialogFooter, |
| 12 | AlertDialogHeader, |
| 13 | AlertDialogPopup, |
| 14 | AlertDialogTitle, |
| 15 | } from "../ui/alert-dialog"; |
| 16 | import { Button, InlineButton } from "../ui/button"; |
| 17 | import { useT3ConnectAccountPage } from "./T3ConnectAccountPages"; |
| 18 | |
| 19 | export function RemoveT3ConnectEnvironmentDialog({ |
| 20 | environmentLabel, |
| 21 | environmentId, |
| 22 | onCancel, |
| 23 | onConfirm, |
| 24 | }: { |
| 25 | readonly environmentLabel: string | null; |
| 26 | readonly environmentId: EnvironmentId | null; |
| 27 | readonly onCancel: () => void; |
| 28 | readonly onConfirm: () => void; |
| 29 | }) { |
| 30 | const accountPage = useT3ConnectAccountPage(); |
| 31 | const gt = useGT(); |
| 32 | const discovery = useRelayEnvironmentDiscovery(); |
| 33 | const registration = environmentId |
| 34 | ? Discovery.relayEnvironmentRegistration(discovery, environmentId) |
| 35 | : "unknown"; |
| 36 | const [shown, setShown] = useState({ label: environmentLabel, registration }); |
| 37 | if ( |
| 38 | environmentLabel !== null && |
| 39 | (environmentLabel !== shown.label || registration !== shown.registration) |
| 40 | ) { |
| 41 | setShown({ label: environmentLabel, registration }); |
| 42 | } |
| 43 | const openAccountPage = accountPage.open; |
| 44 | const accountPageLink = openAccountPage ? ( |
| 45 | <InlineButton |
| 46 | onClick={() => { |
| 47 | onCancel(); |
| 48 | openAccountPage(); |
| 49 | }} |
| 50 | > |
| 51 | <T>T3 Connect settings</T> |
| 52 | </InlineButton> |
| 53 | ) : ( |
| 54 | gt("T3 Connect settings") |
| 55 | ); |
| 56 | |
| 57 | return ( |
| 58 | <> |
| 59 | <AlertDialog |
| 60 | open={environmentLabel !== null} |
| 61 | onOpenChange={(open) => { |
| 62 | if (!open) onCancel(); |
| 63 | }} |
| 64 | > |
| 65 | <AlertDialogPopup> |
| 66 | <AlertDialogHeader> |
| 67 | <AlertDialogTitle> |
| 68 | <T> |
| 69 | Remove <Var>{shown.label}</Var> from this device? |
| 70 | </T> |
| 71 | </AlertDialogTitle> |
| 72 | <AlertDialogDescription> |
| 73 | <T>This forgets its pairing, credentials, and cached threads here.</T> |
| 74 | </AlertDialogDescription> |
| 75 | <AlertDialogDescription> |
| 76 | {shown.registration === "registered" ? ( |
| 77 | <T> |
| 78 | It stays on your T3 Connect account and keeps its host space. Deregister it in{" "} |
| 79 | <Var>{accountPageLink}</Var> to free it. |
| 80 | </T> |
| 81 | ) : shown.registration === "unregistered" ? ( |
| 82 | gt("It's no longer on your T3 Connect account.") |
| 83 | ) : ( |
| 84 | <T> |
| 85 | This doesn't change your T3 Connect account. To deregister it there, use{" "} |
| 86 | <Var>{accountPageLink}</Var>. |
| 87 | </T> |
| 88 | )} |
| 89 | </AlertDialogDescription> |
| 90 | </AlertDialogHeader> |
| 91 | <AlertDialogFooter> |
| 92 | <AlertDialogClose render={<Button variant="outline" />}> |
| 93 | <T>Cancel</T> |
| 94 | </AlertDialogClose> |
| 95 | <Button variant="destructive" onClick={onConfirm}> |
| 96 | <T>Remove from this device</T> |
| 97 | </Button> |
| 98 | </AlertDialogFooter> |
| 99 | </AlertDialogPopup> |
| 100 | </AlertDialog> |
| 101 | {accountPage.portals} |
| 102 | </> |
| 103 | ); |
| 104 | } |