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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(ui): show team projects to internal users (#28855)
milan-berrif59e4ebc9e98
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.test.tsindex 13b9107bdc1..39d1b28303d 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.test.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.test.ts@@ -115,8 +115,16 @@ describe("useProjects", () => {expect(global.fetch).not.toHaveBeenCalled();});- it("should not fetch when userRole is not an admin role", () => {+ it("should fetch when userRole is an internal user role", async () => {mockUseAuthorized.mockReturnValue({ accessToken: "test-token", userRole: "Internal User" });+ (global.fetch as any).mockResolvedValue({ ok: true, json: async () => mockProjects });+ const { result } = renderHook(() => useProjects(), { wrapper: makeWrapper(queryClient) });+ await waitFor(() => expect(result.current.isSuccess).toBe(true));+ expect(global.fetch).toHaveBeenCalled();+ });++ it("should not fetch when userRole cannot read projects", () => {+ mockUseAuthorized.mockReturnValue({ accessToken: "test-token", userRole: "regular_user" });const { result } = renderHook(() => useProjects(), { wrapper: makeWrapper(queryClient) });expect(result.current.isFetched).toBe(false);expect(global.fetch).not.toHaveBeenCalled();diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.tsindex 7bdc8a4fe6d..c240dbb0170 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.ts@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";import { createQueryKeys } from "../common/queryKeysFactory";import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage, handleError } from "@/components/networking";import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";-import { all_admin_roles } from "@/utils/roles";+import { all_admin_roles, internalUserRoles } from "@/utils/roles";// ── Types ────────────────────────────────────────────────────────────────────@@ -42,6 +42,8 @@ export interface ProjectResponse {export const projectKeys = createQueryKeys("projects");+const projectReaderRoles = [...all_admin_roles, ...internalUserRoles];+// ── Fetch function ───────────────────────────────────────────────────────────const fetchProjects = async (accessToken: string): Promise<ProjectResponse[]> => {@@ -74,6 +76,6 @@ export const useProjects = () => {return useQuery<ProjectResponse[]>({queryKey: projectKeys.list({}),queryFn: async () => fetchProjects(accessToken!),- enabled: Boolean(accessToken) && all_admin_roles.includes(userRole!),+ enabled: Boolean(accessToken) && projectReaderRoles.includes(userRole!),});};