"use client"; import { GitLogResponse, CommitInfo } from "@/types/git"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { ScrollArea } from "@/components/ui/scroll-area"; import { cn } from "@/lib/utils"; import { GitCommit, User, Calendar } from "lucide-react"; import { formatDistanceToNow } from "date-fns"; import { HelpTip } from "@/components/ui/help-tip"; interface GitLogPanelProps { log: GitLogResponse | undefined; isLoading: boolean; onSelectCommit?: (commit: CommitInfo) => void; selectedHash?: string; } export function GitLogPanel({ log, isLoading, onSelectCommit, selectedHash, }: GitLogPanelProps) { if (isLoading) { return ( {Array.from({ length: 6 }).map((_, i) => ( ))} ); } if (!log || log.commits.length === 0) { return ( No commits found ); } return ( Commit History {log.branch} {log.commits.map((commit, index) => ( onSelectCommit?.(commit)} variant="ghost" className={cn( "w-full h-auto justify-start text-left p-3 font-normal whitespace-normal relative", selectedHash === commit.hash ? "bg-primary/10 hover:bg-primary/10" : "", )} > {/* Timeline line */} {index < log.commits.length - 1 && ( )} {/* Commit dot */} {/* Commit info */} {commit.message} {commit.short_hash} {commit.author} {formatDistanceToNow(new Date(commit.date), { addSuffix: true, })} ))} ); }
No commits found
{commit.message}