| 1 | import type { ScopedThreadRef } from "@t3tools/contracts"; |
| 2 | import { DiscoveryListRow } from "../ui/discovery-list"; |
| 3 | |
| 4 | import { PreviewFaviconIcon } from "./PreviewFaviconIcon"; |
| 5 | import type { PreviewableServer } from "./useDiscoveredLocalServers"; |
| 6 | |
| 7 | interface Props { |
| 8 | threadRef: ScopedThreadRef; |
| 9 | server: PreviewableServer; |
| 10 | onOpen: () => void; |
| 11 | } |
| 12 | |
| 13 | export function PreviewLocalServerCard({ threadRef, server, onOpen }: Props) { |
| 14 | const subtitle = describeServer(server); |
| 15 | return ( |
| 16 | <DiscoveryListRow |
| 17 | onClick={onOpen} |
| 18 | icon={<PreviewFaviconIcon threadRef={threadRef} url={server.requestedUrl} />} |
| 19 | title={subtitle} |
| 20 | description={`${server.host}:${server.port}`} |
| 21 | /> |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | function describeServer(server: PreviewableServer): string { |
| 26 | if (server.processName) return server.processName; |
| 27 | return "Listening"; |
| 28 | } |