From 74ae7deee3af588ddb37598e285c24bb57a336f5 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 9 Oct 2024 16:02:08 +0530 Subject: [PATCH] uo fixes for default team (#6134) --- .../src/components/dashboard_default_team.tsx | 17 +++++++++++++++++ .../src/components/user_dashboard.tsx | 2 ++ 2 files changed, 19 insertions(+) diff --git a/ui/litellm-dashboard/src/components/dashboard_default_team.tsx b/ui/litellm-dashboard/src/components/dashboard_default_team.tsx index 0182d5538..04481eadc 100644 --- a/ui/litellm-dashboard/src/components/dashboard_default_team.tsx +++ b/ui/litellm-dashboard/src/components/dashboard_default_team.tsx @@ -1,13 +1,16 @@ import React, { useState, useEffect } from "react"; import { Select, SelectItem, Text, Title } from "@tremor/react"; import { ProxySettings, UserInfo } from "./user_dashboard"; +import { getProxyBaseUrlAndLogoutUrl } from "./networking" interface DashboardTeamProps { teams: Object[] | null; setSelectedTeam: React.Dispatch>; userRole: string | null; proxySettings: ProxySettings | null; + setProxySettings: React.Dispatch>; userInfo: UserInfo | null; + accessToken: string | null; } type TeamInterface = { @@ -22,7 +25,9 @@ const DashboardTeam: React.FC = ({ setSelectedTeam, userRole, proxySettings, + setProxySettings, userInfo, + accessToken }) => { console.log(`userInfo: ${JSON.stringify(userInfo)}`) const defaultTeam: TeamInterface = { @@ -32,10 +37,22 @@ const DashboardTeam: React.FC = ({ max_budget: userInfo?.max_budget || null, } + const getProxySettings = async () => { + if (proxySettings === null && accessToken) { + const proxy_settings: ProxySettings = await getProxyBaseUrlAndLogoutUrl(accessToken); + setProxySettings(proxy_settings); + } + }; + + useEffect(() => { + getProxySettings(); + }, [proxySettings]); const [value, setValue] = useState(defaultTeam); let updatedTeams; + console.log(`userRole: ${userRole}`) + console.log(`proxySettings: ${JSON.stringify(proxySettings)}`) if (userRole === "App User") { // Non-Admin SSO users should only see their own team - they should not see "Default Team" updatedTeams = teams; diff --git a/ui/litellm-dashboard/src/components/user_dashboard.tsx b/ui/litellm-dashboard/src/components/user_dashboard.tsx index 487bda551..527d16c23 100644 --- a/ui/litellm-dashboard/src/components/user_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/user_dashboard.tsx @@ -349,7 +349,9 @@ const UserDashboard: React.FC = ({ setSelectedTeam={setSelectedTeam} userRole={userRole} proxySettings={proxySettings} + setProxySettings={setProxySettings} userInfo={userSpendData} + accessToken={accessToken} />