Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

refactor(ui): give MemberTable its own extra-column type

Yuneng Jiang26e055248b2d
diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.json
index 53768c6f945..85bc950af97 100644
--- a/ui/litellm-dashboard/eslint-suppressions.json
+++ b/ui/litellm-dashboard/eslint-suppressions.json
@@ -2398,11 +2398,6 @@
"count": 2
}
},
- "src/components/common_components/MemberTable.tsx": {
- "no-restricted-imports": {
- "count": 1
- }
- },
"src/components/common_components/MetadataKeyValueFields.test.tsx": {
"no-restricted-imports": {
"count": 1
@@ -2889,9 +2884,6 @@
"src/components/organization/organization_view.tsx": {
"local/filename-pascal-case": {
"count": 1
- },
- "no-restricted-imports": {
- "count": 1
}
},
"src/components/page_utils.test.ts": {
diff --git a/ui/litellm-dashboard/src/components/common_components/MemberTable.tsx b/ui/litellm-dashboard/src/components/common_components/MemberTable.tsx
index 3f4cdf5931b..19c2377bafe 100644
--- a/ui/litellm-dashboard/src/components/common_components/MemberTable.tsx
+++ b/ui/litellm-dashboard/src/components/common_components/MemberTable.tsx
@@ -3,11 +3,17 @@ import { Member } from "@/components/networking";
import { StatusBadge } from "@/components/shared/table_cells";
import { Button } from "@/components/ui/button";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
-import type { ColumnsType } from "antd/es/table";
import { Crown, Info, User, UserPlus } from "lucide-react";
import React from "react";
import TableIconActionButton from "./IconActionButton/TableIconActionButtons/TableIconActionButton";
+export interface MemberTableColumn {
+ title: React.ReactNode;
+ key: React.Key;
+ dataIndex?: keyof Member;
+ render?: (value: Member[keyof Member], member: Member, index: number) => React.ReactNode;
+}
+
export interface MemberTableProps {
members: Member[];
canEdit: boolean;
@@ -16,22 +22,14 @@ export interface MemberTableProps {
onAddMember?: () => void;
roleColumnTitle?: string;
roleTooltip?: string;
- extraColumns?: ColumnsType<Member>;
+ extraColumns?: MemberTableColumn[];
showDeleteForMember?: (member: Member) => boolean;
emptyText?: string;
}
-type ExtraColumn = ColumnsType<Member>[number];
-
-const extraColumnTitle = (column: ExtraColumn): React.ReactNode =>
- typeof column.title === "function" ? null : column.title;
-
-const extraColumnCell = (column: ExtraColumn, member: Member, index: number): React.ReactNode => {
- const dataIndex = "dataIndex" in column && typeof column.dataIndex === "string" ? column.dataIndex : undefined;
- const value = dataIndex ? member[dataIndex as keyof Member] : undefined;
- const rendered = column.render?.(value, member, index);
- if (typeof rendered === "string" || typeof rendered === "number") return rendered;
- return React.isValidElement(rendered) ? rendered : null;
+const extraColumnCell = (column: MemberTableColumn, member: Member, index: number): React.ReactNode => {
+ const value = column.dataIndex ? member[column.dataIndex] : undefined;
+ return column.render ? column.render(value, member, index) : value;
};
const STICKY_ACTIONS_CLASS = "sticky right-0 w-[120px] bg-background";
@@ -70,8 +68,8 @@ export default function MemberTable({
roleColumnTitle
)}
</TableHead>
- {extraColumns.map((column, columnIndex) => (
- <TableHead key={column.key ?? columnIndex}>{extraColumnTitle(column)}</TableHead>
+ {extraColumns.map((column) => (
+ <TableHead key={column.key}>{column.title}</TableHead>
))}
<TableHead className={STICKY_ACTIONS_CLASS}>Actions</TableHead>
</TableRow>
@@ -104,8 +102,8 @@ export default function MemberTable({
<span className="capitalize">{member.role || "-"}</span>
</span>
</TableCell>
- {extraColumns.map((column, columnIndex) => (
- <TableCell key={column.key ?? columnIndex}>{extraColumnCell(column, member, memberIndex)}</TableCell>
+ {extraColumns.map((column) => (
+ <TableCell key={column.key}>{extraColumnCell(column, member, memberIndex)}</TableCell>
))}
<TableCell className={STICKY_ACTIONS_CLASS}>
{canEdit ? (
diff --git a/ui/litellm-dashboard/src/components/organization/organization_view.tsx b/ui/litellm-dashboard/src/components/organization/organization_view.tsx
index a9f79810e1d..8c1607088c9 100644
--- a/ui/litellm-dashboard/src/components/organization/organization_view.tsx
+++ b/ui/litellm-dashboard/src/components/organization/organization_view.tsx
@@ -11,10 +11,9 @@ import { formatNumberWithCommas } from "@/utils/dataUtils";
import { teamDetailHref } from "@/utils/entityLinks";
import { createTeamAliasMap } from "@/utils/teamUtils";
import { BadgeLink } from "@/components/shared/BadgeLink";
-import type { ColumnsType } from "antd/es/table";
import { ArrowLeft } from "lucide-react";
import React, { useMemo, useState } from "react";
-import MemberTable from "../common_components/MemberTable";
+import MemberTable, { type MemberTableColumn } from "../common_components/MemberTable";
import UserSearchModal from "../common_components/user_search_modal";
import NotificationsManager from "../molecules/notifications_manager";
import {
@@ -122,7 +121,7 @@ const OrganizationInfoView: React.FC<OrganizationInfoProps> = ({
return <div className="p-4">Organization not found</div>;
}
- const orgExtraColumns: ColumnsType<Member> = [
+ const orgExtraColumns: MemberTableColumn[] = [
{
title: "Spend (USD)",
key: "spend",