import type { ColumnDef } from "@tanstack/react-table"; import { Eye, Trash2, Layers } from "lucide-react"; import { Checkbox } from "@/components/ui/checkbox"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; import { RelativeTime } from "@/components/shared/relative-time"; import { DocStatusBadge } from "./doc-status-badge"; import { extractFileName } from "@/lib/utils"; import type { TranslateFn } from "@/i18n/i18n-context"; import type { Document } from "@/types/knowledge-base"; interface DocColumnsOptions { t: TranslateFn; onView?: (document: Document) => void; onDelete?: (document: Document) => void; onViewChunks?: (document: Document) => void; } export function createDocColumns({ t, onView, onDelete, onViewChunks, }: DocColumnsOptions): ColumnDef[] { const columns: ColumnDef[] = [ { id: "select", header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label={t("documents.table.selectAll")} /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label={t("documents.table.selectRow")} /> ), enableSorting: false, enableHiding: false, }, { accessorKey: "ossKey", header: t("documents.table.docName"), cell: ({ row }) => ( {extractFileName(row.original.ossKey)} ), }, { accessorKey: "status", header: t("documents.table.status"), cell: ({ row }) => , }, { accessorKey: "chunkNum", header: t("documents.table.chunkCount"), cell: ({ row }) => ( {row.original.chunkNum ?? "—"} ), }, { accessorKey: "updatedAt", header: t("documents.table.updatedAt"), cell: ({ row }) => , }, { id: "actions", header: () => ( {t("documents.table.actions")} ), cell: ({ row }) => (
{t("documents.table.viewDetail")} {t("documents.table.viewChunks")} {t("common.delete")}
), }, ]; // The subspace column is intentionally absent: when subspace is disabled // it is always "_default" (no signal), and when subspace is enabled the // user has already chosen one at the SubspaceGate so it is shown in the // detail sidebar. Surfacing it again per-row is redundant noise. return columns; }