// API tokens on the account page: the person's tokens, and making one. import { ActionForm, SubmitButton } from "@/components/forms"; import { Tag } from "@/components/status"; import { DateTime } from "@/components/time"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import type { TokenEntry, TokenList } from "@/lib/api"; import { revokeToken } from "./actions"; import { TokenForm } from "./token-form"; export function TokensCard({ data }: { data: TokenList }) { const active = data.tokens.filter((t) => t.status === "active"); const past = data.tokens.filter((t) => t.status !== "active").slice(0, 10); return ( API Tokens For your own scripts. A token can do only what you give it, and never more than you can do yourself. {active.length > 0 && ( )} {data.scopes.length > 0 ? ( ) : (

Tokens act on what you manage: your products or a catalog's team. You don't manage anything yet.

)} {past.length > 0 && (
Revoked and expired
    {past.map((t) => ( ))}
)}
); } function TokenRow({ token: t }: { token: TokenEntry }) { return (
  • {t.name} {t.status !== "active" && {t.status}} {t.status === "active" && ( Revoke )}

    {t.grants.map((g, i) => ( {i > 0 && ", "} {g.permission} on {g.scope.type === "hub" ? "everything" : g.name} ))}

    Made {" · "} {t.status === "revoked" && t.revokedAt ? ( <> revoked ) : ( <> {t.status === "expired" ? "expired" : "expires"} )} {" · "} {t.lastUsedAt ? ( <> last used ) : ( "never used" )}

  • ); }