From 59693d501904e12e7742ce165e5b19046fb41d20 Mon Sep 17 00:00:00 2001
From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Date: Fri, 11 Sep 2026 09:08:39 +0000
Subject: [PATCH] fix(ui): only offer team admins the teams they administer in
the Team ID selector
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
---
.../src/components/model_info_view.test.tsx | 26 +++++++++++++++++++
.../src/components/model_info_view.tsx | 11 +++-----
ui/litellm-dashboard/src/utils/roles.ts | 11 ++++++++
3 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/ui/litellm-dashboard/src/components/model_info_view.test.tsx b/ui/litellm-dashboard/src/components/model_info_view.test.tsx
index 33f77085551..c5a03b0eed1 100644
--- a/ui/litellm-dashboard/src/components/model_info_view.test.tsx
+++ b/ui/litellm-dashboard/src/components/model_info_view.test.tsx
@@ -1668,6 +1668,32 @@ describe("ModelInfoView", () => {
expect(payload.model_info.team_id).toBe("team-2");
});
+ it("only offers a team admin the teams they administer", async () => {
+ mockUseTeams.mockReturnValue({
+ data: [
+ { team_id: "team-1", team_alias: "alpha", members_with_roles: [{ user_id: "123", role: "admin" }] },
+ { team_id: "team-2", team_alias: "beta", members_with_roles: [{ user_id: "123", role: "user" }] },
+ { team_id: "team-3", team_alias: "gamma", members_with_roles: [{ user_id: "123", role: "admin" }] },
+ ],
+ isLoading: false,
+ error: null,
+ });
+ const teamModel = {
+ ...defaultModelData,
+ model_info: { ...defaultModelData.model_info, team_id: "team-1" },
+ };
+ mockUseModelsInfo.mockReturnValue({ data: { data: [teamModel] }, isLoading: false, error: null });
+ mockModelInfoV1Call.mockResolvedValue({ data: [teamModel] });
+ const user = userEvent.setup();
+ render(
Loading...
diff --git a/ui/litellm-dashboard/src/utils/roles.ts b/ui/litellm-dashboard/src/utils/roles.ts index 62a5f02cc39..30b53e9b089 100644 --- a/ui/litellm-dashboard/src/utils/roles.ts +++ b/ui/litellm-dashboard/src/utils/roles.ts @@ -46,6 +46,17 @@ export const isUserTeamAdminForSingleTeam = (teamMemberWithRoles: Member[] | nul return teamMemberWithRoles.some((member) => member.user_id === userID && member.role === "admin"); }; +export const teamsUserCanAssign = ( + teams: Team[] | null, + userRole: string | null, + userID: string | null, +): Team[] | null => { + if (teams == null || all_admin_roles.includes(userRole ?? "")) { + return teams; + } + return teams.filter((team) => isUserTeamAdminForSingleTeam(team.members_with_roles, userID ?? "")); +}; + export const isOrgAdminForAnyOrg = ( organizations: Organization[] | null | undefined, userID: string | null | undefined,