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]

fix(ui): name the popover copy buttons after the field they copy

ryan-crabbe-berri06b259e09207
diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/UserPopoverCell.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/UserPopoverCell.tsx
index 223d66d7421..eb786e45541 100644
--- a/ui/litellm-dashboard/src/components/shared/table_cells/UserPopoverCell.tsx
+++ b/ui/litellm-dashboard/src/components/shared/table_cells/UserPopoverCell.tsx
@@ -31,7 +31,7 @@ export function UserPopoverCell({ userAlias, userEmail, userId, width }: UserPop
<div key={label} className="flex flex-col min-w-0">
<span className="text-muted-foreground">{label}</span>
{value ? (
- <IdCell value={value} variant="plain" copyable className="max-w-full" />
+ <IdCell value={value} variant="plain" copyable copyLabel={`Copy ${label}`} className="max-w-full" />
) : (
<span className="font-mono">-</span>
)}
diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/id_cell.test.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/id_cell.test.tsx
index 395c1815dd0..c715210fdde 100644
--- a/ui/litellm-dashboard/src/components/shared/table_cells/id_cell.test.tsx
+++ b/ui/litellm-dashboard/src/components/shared/table_cells/id_cell.test.tsx
@@ -71,6 +71,14 @@ describe("IdCell", () => {
expect(rowClick).not.toHaveBeenCalled();
});
+ it("names the copy button after the field it copies", async () => {
+ const user = userEvent.setup();
+ render(<IdCell value="[email protected]" copyable copyLabel="Copy User Email" />);
+ expect(screen.queryByRole("button", { name: "Copy ID" })).not.toBeInTheDocument();
+ await user.click(screen.getByRole("button", { name: "Copy User Email" }));
+ expect(copyToClipboardMock).toHaveBeenCalledWith("[email protected]");
+ });
+
it("passes dataTestId through to the id element", () => {
render(<IdCell value="k-1" dataTestId="key-id-cell" />);
expect(screen.getByTestId("key-id-cell")).toHaveTextContent("k-1");
diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/id_cell.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/id_cell.tsx
index 1b109a86106..33c7f835e64 100644
--- a/ui/litellm-dashboard/src/components/shared/table_cells/id_cell.tsx
+++ b/ui/litellm-dashboard/src/components/shared/table_cells/id_cell.tsx
@@ -15,6 +15,7 @@ interface IdCellProps {
variant?: IdCellVariant;
onClick?: (value: string) => void;
copyable?: boolean;
+ copyLabel?: string;
truncate?: boolean;
fallback?: string;
tooltip?: React.ReactNode;
@@ -39,6 +40,7 @@ export function IdCell({
variant = "pill",
onClick,
copyable = false,
+ copyLabel = "Copy ID",
truncate = true,
fallback = "-",
tooltip,
@@ -80,7 +82,7 @@ export function IdCell({
{withTooltip}
<button
type="button"
- aria-label="Copy ID"
+ aria-label={copyLabel}
className="shrink-0 cursor-pointer text-muted-foreground hover:text-foreground"
onClick={(event) => {
event.stopPropagation();
diff --git a/ui/litellm-dashboard/src/components/team/TeamVirtualKeysTable.test.tsx b/ui/litellm-dashboard/src/components/team/TeamVirtualKeysTable.test.tsx
index 76df0d12539..08408fb4ff4 100644
--- a/ui/litellm-dashboard/src/components/team/TeamVirtualKeysTable.test.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamVirtualKeysTable.test.tsx
@@ -396,7 +396,8 @@ describe("TeamVirtualKeysTable", () => {
refetch: vi.fn(),
} as any);
renderWithProviders(<TeamVirtualKeysTable {...defaultProps} organization={organization} />);
- return (await screen.findByText(key.key_alias as string)).closest("tr") as HTMLElement;
+ await screen.findByText(key.key_alias as string);
+ return screen.getByRole("row", { name: new RegExp(key.key_alias as string) });
};
it("points the Organization ID cell at the org's detail page", async () => {
@@ -433,17 +434,18 @@ describe("TeamVirtualKeysTable", () => {
it("leaves the default_user_id placeholder unlinked in the User ID and Created By cells", async () => {
const placeholder = { user_id: "default_user_id", user_email: "[email protected]", user_alias: "Proxy Admin" };
- const row = await renderRow(
- createMockKey({
- user_id: placeholder.user_id,
- user: placeholder,
- created_by: placeholder.user_id,
- created_by_user: placeholder,
- }),
- );
+ const ownedAndCreatedByPlaceholder = {
+ user_id: placeholder.user_id,
+ user: placeholder,
+ created_by: placeholder.user_id,
+ created_by_user: placeholder,
+ };
+ const row = await renderRow(createMockKey(ownedAndCreatedByPlaceholder));
expect(within(row).getByText("Default Proxy Admin")).toBeInTheDocument();
expect(within(row).getByText("Proxy Admin")).toBeInTheDocument();
expect(within(row).queryByRole("link", { name: "Proxy Admin" })).not.toBeInTheDocument();
+ expect(within(row).queryByRole("link", { name: placeholder.user_email })).not.toBeInTheDocument();
+ expect(within(row).queryByRole("link", { name: "Default Proxy Admin" })).not.toBeInTheDocument();
});
});
});