import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { cn } from "@/lib/utils"; import { useT, type Key } from "@/i18n"; import { useRegistryStatus } from "@/lib/registry"; import { isListed, stateTone, usePublishRealms, type PublishRealm } from "@/lib/publishRealms"; import type { RealmPublishStatus } from "@/lib/registry"; import { PublishAllDialog, PublishRealmDialog } from "@/screens/PublishDialog"; /** A small button on a realm card: the listing state of that realm; it opens the window to publish or configure it. */ export function ListingChip({ status, hasUrl, onOpen }: { status: RealmPublishStatus | undefined; hasUrl: boolean; onOpen: () => void }) { const t = useT(); const listed = isListed(status); if (!listed && !hasUrl) return null; return ( ); } /** The public listing of this server's realms: one line per realm; the form opens in a window. */ export function PublishCard({ serverId, serverName }: { serverId: string; serverName: string }) { const t = useT(); const realms = usePublishRealms(serverId, serverName); const { status } = useRegistryStatus(); const [open, setOpen] = useState(null); if (!realms) return null; const listed = (r: PublishRealm) => isListed(status?.realms.find((s) => s.local_id === r.localId)); const someUnlisted = realms.some((r) => !listed(r)); return (

{t("registry.title")}

{realms.length > 1 && someUnlisted && }

{t("registry.text")}

{!status?.url &&

{t("registry.noUrl")}

} {open === "all" && setOpen(null)} />} {open && open !== "all" && setOpen(null)} />}
); }