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]

feat(ui): link the User ID, Created By and Deleted By cells on Deleted Keys (#40750)

ryan-crabbe-berri06964e5603ec
diff --git a/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysPage.test.tsx b/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysPage.test.tsx
index ee2f42ad85b..31cd407a5e6 100644
--- a/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysPage.test.tsx
+++ b/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysPage.test.tsx
@@ -5,6 +5,8 @@ import { renderWithProviders } from "../../../tests/test-utils";
import DeletedKeysPage from "./DeletedKeysPage";
import { useDeletedKeys, DeletedKeyResponse } from "@/app/(dashboard)/hooks/keys/useKeys";
+vi.mock("next/navigation", () => ({ useRouter: () => ({ push: vi.fn() }) }));
+
vi.mock("@/app/(dashboard)/hooks/keys/useKeys", () => ({
useDeletedKeys: vi.fn(),
}));
diff --git a/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysTable/DeletedKeysTable.test.tsx b/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysTable/DeletedKeysTable.test.tsx
index 7e30ef2c135..dd8007be264 100644
--- a/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysTable/DeletedKeysTable.test.tsx
+++ b/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysTable/DeletedKeysTable.test.tsx
@@ -5,6 +5,8 @@ import { renderWithProviders } from "../../../../tests/test-utils";
import { DeletedKeysTable } from "./DeletedKeysTable";
import { DeletedKeyResponse } from "@/app/(dashboard)/hooks/keys/useKeys";
+vi.mock("next/navigation", () => ({ useRouter: () => ({ push: vi.fn() }) }));
+
const makeDeletedKey = (overrides: Partial<DeletedKeyResponse> = {}): DeletedKeyResponse =>
({
token: "sk-1234567890abcdef",
@@ -86,3 +88,19 @@ it("should show the empty state when there are no deleted keys", () => {
expect(screen.getByText("No deleted keys found")).toBeInTheDocument();
});
+
+it("links the owner, creator and deleter cells to their user detail pages", () => {
+ renderWithProviders(<DeletedKeysTable {...defaultProps} keys={[makeDeletedKey({ deleted_by: "deleter-1" })]} />);
+
+ expect(screen.getByRole("link", { name: "user-1" })).toHaveAttribute("href", "/ui/users?user=user-1");
+ expect(screen.getByRole("link", { name: "creator-1" })).toHaveAttribute("href", "/ui/users?user=creator-1");
+ expect(screen.getByRole("link", { name: "deleter-1" })).toHaveAttribute("href", "/ui/users?user=deleter-1");
+});
+
+it("leaves the default_user_id placeholder unlinked", () => {
+ const placeholderKey = makeDeletedKey({ user_id: "default_user_id", created_by: "default_user_id" });
+ renderWithProviders(<DeletedKeysTable {...defaultProps} keys={[placeholderKey]} />);
+
+ expect(screen.getAllByText("default_user_id")).toHaveLength(2);
+ expect(screen.queryByRole("link", { name: "default_user_id" })).not.toBeInTheDocument();
+});
diff --git a/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysTable/DeletedKeysTableColumns.tsx b/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysTable/DeletedKeysTableColumns.tsx
index aa7d6380cc3..32185f867b4 100644
--- a/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysTable/DeletedKeysTableColumns.tsx
+++ b/ui/litellm-dashboard/src/components/DeletedKeysPage/DeletedKeysTable/DeletedKeysTableColumns.tsx
@@ -3,8 +3,9 @@
import { ColumnDef } from "@tanstack/react-table";
import { DataTableSortHeader } from "@/components/shared/DataTable";
-import { DateCell, IdCell, MoneyCell } from "@/components/shared/table_cells";
+import { DateCell, IdCell, IdentityCell, MoneyCell } from "@/components/shared/table_cells";
import { DeletedKeyResponse } from "@/app/(dashboard)/hooks/keys/useKeys";
+import { userDetailHref } from "@/utils/entityLinks";
function TruncatedTextCell({ value }: { value: string | null | undefined }) {
if (!value) {
@@ -17,6 +18,17 @@ function TruncatedTextCell({ value }: { value: string | null | undefined }) {
);
}
+function UserLinkCell({ userId }: { userId: string | null | undefined }) {
+ if (!userId) {
+ return <span className="text-muted-foreground">-</span>;
+ }
+ return (
+ <span className="block max-w-60" title={userId}>
+ <IdentityCell title={userId} titleClassName="font-normal" href={userDetailHref(userId)} />
+ </span>
+ );
+}
+
export const getDeletedKeysTableColumns = (): ColumnDef<DeletedKeyResponse>[] => [
{
id: "token",
@@ -89,7 +101,7 @@ export const getDeletedKeysTableColumns = (): ColumnDef<DeletedKeyResponse>[] =>
header: "User ID",
size: 120,
enableSorting: false,
- cell: ({ row }) => <IdCell value={row.original.user_id} variant="plain" />,
+ cell: ({ row }) => <UserLinkCell userId={row.original.user_id} />,
},
{
id: "created_at",
@@ -107,7 +119,7 @@ export const getDeletedKeysTableColumns = (): ColumnDef<DeletedKeyResponse>[] =>
header: "Created By",
size: 120,
enableSorting: false,
- cell: ({ row }) => <TruncatedTextCell value={row.original.created_by} />,
+ cell: ({ row }) => <UserLinkCell userId={row.original.created_by} />,
},
{
id: "deleted_at",
@@ -125,6 +137,6 @@ export const getDeletedKeysTableColumns = (): ColumnDef<DeletedKeyResponse>[] =>
header: "Deleted By",
size: 120,
enableSorting: false,
- cell: ({ row }) => <TruncatedTextCell value={row.original.deleted_by} />,
+ cell: ({ row }) => <UserLinkCell userId={row.original.deleted_by} />,
},
];