mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
feat(ui): link the Created By cell on the Prompts page (#40753)
The column was plain muted text, so finding out who owns a prompt meant copying the id into the Users page search box. Route it through IdentityCell with userDetailHref, which keeps the proxy admin placeholder unlinked. Claude-Session: https://claude.ai/code/session_01NfwfQhamRNnSqgXMUjf3h4
This commit is contained in:
parent
06964e5603
commit
c53f72c764
2 changed files with 21 additions and 2 deletions
|
|
@ -10,6 +10,8 @@ vi.mock("@/components/networking", () => ({
|
|||
modelHubCall: vi.fn().mockResolvedValue({ data: [] }),
|
||||
}));
|
||||
|
||||
vi.mock("next/navigation", () => ({ useRouter: () => ({ push: vi.fn() }) }));
|
||||
|
||||
const mockPrompts: PromptSpec[] = [
|
||||
{
|
||||
prompt_id: "prompt-newer",
|
||||
|
|
@ -53,6 +55,15 @@ describe("PromptTable", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("links the Created By cell to the creator's detail page, leaving the placeholder unlinked", () => {
|
||||
const prompts = [mockPrompts[0], { ...mockPrompts[1], created_by: "default_user_id" }];
|
||||
render(<PromptTable {...defaultProps} promptsList={prompts} />);
|
||||
|
||||
expect(screen.getByRole("link", { name: "user-1" })).toHaveAttribute("href", "/ui/users?user=user-1");
|
||||
expect(screen.getByText("default_user_id")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("link", { name: "default_user_id" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should display the empty state when data is empty", () => {
|
||||
render(<PromptTable {...defaultProps} promptsList={[]} />);
|
||||
expect(screen.getByText("No prompts yet")).toBeInTheDocument();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import {
|
|||
} from "@/components/ui/dropdown-menu";
|
||||
import { cn } from "@/lib/cva.config";
|
||||
import { copyToClipboard } from "@/utils/dataUtils";
|
||||
import { userDetailHref } from "@/utils/entityLinks";
|
||||
|
||||
import { extractModel, getProviderFromModelHub, ModelGroupInfo } from "./prompt_utils";
|
||||
|
||||
|
|
@ -191,9 +192,16 @@ export const getPromptTableColumns = ({
|
|||
enableSorting: false,
|
||||
cell: ({ row }) => {
|
||||
const createdBy = row.original.created_by;
|
||||
if (!createdBy) {
|
||||
return <span className="text-muted-foreground">-</span>;
|
||||
}
|
||||
return (
|
||||
<span className="block max-w-60 truncate text-sm text-muted-foreground" title={createdBy}>
|
||||
{createdBy || "-"}
|
||||
<span className="block max-w-60" title={createdBy}>
|
||||
<IdentityCell
|
||||
title={createdBy}
|
||||
titleClassName="font-normal text-muted-foreground"
|
||||
href={userDetailHref(createdBy)}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue