Skip to content

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

feat(tables): add columnvisibility count (#1452)

Richard Krümmel07bd61798f39
diff --git a/web/src/components/table/data-table-column-visibility-filter.tsx b/web/src/components/table/data-table-column-visibility-filter.tsx
index 7628825ebf..8be1d13e69 100644
--- a/web/src/components/table/data-table-column-visibility-filter.tsx
+++ b/web/src/components/table/data-table-column-visibility-filter.tsx
@@ -38,6 +38,29 @@ export function DataTableColumnVisibilityFilter<TData, TValue>({
[setColumnVisibility],
);
+ const calculateColumnCounts = (
+ columns: LangfuseColumnDef<TData, TValue>[],
+ columnVisibility: VisibilityState,
+ ) => {
+ return columns.reduce(
+ (acc, column) => {
+ if (column.enableHiding) {
+ acc.total++;
+ if (
+ column.accessorKey in columnVisibility &&
+ columnVisibility[column.accessorKey]
+ ) {
+ acc.count++;
+ }
+ }
+ return acc;
+ },
+ { count: 0, total: 0 },
+ );
+ };
+
+ const { count, total } = calculateColumnCounts(columns, columnVisibility);
+
return (
<DropdownMenu open={isOpen}>
<DropdownMenuTrigger
@@ -48,7 +71,7 @@ export function DataTableColumnVisibilityFilter<TData, TValue>({
asChild
>
<Button variant="outline" className="ml-auto">
- Columns
+ Columns {count <= total ? `${count}/${total}` : ""}
<ChevronDownIcon className="ml-2 h-4 w-4" />
</Button>
</DropdownMenuTrigger>
diff --git a/web/src/components/table/types.ts b/web/src/components/table/types.ts
index 002eafb563..4161c4ae73 100644
--- a/web/src/components/table/types.ts
+++ b/web/src/components/table/types.ts
@@ -10,6 +10,7 @@ export type LangfuseColumnDef<
TData extends RowData,
TValue = unknown,
> = ColumnDef<TData, TValue> & {
+ accessorKey: string;
defaultHidden?: boolean;
headerTooltip?: {
description: string;
diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsx
index afb8610ca0..9853c6ab3d 100644
--- a/web/src/components/table/use-cases/traces.tsx
+++ b/web/src/components/table/use-cases/traces.tsx
@@ -178,6 +178,7 @@ export default function TracesTable({
const columns: LangfuseColumnDef<TracesTableRow>[] = [
{
id: "select",
+ accessorKey: "select",
header: ({ table }) => (
<Checkbox
checked={
@@ -194,7 +195,7 @@ export default function TracesTable({
}
}}
aria-label="Select all"
- className="opacity-60"
+ className="mt-1 opacity-60 data-[state=checked]:mt-[6px] data-[state=indeterminate]:mt-[6px]"
/>
),
cell: ({ row }) => (
@@ -202,7 +203,7 @@ export default function TracesTable({
checked={row.getIsSelected()}
onCheckedChange={(value) => row.toggleSelected(!!value)}
aria-label="Select row"
- className="opacity-60"
+ className="mt-1 opacity-60 data-[state=checked]:mt-[5px]"
/>
),
},
diff --git a/web/src/features/datasets/components/DatasetItemsTable.tsx b/web/src/features/datasets/components/DatasetItemsTable.tsx
index 973a89cee8..6ee9bd043f 100644
--- a/web/src/features/datasets/components/DatasetItemsTable.tsx
+++ b/web/src/features/datasets/components/DatasetItemsTable.tsx
@@ -103,6 +103,8 @@ export function DatasetItemsTable({
},
{
id: "actions",
+ accessorKey: "actions",
+ header: "Actions",
cell: ({ row }) => {
const id: string = row.getValue("id");
const status: DatasetStatus = row.getValue("status");
diff --git a/web/src/features/datasets/components/DatasetsTable.tsx b/web/src/features/datasets/components/DatasetsTable.tsx
index 0cad4b5cb2..0d32724ce4 100644
--- a/web/src/features/datasets/components/DatasetsTable.tsx
+++ b/web/src/features/datasets/components/DatasetsTable.tsx
@@ -75,6 +75,8 @@ export function DatasetsTable(props: { projectId: string }) {
},
{
id: "actions",
+ accessorKey: "actions",
+ header: "Actions",
cell: ({ row }) => {
const key: RowData["key"] = row.getValue("key");
return (