({ workingDir, hash, selectedPath, onSelectFile })
| 82 | |
| 83 | /** Inline file list under a commit (clickable to select file for diff) */ |
| 84 | const CommitFileList: React.FC<{ |
| 85 | workingDir: string; hash: string; selectedPath: string | null; onSelectFile: (path: string) => void |
| 86 | }> = ({ workingDir, hash, selectedPath, onSelectFile }) => { |
| 87 | const { t } = useI18n() |
| 88 | const { data, isLoading } = useGitCommitFiles(workingDir, hash) |
| 89 | if (isLoading) return ( |
| 90 | <div className="pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1"> |
| 91 | <Loader2 size={12} className="animate-spin" /><span>{t('Loading...')}</span> |
| 92 | </div> |
| 93 | ) |
| 94 | const files = data?.files || [] |
| 95 | if (files.length === 0) return <div className="pl-7 py-1 text-xs text-muted-foreground/70">{t('No files changed')}</div> |
| 96 | return ( |
| 97 | <div className="pl-7 pb-1 space-y-0.5"> |
| 98 | {files.map((f: GitChangeEntry) => { |
| 99 | const colorClass = STATUS_COLOR_MAP[f.status] || STATUS_COLOR_MAP.M |
| 100 | const dir = dirname(f.path) |
| 101 | return ( |
| 102 | <button |
| 103 | key={f.path} |
| 104 | type="button" |
| 105 | onClick={(e) => { e.stopPropagation(); onSelectFile(f.path) }} |
| 106 | className={cn( |
| 107 | 'flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left', |
| 108 | selectedPath === f.path ? 'bg-muted' : 'hover:bg-muted/60' |
| 109 | )} |
| 110 | > |
| 111 | <span className={cn('w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0', colorClass)}> |
| 112 | {f.status} |
| 113 | </span> |
| 114 | <span className="text-xs text-foreground truncate">{basename(f.path)}</span> |
| 115 | {dir && <span className="text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0">{dir}</span>} |
| 116 | </button> |
| 117 | ) |
| 118 | })} |
| 119 | </div> |
| 120 | ) |
| 121 | } |
| 122 |
nothing calls this directly
no test coverage detected