| 1 | "use client"; |
| 2 | |
| 3 | import { Badge } from |
| 4 | import { |
| 5 | Tooltip, |
| 6 | TooltipContent, |
| 7 | TooltipProvider, |
| 8 | TooltipTrigger, |
| 9 | } from "@/components/ui/tooltip"; |
| 10 | |
| 11 | export type CommitVerification |
| 12 | verified: boolean |
| 13 | reason: string |
| 14 | keyId: string |
| 15 | }; |
| 16 | |
| 17 | /** Signature status of one commit. Renders nothing when the commit carries no signature, which is the ordinary case and should not read as a warning. */ |
| 18 | export function CommitVerificationBadge({ |
| 19 | verification, |
| 20 | }: { |
| 21 | verification?: CommitVerification |
| 22 | }) { |
| 23 | if (!verification) |
| 24 | |
| 25 | return ( |
| 26 | <TooltipProvider> |
| 27 | <Tooltip> |
| 28 | <TooltipTrigger asChild> |
| 29 | <Badge |
| 30 | variant={verification.verified |
| 31 | className={ |
| 32 | verification.verified |
| 33 | ? "shrink-0 border-emerald-600/40 bg-emerald-600/15 text-emerald-700 dark:text-emerald-400" |
| 34 | : "shrink-0 text-muted-foreground" |
| 35 | } |
| 36 | > |
| 37 | {verification.verified ? |
| 38 | </Badge> |
| 39 | </TooltipTrigger> |
| 40 | <TooltipContent> |
| 41 | {verification.reason} |
| 42 | <span className="block font-mono text-[10px] opacity-70 |
| 43 | {verification.keyId} |
| 44 | </span> |
| 45 | </TooltipContent> |
| 46 | </Tooltip> |
| 47 | </TooltipProvider> |
| 48 | ); |
| 49 | } |