"use client"; import { IconArrowBackUp, IconPlus, IconMinus, IconCheck, IconLoader2, IconPencil, } from "@tabler/icons-react"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import { LineStat } from "@/components/diff-stat"; import type { FileInfo } from "@/lib/state/store"; import { FileStatusIcon } from "./file-status-icon"; const splitPath = (path: string) => { const lastSlash = path.lastIndexOf("/"); if (lastSlash === -1) return { folder: "", file: path }; return { folder: path.slice(0, lastSlash), file: path.slice(lastSlash + 1), }; }; type ChangedFile = { path: string; status: FileInfo["status"]; staged: boolean; plus: number | undefined; minus: number | undefined; oldPath: string | undefined; }; type FileRowProps = { file: ChangedFile; isPending: boolean; onOpenDiff: (path: string) => void; onStage: (path: string) => void; onUnstage: (path: string) => void; onDiscard: (path: string) => void; onEditFile: (path: string) => void; }; export function FileRow({ file, isPending, onOpenDiff, onStage, onUnstage, onDiscard, onEditFile, }: FileRowProps) { const { folder, file: name } = splitPath(file.path); return (
  • onOpenDiff(file.path)} >
  • ); } function StageButton({ isPending, staged, path, onStage, onUnstage, }: { isPending: boolean; staged: boolean; path: string; onStage: (path: string) => void; onUnstage: (path: string) => void; }) { if (isPending) { return (
    ); } if (staged) { return ( ); } return ( ); } function FileRowActions({ path, onDiscard, onEditFile, }: { path: string; onDiscard: (path: string) => void; onEditFile: (path: string) => void; }) { return (
    Discard changes Edit
    ); }