Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

refactor(web): Migrate exports settings table to design system (#17864)

Ben Bachemb9c8f6cabece
diff --git a/web/src/components/design-system/Tooltip/Tooltip.tsx b/web/src/components/design-system/Tooltip/Tooltip.tsx
index 5ddeeab1bb..ecf82a476d 100644
--- a/web/src/components/design-system/Tooltip/Tooltip.tsx
+++ b/web/src/components/design-system/Tooltip/Tooltip.tsx
@@ -12,7 +12,12 @@ type TooltipProps = Omit<
};
function Tooltip({ label, ...props }: TooltipProps) {
- return <CustomTooltip content={<span>{label}</span>} {...props} />;
+ return (
+ <CustomTooltip
+ content={<span className="whitespace-pre-line">{label}</span>}
+ {...props}
+ />
+ );
}
export { Tooltip };
diff --git a/web/src/components/design-system/table/columns/createDateTableColumn.tsx b/web/src/components/design-system/table/columns/createDateTableColumn.tsx
index e87bf24281..45858aadfb 100644
--- a/web/src/components/design-system/table/columns/createDateTableColumn.tsx
+++ b/web/src/components/design-system/table/columns/createDateTableColumn.tsx
@@ -12,6 +12,7 @@ import {
export function createDateTableColumn<TData extends RowData>({
getValue,
mode = "absolute",
+ emptyValue,
...options
}: TableColumnOptions<TData, Date> & {
getValue?: (
@@ -19,6 +20,7 @@ export function createDateTableColumn<TData extends RowData>({
context: CellContext<TData, Date | null | undefined>,
) => Date | { type: "loading" } | undefined;
mode?: "absolute" | "relative";
+ emptyValue?: string;
}) {
return createTableColumn<TData, Date>({
...options,
@@ -26,7 +28,11 @@ export function createDateTableColumn<TData extends RowData>({
renderCell: (value, context) => {
const resolvedValue = getValue ? getValue(value, context) : value;
- if (resolvedValue === null || resolvedValue === undefined) return null;
+ if (resolvedValue === null || resolvedValue === undefined) {
+ return emptyValue ? (
+ <span className="text-muted-foreground">{emptyValue}</span>
+ ) : null;
+ }
if (!(resolvedValue instanceof Date)) {
return <Skeleton className="h-4 w-1/2" />;
diff --git a/web/src/components/design-system/table/columns/createTextTableColumn.stories.tsx b/web/src/components/design-system/table/columns/createTextTableColumn.stories.tsx
index 91075fb82a..d1db35eb3c 100644
--- a/web/src/components/design-system/table/columns/createTextTableColumn.stories.tsx
+++ b/web/src/components/design-system/table/columns/createTextTableColumn.stories.tsx
@@ -22,6 +22,15 @@ const columns = [
header: "Copyable text",
trailingAction: { type: "copy-to-clipboard" },
}),
+ createTextTableColumn<Row>({
+ id: "name-with-tooltip",
+ accessorFn: (row) => row.name,
+ header: "Text with tooltip",
+ tooltip: ({ row }) =>
+ row.original.name
+ ? `Created: today\nCount: ${row.original.count ?? "—"}`
+ : undefined,
+ }),
createTextTableColumn<Row, number>({
accessorKey: "count",
header: "Mapped text with action",
diff --git a/web/src/components/design-system/table/columns/createTextTableColumn.tsx b/web/src/components/design-system/table/columns/createTextTableColumn.tsx
index c8d2b95a94..7e0b858633 100644
--- a/web/src/components/design-system/table/columns/createTextTableColumn.tsx
+++ b/web/src/components/design-system/table/columns/createTextTableColumn.tsx
@@ -1,9 +1,10 @@
/* eslint-disable boundaries/dependencies */
import { type CellContext, type RowData } from "@tanstack/react-table";
-import { Check, Copy, type LucideIcon } from "lucide-react";
+import { Check, Copy, InfoIcon, type LucideIcon } from "lucide-react";
import { type ReactNode } from "react";
import { IconButton } from "@/src/components/design-system/IconButton/IconButton";
+import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";
import { Skeleton } from "@/src/components/ui/skeleton";
import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";
import {
@@ -39,11 +40,22 @@ export function createTextTableColumn<TData extends RowData, TValue = string>({
mapValue,
nullValue,
trailingAction,
+ tooltip,
...options
}: TextTableColumnOptions<TData, TValue> & {
nullValue?: string;
- trailingAction?: TextTableColumnTrailingAction<TData, TValue>;
-}) {
+} & (
+ | {
+ trailingAction?: TextTableColumnTrailingAction<TData, TValue>;
+ tooltip?: never;
+ }
+ | {
+ tooltip: (
+ context: CellContext<TData, TValue | null | undefined>,
+ ) => string | undefined;
+ trailingAction?: never;
+ }
+ )) {
const loadingCell = <Skeleton className="h-4 w-1/2" />;
return createTableColumn<TData, TValue>({
@@ -69,6 +81,31 @@ export function createTextTableColumn<TData extends RowData, TValue = string>({
}
if (typeof text !== "string") return loadingCell;
+ if (tooltip) {
+ const content = tooltip(context);
+ if (content) {
+ return (
+ <TextWithAction
+ value={text}
+ action={
+ <Tooltip label={content}>
+ {({ getTriggerProps }) => (
+ <button
+ type="button"
+ {...getTriggerProps()}
+ aria-label="More information"
+ className="flex items-center"
+ >
+ <InfoIcon className="text-muted-foreground size-3" />
+ </button>
+ )}
+ </Tooltip>
+ }
+ />
+ );
+ }
+ }
+
if (trailingAction?.type === "copy-to-clipboard") {
return <CopyableText value={text} />;
}
diff --git a/web/src/components/ui/alert-dialog.tsx b/web/src/components/ui/alert-dialog.tsx
index e2362a6604..8aab0eec2a 100644
--- a/web/src/components/ui/alert-dialog.tsx
+++ b/web/src/components/ui/alert-dialog.tsx
@@ -11,8 +11,6 @@ import motionStyles from "./dialog-motion.module.css";
const AlertDialog = AlertDialogPrimitive.Root;
-const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
-
// Route the portal into the `modal` overlay layer (null until mounted →
// falls back to <body>, SSR-parity). Layer order, not z-index, stacks it.
const AlertDialogPortal = ({
@@ -141,7 +139,6 @@ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
export {
AlertDialog,
- AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
diff --git a/web/src/features/batch-exports/components/BatchExportsSettingsPage.tsx b/web/src/features/batch-exports/components/BatchExportsSettingsPage.tsx
index c1c448bc3e..da2b1c35d4 100644
--- a/web/src/features/batch-exports/components/BatchExportsSettingsPage.tsx
+++ b/web/src/features/batch-exports/components/BatchExportsSettingsPage.tsx
@@ -1,8 +1,7 @@
import Header from "@/src/components/layouts/header";
import { Alert } from "@/src/components/design-system/Alert/Alert";
-import { BatchExportsTable } from "@/src/features/batch-exports/components/BatchExportsTable";
+import { ConnectedBatchExportsTable } from "@/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable";
import { useHasProjectAccess } from "@/src/features/rbac";
-import { SettingsTableCard } from "@/src/components/layouts/settings-table-card";
export function BatchExportsSettingsPage(props: { projectId: string }) {
const hasAccess = useHasProjectAccess({
@@ -20,9 +19,7 @@ export function BatchExportsSettingsPage(props: { projectId: string }) {
will receive an email notification once your export is ready.
</p>
{hasAccess ? (
- <SettingsTableCard>
- <BatchExportsTable projectId={props.projectId} />
- </SettingsTableCard>
+ <ConnectedBatchExportsTable projectId={props.projectId} />
) : (
<Alert>
<Alert.Title>Access Denied</Alert.Title>
diff --git a/web/src/features/batch-exports/components/BatchExportsTable.tsx b/web/src/features/batch-exports/components/BatchExportsTable.tsx
deleted file mode 100644
index b89b144727..0000000000
--- a/web/src/features/batch-exports/components/BatchExportsTable.tsx
+++ /dev/null
@@ -1,285 +0,0 @@
-/* eslint-disable no-nested-ternary */
-import { DataTable } from "@/src/components/table/data-table";
-import { type LangfuseColumnDef } from "@/src/components/table/types";
-import { api, type RouterOutputs } from "@/src/utils/api";
-import { safeExtract } from "@/src/utils/map-utils";
-import { formatDistanceToNow } from "date-fns";
-import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";
-import { NumberParam, useQueryParams, withDefault } from "use-query-params";
-import { ActionButton } from "@/src/components/ActionButton";
-import { DownloadIcon, InfoIcon } from "lucide-react";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/src/components/ui/tooltip";
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
- AlertDialogTrigger,
-} from "@/src/components/ui/alert-dialog";
-import { useState } from "react";
-import { useHasProjectAccess } from "@/src/features/rbac";
-import { createUserTableColumn } from "@/src/components/design-system/table/columns/createUserTableColumn";
-
-type BatchExportRow = RouterOutputs["batchExport"]["all"]["exports"][number];
-
-export function BatchExportsTable(props: { projectId: string }) {
- const [paginationState, setPaginationState] = useQueryParams({
- pageIndex: withDefault(NumberParam, 0),
- pageSize: withDefault(NumberParam, 10),
- });
- const [cancelDialogOpen, setCancelDialogOpen] = useState(false);
- const [selectedExportId, setSelectedExportId] = useState<string | null>(null);
- // Per-row pending downloads: a shared mutation with a single scalar id
- // would cross-wire spinners when two rows are clicked in quick succession.
- const [downloadingIds, setDownloadingIds] = useState<Set<string>>(new Set());
-
- const batchExports = api.batchExport.all.useQuery({
- projectId: props.projectId,
- limit: paginationState.pageSize,
- page: paginationState.pageIndex,
- });
-
- const cancelBatchExport = api.batchExport.cancel.useMutation({
- onSuccess: () => {
- batchExports.refetch();
- setCancelDialogOpen(false);
- setSelectedExportId(null);
- },
- });
-
- const downloadBatchExport = api.batchExport.downloadUrl.useMutation();
-
- const hasAccess = useHasProjectAccess({
- projectId: props.projectId,
- scope: "batchExports:create",
- });
-
- const columns = [
- {
- accessorKey: "name",
- id: "name",
- header: "Name",
- size: 200,
- cell: ({ row }) => {
- const name = row.getValue("name") as string;
- const { createdAt, finishedAt, expiresAt } = row.original;
- return (
- <div className="flex items-center gap-2">
- <span className="whitespace-break-spaces">{name}</span>
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger>
- <InfoIcon className="text-muted-foreground size-3" />
- </TooltipTrigger>
- <TooltipContent>
- <div className="space-y-1">
- <div>Created: {new Date(createdAt).toLocaleString()}</div>
- <div>
- Finished:{" "}
- {finishedAt ? new Date(finishedAt).toLocaleString() : "-"}
- </div>
- <div>
- Download expires:{" "}
- {expiresAt ? new Date(expiresAt).toLocaleString() : "-"}
- </div>
- </div>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- );
- },
- },
- {
- accessorKey: "status",
- id: "status",
- header: "Status",
- size: 90,
- cell: ({ row }) => {
- const { status, log } = row.original;
- const badge = <StatusBadge type={status.toLowerCase()} />;
- // The log only exists on failed exports (worker-written, user-facing
- // error message); surface it on the badge instead of a dedicated
- // column that is empty for every successful row.
- if (!log) {
- return badge;
- }
- return (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger>{badge}</TooltipTrigger>
- <TooltipContent className="max-w-md whitespace-pre-wrap">
- {log}
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- );
- },
- },
- {
- accessorKey: "isDownloadable",
- id: "action",
- header: "Action",
- size: 130,
- // One state-dependent action per row: Cancel while queued/processing,
- // Download (or Expired) once completed — the states never coexist.
- cell: ({ row }) => {
- const { id, status, isExpired, isDownloadable } = row.original;
- if (isDownloadable) {
- return (
- <ActionButton
- icon={<DownloadIcon size={16} />}
- size="sm"
- loading={downloadingIds.has(id)}
- onClick={() => {
- setDownloadingIds((prev) => new Set(prev).add(id));
- downloadBatchExport.mutate(
- { projectId: props.projectId, batchExportId: id },
- {
- // Content-Disposition is `attachment`, so assigning the
- // fresh URL triggers a download without leaving the page.
- onSuccess: (data) => {
- window.location.href = data.url;
- },
- onSettled: () =>
- setDownloadingIds((prev) => {
- const next = new Set(prev);
- next.delete(id);
- return next;
- }),
- },
- );
- }}
- >
- Download
- </ActionButton>
- );
- }
- if (status === "COMPLETED" && isExpired) {
- return <span className="text-muted-foreground">Expired</span>;
- }
- if (status === "QUEUED" || status === "PROCESSING") {
- return (
- <AlertDialog
- open={cancelDialogOpen && selectedExportId === id}
- onOpenChange={(open) => {
- if (!open) {
- setCancelDialogOpen(false);
- setSelectedExportId(null);
- }
- }}
- >
- <AlertDialogTrigger asChild>
- <ActionButton
- hasAccess={hasAccess}
- size="sm"
- onClick={() => {
- setSelectedExportId(id);
- setCancelDialogOpen(true);
- }}
- >
- Cancel
- </ActionButton>
- </AlertDialogTrigger>
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>Cancel batch export?</AlertDialogTitle>
- <AlertDialogDescription>
- Are you sure you want to cancel this batch export? This
- action cannot be undone.
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancel>No, keep it</AlertDialogCancel>
- <AlertDialogAction
- onClick={() => {
- cancelBatchExport.mutate({
- projectId: props.projectId,
- batchExportId: id,
- });
- }}
- >
- Yes, cancel export
- </AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- );
- }
- return null;
- },
- },
- {
- accessorKey: "expiresAt",
- id: "expiresAt",
- header: "Expires",
- size: 130,
- cell: ({ row }) => {
- const { status, expiresAt, isExpired } = row.original;
- // The Action column already reads "Expired" for lapsed exports; a
- // "how long ago" timestamp adds nothing, so show the countdown only
- // while the download is still available.
- if (status !== "COMPLETED" || !expiresAt || isExpired) {
- return null;
- }
- return (
- <span title={new Date(expiresAt).toLocaleString()}>
- {formatDistanceToNow(new Date(expiresAt), { addSuffix: true })}
- </span>
- );
- },
- },
- {
- accessorKey: "format",
- id: "format",
- header: "Format",
- size: 70,
- },
- createUserTableColumn<BatchExportRow>({
- accessorKey: "user",
- header: "Created By",
- size: 150,
- variant: "avatar",
- emptyValue: "Unknown",
- }),
- ] as LangfuseColumnDef<BatchExportRow>[];
-
- return (
- <>
- <DataTable
- tableName="batchExports"
- columns={columns}
- data={
- batchExports.isPending
- ? { isLoading: true, isError: false }
- : batchExports.isError
- ? {
- isLoading: false,
- isError: true,
- error: batchExports.error.message,
- }
- : {
- isLoading: false,
- isError: false,
- data: safeExtract(batchExports.data, "exports", []),
- }
- }
- pagination={{
- totalCount: batchExports.data?.totalCount ?? null,
- onChange: setPaginationState,
- state: paginationState,
- }}
- cellPadding="comfortable"
- />
- </>
- );
-}
diff --git a/web/src/features/batch-exports/components/BatchExportsTable/BatchExportsTable.stories.tsx b/web/src/features/batch-exports/components/BatchExportsTable/BatchExportsTable.stories.tsx
new file mode 100644
index 0000000000..8997301601
--- /dev/null
+++ b/web/src/features/batch-exports/components/BatchExportsTable/BatchExportsTable.stories.tsx
@@ -0,0 +1,83 @@
+import { fn } from "storybook/test";
+
+import preview from "../../../../../.storybook/preview";
+import { BatchExportsTable, type BatchExportRow } from "./BatchExportsTable";
+
+const meta = preview.meta({ component: BatchExportsTable });
+
+const completedExport: BatchExportRow = {
+ id: "export-1",
+ projectId: "project-1",
+ userId: "user-1",
+ name: "Traces export",
+ status: "COMPLETED",
+ format: "CSV",
+ query: {},
+ createdAt: new Date("2026-09-01"),
+ updatedAt: new Date("2026-09-02"),
+ finishedAt: new Date("2026-09-02"),
+ expiresAt: new Date("2027-09-02"),
+ log: null,
+ isExpired: false,
+ isDownloadable: true,
+ user: { id: "user-1", name: "Ada Lovelace", image: null },
+};
+
+const pagination = {
+ totalCount: 3,
+ state: { pageIndex: 0, pageSize: 10 },
+ onChange: fn(),
+};
+const commonArgs = {
+ pagination,
+ hasCancelAccess: true,
+ downloadingIds: new Set<string>(),
+ onDownload: fn(),
+ onCancel: fn(),
+};
+
+export const Default = meta.story({
+ args: {
+ data: {
+ status: "success",
+ data: [
+ completedExport,
+ {
+ ...completedExport,
+ id: "export-2",
+ name: "Pending export",
+ status: "PROCESSING",
+ finishedAt: null,
+ expiresAt: null,
+ isDownloadable: false,
+ },
+ {
+ ...completedExport,
+ id: "export-3",
+ name: "Failed export",
+ status: "FAILED",
+ log: "Export failed",
+ finishedAt: null,
+ expiresAt: null,
+ isDownloadable: false,
+ },
+ ],
+ },
+ ...commonArgs,
+ },
+});
+
+export const Loading = meta.story({
+ args: { ...commonArgs, data: { status: "loading" } },
+});
+
+export const Empty = meta.story({
+ args: { ...commonArgs, data: { status: "success", data: [] } },
+});
+
+export const Error = meta.story({
+ args: {
+ ...commonArgs,
+ data: { status: "error", error: "Unable to load exports" },
+ },
+});
diff --git a/web/src/features/batch-exports/components/BatchExportsTable/BatchExportsTable.tsx b/web/src/features/batch-exports/components/BatchExportsTable/BatchExportsTable.tsx
new file mode 100644
index 0000000000..89ada062cd
--- /dev/null
+++ b/web/src/features/batch-exports/components/BatchExportsTable/BatchExportsTable.tsx
@@ -0,0 +1,161 @@
+import { SettingsTable } from "@/src/components/SettingsTable/SettingsTable";
+import { type TableProps } from "@/src/components/design-system/table/Table";
+import { type PaginationBarProps } from "@/src/components/design-system/PaginationBar/PaginationBar";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { type RouterOutputs } from "@/src/utils/api";
+import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
+import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { ActionButton } from "@/src/components/ActionButton";
+import { DownloadIcon } from "lucide-react";
+import { CustomTooltip } from "@/src/components/design-system/CustomTooltip/CustomTooltip";
+import { useMemo } from "react";
+import { createUserTableColumn } from "@/src/components/design-system/table/columns/createUserTableColumn";
+
+export type BatchExportRow =
+ RouterOutputs["batchExport"]["all"]["exports"][number];
+
+export function BatchExportsTable({
+ data,
+ pagination,
+ hasCancelAccess,
+ downloadingIds,
+ onDownload,
+ onCancel,
+}: {
+ data: TableProps<BatchExportRow>["data"];
+ pagination: PaginationBarProps;
+ hasCancelAccess: boolean;
+ downloadingIds: Set<string>;
+ onDownload: (id: string) => void;
+ onCancel: (id: string) => void;
+}) {
+ const columns = useMemo<LangfuseColumnDef<BatchExportRow>[]>(
+ () => [
+ createTextTableColumn<BatchExportRow>({
+ accessorKey: "name",
+ header: "Name",
+ size: 200,
+ tooltip: ({ row }) => {
+ const { createdAt, finishedAt, expiresAt } = row.original;
+ return [
+ `Created: ${new Date(createdAt).toLocaleString()}`,
+ `Finished: ${finishedAt ? new Date(finishedAt).toLocaleString() : "-"}`,
+ `Download expires: ${expiresAt ? new Date(expiresAt).toLocaleString() : "-"}`,
+ ].join("\n");
+ },
+ }),
+ {
+ accessorKey: "status",
+ id: "status",
+ header: "Status",
+ size: 90,
+ cell: ({ row }) => {
+ const { status, log } = row.original;
+ const badge = <StatusBadge type={status.toLowerCase()} />;
+ // The log only exists on failed exports (worker-written, user-facing
+ // error message); surface it on the badge instead of a dedicated
+ // column that is empty for every successful row.
+ if (!log) {
+ return badge;
+ }
+ return (
+ <CustomTooltip
+ content={
+ <div className="max-w-md whitespace-pre-wrap">{log}</div>
+ }
+ >
+ {({ getTriggerProps }) => (
+ <button
+ type="button"
+ {...getTriggerProps()}
+ aria-label="Export error"
+ >
+ {badge}
+ </button>
+ )}
+ </CustomTooltip>
+ );
+ },
+ },
+ {
+ accessorKey: "isDownloadable",
+ id: "action",
+ header: "Action",
+ size: 130,
+ // One state-dependent action per row: Cancel while queued/processing,
+ // Download (or Expired) once completed — the states never coexist.
+ cell: ({ row }) => {
+ const { id, status, isExpired, isDownloadable } = row.original;
+ if (isDownloadable) {
+ return (
+ <ActionButton
+ icon={<DownloadIcon size={16} />}
+ size="sm"
+ loading={downloadingIds.has(id)}
+ onClick={() => onDownload(id)}
+ >
+ Download
+ </ActionButton>
+ );
+ }
+ if (status === "COMPLETED" && isExpired) {
+ return <span className="text-muted-foreground">Expired</span>;
+ }
+ if (status === "QUEUED" || status === "PROCESSING") {
+ return (
+ <ActionButton
+ hasAccess={hasCancelAccess}
+ size="sm"
+ onClick={() => onCancel(id)}
+ >
+ Cancel
+ </ActionButton>
+ );
+ }
+ return null;
+ },
+ },
+ createDateTableColumn<BatchExportRow>({
+ accessorKey: "expiresAt",
+ header: "Expires",
+ size: 130,
+ mode: "relative",
+ emptyValue: "-",
+ getValue: (expiresAt, { row }) => {
+ const { status, isExpired } = row.original;
+ // The Action column already reads "Expired" for lapsed exports; a
+ // "how long ago" timestamp adds nothing, so show the countdown only
+ // while the download is still available.
+ if (status !== "COMPLETED" || !expiresAt || isExpired) {
+ return undefined;
+ }
+ return expiresAt;
+ },
+ }),
+ createTextTableColumn<BatchExportRow>({
+ accessorKey: "format",
+ header: "Format",
+ size: 70,
+ }),
+ createUserTableColumn<BatchExportRow>({
+ accessorKey: "user",
+ header: "Created By",
+ size: 150,
+ variant: "avatar",
+ emptyValue: "Unknown",
+ }),
+ ],
+ [downloadingIds, hasCancelAccess, onCancel, onDownload],
+ );
+
+ return (
+ <SettingsTable
+ tableName="batchExports"
+ columns={columns}
+ data={data}
+ pagination={pagination}
+ loadingRowCount={Math.max(1, Math.min(pagination.state.pageSize, 8))}
+ />
+ );
+}
diff --git a/web/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable.tsx b/web/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable.tsx
new file mode 100644
index 0000000000..4bd98310ae
--- /dev/null
+++ b/web/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable.tsx
@@ -0,0 +1,103 @@
+import { useCallback, useMemo, useState } from "react";
+import { NumberParam, useQueryParams, withDefault } from "use-query-params";
+
+import { type AsyncTableData } from "@/src/components/design-system/table/Table";
+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";
+import { useHasProjectAccess } from "@/src/features/rbac";
+import { api } from "@/src/utils/api";
+import { safeExtract } from "@/src/utils/map-utils";
+import { BatchExportsTable, type BatchExportRow } from "./BatchExportsTable";
+
+export function ConnectedBatchExportsTable({
+ projectId,
+}: {
+ projectId: string;
+}) {
+ const [paginationState, setPaginationState] = useQueryParams({
+ pageIndex: withDefault(NumberParam, 0),
+ pageSize: withDefault(NumberParam, 10),
+ });
+ const [downloadingIds, setDownloadingIds] = useState<Set<string>>(new Set());
+
+ const batchExports = api.batchExport.all.useQuery({
+ projectId,
+ limit: paginationState.pageSize,
+ page: paginationState.pageIndex,
+ });
+ const cancelBatchExport = api.batchExport.cancel.useMutation({
+ onSuccess: () => {
+ batchExports.refetch();
+ },
+ });
+ const downloadBatchExport = api.batchExport.downloadUrl.useMutation();
+ const hasCancelAccess = useHasProjectAccess({
+ projectId,
+ scope: "batchExports:create",
+ });
+
+ const onDownload = useCallback(
+ (id: string) => {
+ setDownloadingIds((prev) => new Set(prev).add(id));
+ downloadBatchExport.mutate(
+ { projectId, batchExportId: id },
+ {
+ onSuccess: (data) => {
+ window.location.href = data.url;
+ },
+ onSettled: () =>
+ setDownloadingIds((prev) => {
+ const next = new Set(prev);
+ next.delete(id);
+ return next;
+ }),
+ },
+ );
+ },
+ [downloadBatchExport, projectId],
+ );
+ const tableData = useMemo<AsyncTableData<BatchExportRow[]>>(() => {
+ if (batchExports.isPending) return { status: "loading" };
+ if (batchExports.isError) {
+ return { status: "error", error: batchExports.error.message };
+ }
+ return {
+ status: "success",
+ data: safeExtract(batchExports.data, "exports", []),
+ };
+ }, [
+ batchExports.data,
+ batchExports.error,
+ batchExports.isError,
+ batchExports.isPending,
+ ]);
+
+ return (
+ <ConfirmationDialogController<string>
+ title="Cancel batch export?"
+ text="Are you sure you want to cancel this batch export? This action cannot be undone."
+ confirmLabel="Yes, cancel export"
+ variant="destructive"
+ loading={cancelBatchExport.isPending}
+ error={cancelBatchExport.error?.message}
+ onAfterDismiss={cancelBatchExport.reset}
+ onConfirm={async (id) => {
+ await cancelBatchExport.mutateAsync({ projectId, batchExportId: id });
+ }}
+ >
+ {({ openDialog }) => (
+ <BatchExportsTable
+ data={tableData}
+ pagination={{
+ totalCount: batchExports.data?.totalCount ?? null,
+ onChange: setPaginationState,
+ state: paginationState,
+ }}
+ hasCancelAccess={hasCancelAccess}
+ downloadingIds={downloadingIds}
+ onDownload={onDownload}
+ onCancel={openDialog}
+ />
+ )}
+ </ConfirmationDialogController>
+ );
+}