mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
feat(ui): link user detail team names to team pages
This commit is contained in:
parent
7a5b98e6a9
commit
1b2f05d6b0
2 changed files with 30 additions and 1 deletions
|
|
@ -42,8 +42,16 @@ const MOCK_USER_DATA_NO_TEAMS = {
|
|||
teams: [],
|
||||
};
|
||||
|
||||
vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({ push: vi.fn() }),
|
||||
usePathname: () => "/users",
|
||||
useSearchParams: () => new URLSearchParams(window.location.search),
|
||||
}));
|
||||
|
||||
// entityLinks -> migratedPages imports serverRootPath from the same module, so the mock must export it too.
|
||||
vi.mock("@/components/networking", () => {
|
||||
return {
|
||||
serverRootPath: "/",
|
||||
userGetInfoV2: (...args: any[]) => mockUserGetInfoV2(...args),
|
||||
userDeleteCall: vi.fn(),
|
||||
userUpdateUserCall: (...args: unknown[]) => mockUserUpdateUserCall(...args),
|
||||
|
|
@ -145,6 +153,21 @@ describe("UserInfoView", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should link each team name to its team page", async () => {
|
||||
render(<UserInfoView {...defaultProps} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByRole("link", { name: "Alpha Team" })).toHaveAttribute(
|
||||
"href",
|
||||
expect.stringContaining("/teams?team=team-1"),
|
||||
);
|
||||
expect(screen.getByRole("link", { name: "Beta Team" })).toHaveAttribute(
|
||||
"href",
|
||||
expect.stringContaining("/teams?team=team-2"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("should show 'No teams' when user has no teams", async () => {
|
||||
mockUserGetInfoV2.mockResolvedValue(MOCK_USER_DATA_NO_TEAMS);
|
||||
render(<UserInfoView {...defaultProps} />);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ import {
|
|||
} from "@/components/networking";
|
||||
import { Button as AntdButton, Modal, Select as AntdSelect, Form, Tooltip } from "antd";
|
||||
import { rolesWithWriteAccess } from "@/utils/roles";
|
||||
import { teamDetailHref } from "@/utils/entityLinks";
|
||||
import { BadgeLink } from "@/components/shared/BadgeLink";
|
||||
import { UserEditView } from "../user_edit_view";
|
||||
import OnboardingModal, { InvitationLink } from "@/components/onboarding_link";
|
||||
import { formatNumberWithCommas, copyToClipboard as utilCopyToClipboard } from "@/utils/dataUtils";
|
||||
|
|
@ -484,7 +486,11 @@ export default function UserInfoView({
|
|||
<TableBody>
|
||||
{teamDetails.slice(0, isTeamsExpanded ? teamDetails.length : 20).map((team) => (
|
||||
<TableRow key={team.team_id}>
|
||||
<TableCell>{team.team_alias || team.team_id}</TableCell>
|
||||
<TableCell>
|
||||
<BadgeLink href={teamDetailHref(team.team_id)}>
|
||||
{team.team_alias || team.team_id}
|
||||
</BadgeLink>
|
||||
</TableCell>
|
||||
{isProxyAdmin && (
|
||||
<TableCell className="text-right">
|
||||
<Button
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue