Skip to content

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]

refactor antd tabs and table

yuneng-jiangc2536ee82ac3
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/ModelsAndEndpointsView.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/ModelsAndEndpointsView.tsx
index 8bfbaa8d3a6..9d77774cb4c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/ModelsAndEndpointsView.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/ModelsAndEndpointsView.tsx
@@ -26,7 +26,7 @@ import ModelGroupAliasSettings from "../../../components/model_group_alias_setti
import ModelInfoView from "../../../components/model_info_view";
import NotificationsManager from "../../../components/molecules/notifications_manager";
import PassThroughSettings from "../../../components/pass_through_settings";
-import TeamInfoView from "../../../components/team/team_info";
+import TeamInfoView from "../../../components/team/TeamInfo";
import useAuthorized from "../hooks/useAuthorized";
interface ModelDashboardProps {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/teams/TeamsView.tsx b/ui/litellm-dashboard/src/app/(dashboard)/teams/TeamsView.tsx
index 10616e95523..88bdf3cdda0 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/teams/TeamsView.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/teams/TeamsView.tsx
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
import { teamDeleteCall, Organization } from "@/components/networking";
import { fetchTeams } from "@/components/common_components/fetch_teams";
import { Form } from "antd";
-import TeamInfoView from "@/components/team/team_info";
+import TeamInfoView from "@/components/team/TeamInfo";
import TeamSSOSettings from "@/components/TeamSSOSettings";
import { isAdminRole } from "@/utils/roles";
import { Card, Button, Col, Text, Grid, TabPanel } from "@tremor/react";
diff --git a/ui/litellm-dashboard/src/components/OldTeams.test.tsx b/ui/litellm-dashboard/src/components/OldTeams.test.tsx
index 91b428c8c98..0ca37cc82d7 100644
--- a/ui/litellm-dashboard/src/components/OldTeams.test.tsx
+++ b/ui/litellm-dashboard/src/components/OldTeams.test.tsx
@@ -52,7 +52,7 @@ vi.mock("./key_team_helpers/fetch_available_models_team_key", () => ({
}),
}));
-vi.mock("@/components/team/team_info", () => ({
+vi.mock("@/components/team/TeamInfo", () => ({
__esModule: true,
default: (props: any) => {
mockTeamInfoView(props);
diff --git a/ui/litellm-dashboard/src/components/OldTeams.tsx b/ui/litellm-dashboard/src/components/OldTeams.tsx
index 4eab197db14..ecc6a624be0 100644
--- a/ui/litellm-dashboard/src/components/OldTeams.tsx
+++ b/ui/litellm-dashboard/src/components/OldTeams.tsx
@@ -1,6 +1,6 @@
import { useOrganizations } from "@/app/(dashboard)/hooks/organizations/useOrganizations";
import AvailableTeamsPanel from "@/components/team/available_teams";
-import TeamInfoView from "@/components/team/team_info";
+import TeamInfoView from "@/components/team/TeamInfo";
import TeamSSOSettings from "@/components/TeamSSOSettings";
import { isProxyAdminRole } from "@/utils/roles";
import { InfoCircleOutlined } from "@ant-design/icons";
diff --git a/ui/litellm-dashboard/src/components/team/team_info.test.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
similarity index 88%
rename from ui/litellm-dashboard/src/components/team/team_info.test.tsx
rename to ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
index fa1b13fbd2d..7a15a6e3f22 100644
--- a/ui/litellm-dashboard/src/components/team/team_info.test.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
@@ -3,7 +3,7 @@ import { screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { renderWithProviders } from "../../../tests/test-utils";
-import TeamInfoView from "./team_info";
+import TeamInfoView from "./TeamInfo";
vi.mock("@/components/networking", () => ({
teamInfoCall: vi.fn(),
@@ -40,7 +40,7 @@ vi.mock("@/app/(dashboard)/hooks/users/useCurrentUser", () => ({
useCurrentUser: vi.fn(),
}));
-vi.mock("@/components/team/team_member_view", () => ({
+vi.mock("@/components/team/TeamMemberTab", () => ({
default: vi.fn(({ setIsAddMemberModalVisible }) => (
<div>
<button onClick={() => setIsAddMemberModalVisible(true)}>Add Member</button>
@@ -89,10 +89,6 @@ vi.mock("@/components/team/member_permissions", () => ({
default: vi.fn(() => <div>Member Permissions</div>),
}));
-vi.mock("@/components/team/member_permissions", () => ({
- default: vi.fn(() => <div>Member Permissions</div>),
-}));
-
import { useAllProxyModels } from "@/app/(dashboard)/hooks/models/useModels";
import { useOrganization } from "@/app/(dashboard)/hooks/organizations/useOrganizations";
import { useTeam } from "@/app/(dashboard)/hooks/teams/useTeams";
@@ -335,10 +331,10 @@ describe("TeamInfoView", () => {
await user.click(settingsTab);
await waitFor(() => {
- expect(screen.getByRole("button", { name: "Edit Settings" })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: /edit settings/i })).toBeInTheDocument();
});
- const editButton = screen.getByRole("button", { name: "Edit Settings" });
+ const editButton = screen.getByRole("button", { name: /edit settings/i });
await user.click(editButton);
await waitFor(() => {
@@ -361,17 +357,17 @@ describe("TeamInfoView", () => {
await user.click(settingsTab);
await waitFor(() => {
- expect(screen.getByRole("button", { name: "Edit Settings" })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: /edit settings/i })).toBeInTheDocument();
});
- const editButton = screen.getByRole("button", { name: "Edit Settings" });
+ const editButton = screen.getByRole("button", { name: /edit settings/i });
await user.click(editButton);
await waitFor(() => {
expect(screen.getByLabelText("Team Name")).toBeInTheDocument();
});
- const cancelButton = screen.getByRole("button", { name: "Cancel" });
+ const cancelButton = screen.getByRole("button", { name: /cancel/i });
await user.click(cancelButton);
await waitFor(() => {
@@ -438,10 +434,10 @@ describe("TeamInfoView", () => {
await user.click(settingsTab);
await waitFor(() => {
- expect(screen.getByRole("button", { name: "Edit Settings" })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: /edit settings/i })).toBeInTheDocument();
});
- const editButton = screen.getByRole("button", { name: "Edit Settings" });
+ const editButton = screen.getByRole("button", { name: /edit settings/i });
await user.click(editButton);
const secretField = await screen.findByPlaceholderText(
@@ -472,10 +468,10 @@ describe("TeamInfoView", () => {
await user.click(settingsTab);
await waitFor(() => {
- expect(screen.getByRole("button", { name: "Edit Settings" })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: /edit settings/i })).toBeInTheDocument();
});
- const editButton = screen.getByRole("button", { name: "Edit Settings" });
+ const editButton = screen.getByRole("button", { name: /edit settings/i });
await user.click(editButton);
const secretField = await screen.findByPlaceholderText(
@@ -502,10 +498,10 @@ describe("TeamInfoView", () => {
await user.click(membersTab);
await waitFor(() => {
- expect(screen.getByRole("button", { name: "Add Member" })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: /add member/i })).toBeInTheDocument();
});
- const addButton = screen.getByRole("button", { name: "Add Member" });
+ const addButton = screen.getByRole("button", { name: /add member/i });
await user.click(addButton);
await waitFor(() => {
@@ -603,6 +599,47 @@ describe("TeamInfoView", () => {
});
});
+ it("should open Settings tab by default when editTeam is true and user can edit", async () => {
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData());
+
+ renderWithProviders(<TeamInfoView {...defaultProps} editTeam={true} />);
+
+ await waitFor(() => {
+ const teamNameElements = screen.queryAllByText("Test Team");
+ expect(teamNameElements.length).toBeGreaterThan(0);
+ });
+
+ expect(screen.getByText("Team Settings")).toBeInTheDocument();
+ });
+
+ it("should open Overview tab by default when editTeam is false", async () => {
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData());
+
+ renderWithProviders(<TeamInfoView {...defaultProps} editTeam={false} />);
+
+ await waitFor(() => {
+ const teamNameElements = screen.queryAllByText("Test Team");
+ expect(teamNameElements.length).toBeGreaterThan(0);
+ });
+
+ expect(screen.getByText("Budget Status")).toBeInTheDocument();
+ });
+
+ it("should open Overview tab by default when editTeam is true but user cannot edit", async () => {
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData());
+
+ renderWithProviders(
+ <TeamInfoView {...defaultProps} editTeam={true} is_team_admin={false} is_proxy_admin={false} />
+ );
+
+ await waitFor(() => {
+ const teamNameElements = screen.queryAllByText("Test Team");
+ expect(teamNameElements.length).toBeGreaterThan(0);
+ });
+
+ expect(screen.getByText("Budget Status")).toBeInTheDocument();
+ });
+
it("should display soft budget alerting emails in settings view when present", async () => {
const user = userEvent.setup();
vi.mocked(networking.teamInfoCall).mockResolvedValue(
diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
new file mode 100644
index 00000000000..d081538fb64
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
@@ -0,0 +1,1294 @@
+import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
+import UserSearchModal from "@/components/common_components/user_search_modal";
+import {
+ getGuardrailsList,
+ getPoliciesList,
+ getPolicyInfoWithGuardrails,
+ Member,
+ Organization,
+ organizationInfoCall,
+ teamInfoCall,
+ teamMemberAddCall,
+ teamMemberDeleteCall,
+ teamMemberUpdateCall,
+ teamUpdateCall,
+} from "@/components/networking";
+import { formatNumberWithCommas } from "@/utils/dataUtils";
+import { mapEmptyStringToNull } from "@/utils/keyUpdateUtils";
+import { isProxyAdminRole } from "@/utils/roles";
+import { EditOutlined, InfoCircleOutlined, SaveOutlined } from "@ant-design/icons";
+import { ArrowLeftIcon } from "@heroicons/react/outline";
+import { Badge, Card, Grid, Text, TextInput, Title } from "@tremor/react";
+import { Button, Form, Input, message, Select, Switch, Tabs, Tooltip } from "antd";
+import { CheckIcon, CopyIcon } from "lucide-react";
+import React, { useEffect, useMemo, useState } from "react";
+import { copyToClipboard as utilCopyToClipboard } from "../../utils/dataUtils";
+import AgentSelector from "../agent_management/AgentSelector";
+import DeleteResourceModal from "../common_components/DeleteResourceModal";
+import DurationSelect from "../common_components/DurationSelect";
+import PassThroughRoutesSelector from "../common_components/PassThroughRoutesSelector";
+import { unfurlWildcardModelsInList } from "../key_team_helpers/fetch_available_models_team_key";
+import LoggingSettingsView from "../logging_settings_view";
+import MCPServerSelector from "../mcp_server_management/MCPServerSelector";
+import MCPToolPermissions from "../mcp_server_management/MCPToolPermissions";
+import { ModelSelect } from "../ModelSelect/ModelSelect";
+import NotificationsManager from "../molecules/notifications_manager";
+import { fetchMCPAccessGroups } from "../networking";
+import ObjectPermissionsView from "../object_permissions_view";
+import NumericalInput from "../shared/numerical_input";
+import VectorStoreSelector from "../vector_store_management/VectorStoreSelector";
+import EditLoggingSettings from "./EditLoggingSettings";
+import MemberModal from "./EditMembership";
+import MemberPermissions from "./member_permissions";
+import {
+ getTeamInfoDefaultTab,
+ getTeamInfoVisibleTabs,
+ TEAM_INFO_TAB_KEYS,
+ TEAM_INFO_TAB_LABELS,
+} from "./tabVisibilityUtils";
+import TeamMembersComponent from "./TeamMemberTab";
+
+export interface TeamMembership {
+ user_id: string;
+ team_id: string;
+ budget_id: string;
+ spend: number;
+ litellm_budget_table: {
+ budget_id: string;
+ soft_budget: number | null;
+ max_budget: number | null;
+ max_parallel_requests: number | null;
+ tpm_limit: number | null;
+ rpm_limit: number | null;
+ model_max_budget: Record<string, number> | null;
+ budget_duration: string | null;
+ };
+}
+
+export interface TeamData {
+ team_id: string;
+ team_info: {
+ team_alias: string;
+ team_id: string;
+ organization_id: string | null;
+ admins: string[];
+ members: string[];
+ members_with_roles: Member[];
+ metadata: Record<string, any>;
+ tpm_limit: number | null;
+ rpm_limit: number | null;
+ max_budget: number | null;
+ soft_budget?: number | null;
+ budget_duration: string | null;
+ models: string[];
+ blocked: boolean;
+ spend: number;
+ max_parallel_requests: number | null;
+ budget_reset_at: string | null;
+ model_id: string | null;
+ litellm_model_table: {
+ model_aliases: Record<string, string>;
+ } | null;
+ created_at: string;
+ guardrails?: string[];
+ policies?: string[];
+ object_permission?: {
+ object_permission_id: string;
+ mcp_servers: string[];
+ mcp_access_groups?: string[];
+ mcp_tool_permissions?: Record<string, string[]>;
+ vector_stores: string[];
+ agents?: string[];
+ agent_access_groups?: string[];
+ };
+ team_member_budget_table: {
+ max_budget: number;
+ budget_duration: string;
+ tpm_limit: number | null;
+ rpm_limit: number | null;
+ } | null;
+ };
+ keys: any[];
+ team_memberships: TeamMembership[];
+}
+
+export interface TeamInfoProps {
+ teamId: string;
+ onUpdate: (data: any) => void;
+ onClose: () => void;
+ accessToken: string | null;
+ is_team_admin: boolean;
+ is_proxy_admin: boolean;
+ userModels: string[];
+ editTeam: boolean;
+ premiumUser?: boolean;
+}
+
+const getOrganizationModels = (organization: Organization | null, userModels: string[]) => {
+ let tempModelsToPick = [];
+
+ if (organization) {
+ // Check if organization has "all-proxy-models" in its models array
+ if (organization.models.includes("all-proxy-models")) {
+ // Treat as all-proxy-models (use userModels)
+ tempModelsToPick = userModels;
+ } else if (organization.models.length > 0) {
+ // Organization has specific models
+ tempModelsToPick = organization.models;
+ } else {
+ // Empty array [] is treated as all-proxy-models
+ tempModelsToPick = userModels;
+ }
+ } else {
+ // No organization, show all available models
+ tempModelsToPick = userModels;
+ }
+
+ return unfurlWildcardModelsInList(tempModelsToPick, userModels);
+};
+
+const TeamInfoView: React.FC<TeamInfoProps> = ({
+ teamId,
+ onClose,
+ accessToken,
+ is_team_admin,
+ is_proxy_admin,
+ userModels,
+ editTeam,
+ premiumUser = false,
+ onUpdate,
+}) => {
+ const [teamData, setTeamData] = useState<TeamData | null>(null);
+ const [loading, setLoading] = useState(true);
+ const [isAddMemberModalVisible, setIsAddMemberModalVisible] = useState(false);
+ const [form] = Form.useForm();
+ const [isEditMemberModalVisible, setIsEditMemberModalVisible] = useState(false);
+ const [selectedEditMember, setSelectedEditMember] = useState<Member | null>(null);
+ const [isEditing, setIsEditing] = useState(false);
+ const [mcpAccessGroups, setMcpAccessGroups] = useState<string[]>([]);
+ const [mcpAccessGroupsLoaded, setMcpAccessGroupsLoaded] = useState(false);
+ const [copiedStates, setCopiedStates] = useState<Record<string, boolean>>({});
+ const [guardrailsList, setGuardrailsList] = useState<string[]>([]);
+ const [policiesList, setPoliciesList] = useState<string[]>([]);
+ const [policyGuardrails, setPolicyGuardrails] = useState<Record<string, string[]>>({});
+ const [loadingPolicies, setLoadingPolicies] = useState(false);
+ const [memberToDelete, setMemberToDelete] = useState<Member | null>(null);
+ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
+ const [isDeleting, setIsDeleting] = useState(false);
+ const [isTeamSaving, setIsTeamSaving] = useState(false);
+ const [organization, setOrganization] = useState<Organization | null>(null);
+ const { userRole } = useAuthorized();
+
+ const canEditTeam = is_team_admin || is_proxy_admin;
+ const visibleTabs = useMemo(() => getTeamInfoVisibleTabs(canEditTeam), [canEditTeam]);
+ const defaultTabKey = useMemo(
+ () => getTeamInfoDefaultTab(editTeam, canEditTeam),
+ [editTeam, canEditTeam]
+ );
+
+ const fetchTeamInfo = async () => {
+ try {
+ setLoading(true);
+ if (!accessToken) return;
+ const response = await teamInfoCall(accessToken, teamId);
+ setTeamData(response);
+ } catch (error) {
+ NotificationsManager.fromBackend("Failed to load team information");
+ console.error("Error fetching team info:", error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ fetchTeamInfo();
+ }, [teamId, accessToken]);
+
+ // Fetch organization data when team has organization_id
+ useEffect(() => {
+ const fetchOrganization = async () => {
+ if (!accessToken || !teamData?.team_info?.organization_id) {
+ setOrganization(null);
+ return;
+ }
+
+ try {
+ const orgData = await organizationInfoCall(accessToken, teamData.team_info.organization_id);
+ setOrganization(orgData);
+ } catch (error) {
+ console.error("Error fetching organization info:", error);
+ setOrganization(null);
+ }
+ };
+
+ fetchOrganization();
+ }, [accessToken, teamData?.team_info?.organization_id]);
+
+ // Compute modelsToPick based on organization and userModels
+ const modelsToPick = useMemo(() => {
+ return getOrganizationModels(organization, userModels);
+ }, [organization, userModels]);
+
+ const fetchMcpAccessGroups = async () => {
+ if (!accessToken) return;
+ if (mcpAccessGroupsLoaded) return;
+ try {
+ const groups = await fetchMCPAccessGroups(accessToken);
+ setMcpAccessGroups(groups);
+ setMcpAccessGroupsLoaded(true);
+ } catch (error) {
+ console.error("Failed to fetch MCP access groups:", error);
+ }
+ };
+
+ useEffect(() => {
+ const fetchGuardrails = async () => {
+ try {
+ if (!accessToken) return;
+ const response = await getGuardrailsList(accessToken);
+ const guardrailNames = response.guardrails.map((g: { guardrail_name: string }) => g.guardrail_name);
+ setGuardrailsList(guardrailNames);
+ } catch (error) {
+ console.error("Failed to fetch guardrails:", error);
+ }
+ };
+
+ const fetchPolicies = async () => {
+ try {
+ if (!accessToken) return;
+ const response = await getPoliciesList(accessToken);
+ const policyNames = response.policies.map((p: { policy_name: string }) => p.policy_name);
+ setPoliciesList(policyNames);
+ } catch (error) {
+ console.error("Failed to fetch policies:", error);
+ }
+ };
+
+ fetchGuardrails();
+ fetchPolicies();
+ }, [accessToken]);
+
+ // Fetch resolved guardrails for all policies
+ useEffect(() => {
+ const fetchPolicyGuardrails = async () => {
+ if (!accessToken || !teamData?.team_info?.policies || teamData.team_info.policies.length === 0) {
+ return;
+ }
+
+ setLoadingPolicies(true);
+ const guardrailsMap: Record<string, string[]> = {};
+
+ try {
+ await Promise.all(
+ teamData.team_info.policies.map(async (policyName: string) => {
+ try {
+ const policyInfo = await getPolicyInfoWithGuardrails(accessToken, policyName);
+ guardrailsMap[policyName] = policyInfo.resolved_guardrails || [];
+ } catch (error) {
+ console.error(`Failed to fetch guardrails for policy ${policyName}:`, error);
+ guardrailsMap[policyName] = [];
+ }
+ })
+ );
+ setPolicyGuardrails(guardrailsMap);
+ } catch (error) {
+ console.error("Failed to fetch policy guardrails:", error);
+ } finally {
+ setLoadingPolicies(false);
+ }
+ };
+
+ fetchPolicyGuardrails();
+ }, [accessToken, teamData?.team_info?.policies]);
+
+ const handleMemberCreate = async (values: any) => {
+ try {
+ if (accessToken == null) return;
+
+ const member: Member = {
+ user_email: values.user_email,
+ user_id: values.user_id,
+ role: values.role,
+ };
+
+ await teamMemberAddCall(accessToken, teamId, member);
+
+ NotificationsManager.success("Team member added successfully");
+ setIsAddMemberModalVisible(false);
+ form.resetFields();
+
+ // Fetch updated team info
+ const updatedTeamData = await teamInfoCall(accessToken, teamId);
+ setTeamData(updatedTeamData);
+
+ // Notify parent component of the update
+ onUpdate(updatedTeamData);
+ } catch (error: any) {
+ let errMsg = "Failed to add team member";
+
+ if (error?.raw?.detail?.error?.includes("Assigning team admins is a premium feature")) {
+ errMsg = "Assigning admins is an enterprise-only feature. Please upgrade your LiteLLM plan to enable this.";
+ } else if (error?.message) {
+ errMsg = error.message;
+ }
+
+ NotificationsManager.fromBackend(errMsg);
+ console.error("Error adding team member:", error);
+ }
+ };
+
+ const handleMemberUpdate = async (values: any) => {
+ try {
+ if (accessToken == null) {
+ return;
+ }
+
+ const member: Member = {
+ user_email: values.user_email,
+ user_id: values.user_id,
+ role: values.role,
+ max_budget_in_team: values.max_budget_in_team,
+ tpm_limit: values.tpm_limit,
+ rpm_limit: values.rpm_limit,
+ };
+ message.destroy(); // Remove all existing toasts
+
+ await teamMemberUpdateCall(accessToken, teamId, member);
+
+ NotificationsManager.success("Team member updated successfully");
+ setIsEditMemberModalVisible(false);
+
+ // Fetch updated team info
+ const updatedTeamData = await teamInfoCall(accessToken, teamId);
+ setTeamData(updatedTeamData);
+
+ // Notify parent component of the update
+ onUpdate(updatedTeamData);
+ } catch (error: any) {
+ let errMsg = "Failed to update team member";
+ if (error?.raw?.detail?.includes("Assigning team admins is a premium feature")) {
+ errMsg = "Assigning admins is an enterprise-only feature. Please upgrade your LiteLLM plan to enable this.";
+ } else if (error?.message) {
+ errMsg = error.message;
+ }
+ setIsEditMemberModalVisible(false);
+
+ message.destroy(); // Remove all existing toasts
+
+ NotificationsManager.fromBackend(errMsg);
+ console.error("Error updating team member:", error);
+ }
+ };
+
+ const handleMemberDelete = (member: Member) => {
+ setMemberToDelete(member);
+ setIsDeleteModalOpen(true);
+ };
+
+ const handleDeleteConfirm = async () => {
+ if (!memberToDelete || !accessToken) return;
+
+ setIsDeleting(true);
+ try {
+ await teamMemberDeleteCall(accessToken, teamId, memberToDelete);
+
+ NotificationsManager.success("Team member removed successfully");
+
+ // Fetch updated team info
+ const updatedTeamData = await teamInfoCall(accessToken, teamId);
+ setTeamData(updatedTeamData);
+
+ // Notify parent component of the update
+ onUpdate(updatedTeamData);
+ } catch (error) {
+ NotificationsManager.fromBackend("Failed to remove team member");
+ console.error("Error removing team member:", error);
+ } finally {
+ setIsDeleting(false);
+ setIsDeleteModalOpen(false);
+ setMemberToDelete(null);
+ }
+ };
+
+ const handleDeleteCancel = () => {
+ setIsDeleteModalOpen(false);
+ setMemberToDelete(null);
+ };
+
+ const handleTeamUpdate = async (values: any) => {
+ try {
+ if (!accessToken) return;
+ setIsTeamSaving(true);
+
+ let parsedMetadata = {};
+ try {
+ const rawMetadata = values.metadata ? JSON.parse(values.metadata) : {};
+ // Exclude soft_budget_alerting_emails from parsed metadata since it's handled separately
+ const { soft_budget_alerting_emails, ...rest } = rawMetadata;
+ parsedMetadata = rest;
+ } catch (e) {
+ NotificationsManager.fromBackend("Invalid JSON in metadata field");
+ return;
+ }
+
+ let secretManagerSettings: Record<string, any> | undefined;
+ if (typeof values.secret_manager_settings === "string") {
+ const trimmedSecretConfig = values.secret_manager_settings.trim();
+ if (trimmedSecretConfig.length > 0) {
+ try {
+ secretManagerSettings = JSON.parse(values.secret_manager_settings);
+ } catch (e) {
+ NotificationsManager.fromBackend("Invalid JSON in secret manager settings");
+ return;
+ }
+ }
+ }
+
+ const sanitizeNumeric = (v: any) => {
+ if (v === null || v === undefined) return null;
+ if (typeof v === "string" && v.trim() === "") return null;
+ if (typeof v === "number" && Number.isNaN(v)) return null;
+ return v;
+ };
+
+ const updateData: any = {
+ team_id: teamId,
+ team_alias: values.team_alias,
+ models: values.models,
+ tpm_limit: sanitizeNumeric(values.tpm_limit),
+ rpm_limit: sanitizeNumeric(values.rpm_limit),
+ max_budget: values.max_budget,
+ soft_budget: sanitizeNumeric(values.soft_budget),
+ budget_duration: values.budget_duration,
+ metadata: {
+ ...parsedMetadata,
+ ...(values.guardrails?.length > 0 ? { guardrails: values.guardrails } : {}),
+ ...(values.logging_settings?.length > 0 ? { logging: values.logging_settings } : {}),
+ disable_global_guardrails: values.disable_global_guardrails || false,
+ soft_budget_alerting_emails:
+ typeof values.soft_budget_alerting_emails === "string"
+ ? values.soft_budget_alerting_emails
+ .split(",")
+ .map((email: string) => email.trim())
+ .filter((email: string) => email.length > 0)
+ : values.soft_budget_alerting_emails || [],
+ ...(secretManagerSettings !== undefined ? { secret_manager_settings: secretManagerSettings } : {}),
+ },
+ ...(values.policies?.length > 0 ? { policies: values.policies } : {}),
+ organization_id: values.organization_id,
+ };
+
+ updateData.max_budget = mapEmptyStringToNull(updateData.max_budget);
+ updateData.team_member_budget_duration = values.team_member_budget_duration;
+
+ if (values.team_member_budget !== undefined) {
+ updateData.team_member_budget = Number(values.team_member_budget);
+ }
+
+ if (values.team_member_key_duration !== undefined) {
+ updateData.team_member_key_duration = values.team_member_key_duration;
+ }
+
+ if (values.team_member_tpm_limit !== undefined || values.team_member_rpm_limit !== undefined) {
+ updateData.team_member_tpm_limit = sanitizeNumeric(values.team_member_tpm_limit);
+ updateData.team_member_rpm_limit = sanitizeNumeric(values.team_member_rpm_limit);
+ }
+
+ // Handle object_permission updates
+ const { servers, accessGroups } = values.mcp_servers_and_groups || {
+ servers: [],
+ accessGroups: [],
+ };
+ const serverIds = new Set(servers || []);
+ const mcpToolPermissions = Object.fromEntries(
+ Object.entries(values.mcp_tool_permissions || {}).filter(([serverId]) => serverIds.has(serverId)),
+ );
+
+ updateData.object_permission = {};
+ if (servers) {
+ updateData.object_permission.mcp_servers = servers;
+ }
+ if (accessGroups) {
+ updateData.object_permission.mcp_access_groups = accessGroups;
+ }
+ if (mcpToolPermissions) {
+ updateData.object_permission.mcp_tool_permissions = mcpToolPermissions;
+ }
+ delete values.mcp_servers_and_groups;
+ delete values.mcp_tool_permissions;
+
+ // Handle agent permissions
+ const { agents, accessGroups: agentAccessGroups } = values.agents_and_groups || {
+ agents: [],
+ accessGroups: [],
+ };
+ if (agents && agents.length > 0) {
+ updateData.object_permission.agents = agents;
+ }
+ if (agentAccessGroups && agentAccessGroups.length > 0) {
+ updateData.object_permission.agent_access_groups = agentAccessGroups;
+ }
+ delete values.agents_and_groups;
+
+ // Handle vector stores permissions
+ if (values.vector_stores && values.vector_stores.length > 0) {
+ updateData.object_permission.vector_stores = values.vector_stores;
+ }
+
+ const response = await teamUpdateCall(accessToken, updateData);
+
+ NotificationsManager.success("Team settings updated successfully");
+ setIsEditing(false);
+ fetchTeamInfo();
+ } catch (error) {
+ console.error("Error updating team:", error);
+ } finally {
+ setIsTeamSaving(false);
+ }
+ };
+
+ if (loading) {
+ return <div className="p-4">Loading...</div>;
+ }
+
+ if (!teamData?.team_info) {
+ return <div className="p-4">Team not found</div>;
+ }
+
+ const { team_info: info } = teamData;
+
+ const copyToClipboard = async (text: string, key: string) => {
+ const success = await utilCopyToClipboard(text);
+ if (success) {
+ setCopiedStates((prev) => ({ ...prev, [key]: true }));
+ setTimeout(() => {
+ setCopiedStates((prev) => ({ ...prev, [key]: false }));
+ }, 2000);
+ }
+ };
+
+ return (
+ <div className="p-4">
+ <div className="flex justify-between items-center mb-6">
+ <div>
+ <Button
+ type="text"
+ icon={<ArrowLeftIcon className="h-4 w-4" />}
+ onClick={onClose}
+ className="mb-4"
+ >
+ Back to Teams
+ </Button>
+ <Title>{info.team_alias}</Title>
+ <div className="flex items-center">
+ <Text className="text-gray-500 font-mono">{info.team_id}</Text>
+ <Button
+ type="text"
+ size="small"
+ icon={copiedStates["team-id"] ? <CheckIcon size={12} /> : <CopyIcon size={12} />}
+ onClick={() => copyToClipboard(info.team_id, "team-id")}
+ className={`left-2 z-10 transition-all duration-200 ${copiedStates["team-id"]
+ ? "text-green-600 bg-green-50 border-green-200"
+ : "text-gray-500 hover:text-gray-700 hover:bg-gray-100"
+ }`}
+ />
+ </div>
+ </div>
+ </div>
+
+ <Tabs
+ defaultActiveKey={defaultTabKey}
+ className="mb-4"
+ items={[
+ {
+ key: TEAM_INFO_TAB_KEYS.OVERVIEW,
+ label: TEAM_INFO_TAB_LABELS[TEAM_INFO_TAB_KEYS.OVERVIEW],
+ children: (
+ <Grid numItems={1} numItemsSm={2} numItemsLg={3} className="gap-6">
+ <Card>
+ <Text>Budget Status</Text>
+ <div className="mt-2">
+ <Title>${formatNumberWithCommas(info.spend, 4)}</Title>
+ <Text>
+ of {info.max_budget === null ? "Unlimited" : `$${formatNumberWithCommas(info.max_budget, 4)}`}
+ </Text>
+ {info.budget_duration && <Text className="text-gray-500">Reset: {info.budget_duration}</Text>}
+ <br />
+ {info.team_member_budget_table && (
+ <Text className="text-gray-500">
+ Team Member Budget: ${formatNumberWithCommas(info.team_member_budget_table.max_budget, 4)}
+ </Text>
+ )}
+ </div>
+ </Card>
+
+ <Card>
+ <Text>Rate Limits</Text>
+ <div className="mt-2">
+ <Text>TPM: {info.tpm_limit || "Unlimited"}</Text>
+ <Text>RPM: {info.rpm_limit || "Unlimited"}</Text>
+ {info.max_parallel_requests && <Text>Max Parallel Requests: {info.max_parallel_requests}</Text>}
+ </div>
+ </Card>
+
+ <Card>
+ <Text>Models</Text>
+ <div className="mt-2 flex flex-wrap gap-2">
+ {info.models.length === 0 ? (
+ <Badge color="red">All proxy models</Badge>
+ ) : (
+ info.models.map((model, index) => (
+ <Badge key={index} color="red">
+ {model}
+ </Badge>
+ ))
+ )}
+ </div>
+ </Card>
+
+ <Card>
+ <Text className="font-semibold text-gray-900">Virtual Keys</Text>
+ <div className="mt-2">
+ <Text>User Keys: {teamData.keys.filter((key) => key.user_id).length}</Text>
+ <Text>Service Account Keys: {teamData.keys.filter((key) => !key.user_id).length}</Text>
+ <Text className="text-gray-500">Total: {teamData.keys.length}</Text>
+ </div>
+ </Card>
+
+ <ObjectPermissionsView
+ objectPermission={info.object_permission}
+ variant="card"
+ accessToken={accessToken}
+ />
+
+ <Card>
+ <Text className="font-semibold text-gray-900 mb-3">Guardrails</Text>
+ {info.guardrails && info.guardrails.length > 0 ? (
+ <div className="flex flex-wrap gap-2">
+ {info.guardrails.map((guardrail: string, index: number) => (
+ <Badge key={index} color="blue">
+ {guardrail}
+ </Badge>
+ ))}
+ </div>
+ ) : (
+ <Text className="text-gray-500">No guardrails configured</Text>
+ )}
+ {info.metadata?.disable_global_guardrails && (
+ <div className="mt-3 pt-3 border-t border-gray-200">
+ <Badge color="yellow">Global Guardrails Disabled</Badge>
+ </div>
+ )}
+ </Card>
+
+ <Card>
+ <Text className="font-semibold text-gray-900 mb-3">Policies</Text>
+ {info.policies && info.policies.length > 0 ? (
+ <div className="space-y-4">
+ {info.policies.map((policy: string, index: number) => (
+ <div key={index} className="space-y-2">
+ <div className="flex items-center gap-2">
+ <Badge color="purple">{policy}</Badge>
+ {loadingPolicies && <Text className="text-xs text-gray-400">Loading guardrails...</Text>}
+ </div>
+ {!loadingPolicies && policyGuardrails[policy] && policyGuardrails[policy].length > 0 && (
+ <div className="ml-4 pl-3 border-l-2 border-gray-200">
+ <Text className="text-xs text-gray-500 mb-1">Resolved Guardrails:</Text>
+ <div className="flex flex-wrap gap-1">
+ {policyGuardrails[policy].map((guardrail: string, gIndex: number) => (
+ <Badge key={gIndex} color="blue" size="xs">
+ {guardrail}
+ </Badge>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ ))}
+ </div>
+ ) : (
+ <Text className="text-gray-500">No policies configured</Text>
+ )}
+ </Card>
+
+ <LoggingSettingsView
+ loggingConfigs={info.metadata?.logging || []}
+ disabledCallbacks={[]}
+ variant="card"
+ />
+ </Grid>
+ ),
+ },
+ {
+ key: TEAM_INFO_TAB_KEYS.MEMBERS,
+ label: TEAM_INFO_TAB_LABELS[TEAM_INFO_TAB_KEYS.MEMBERS],
+ children: (
+ <TeamMembersComponent
+ teamData={teamData}
+ canEditTeam={canEditTeam}
+ handleMemberDelete={handleMemberDelete}
+ setSelectedEditMember={setSelectedEditMember}
+ setIsEditMemberModalVisible={setIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={setIsAddMemberModalVisible}
+ />
+ ),
+ },
+ {
+ key: TEAM_INFO_TAB_KEYS.MEMBER_PERMISSIONS,
+ label: TEAM_INFO_TAB_LABELS[TEAM_INFO_TAB_KEYS.MEMBER_PERMISSIONS],
+ children: (
+ <MemberPermissions teamId={teamId} accessToken={accessToken} canEditTeam={canEditTeam} />
+ ),
+ },
+ {
+ key: TEAM_INFO_TAB_KEYS.SETTINGS,
+ label: TEAM_INFO_TAB_LABELS[TEAM_INFO_TAB_KEYS.SETTINGS],
+ children: (
+ <Card className="overflow-y-auto max-h-[65vh]">
+ <div className="flex justify-between items-center mb-4">
+ <Title>Team Settings</Title>
+ {canEditTeam && !isEditing && (
+ <Button icon={<EditOutlined className="h-4 w-4" />} onClick={() => setIsEditing(true)}>Edit Settings</Button>
+ )}
+ </div>
+
+ {isEditing ? (
+ <Form
+ form={form}
+ onFinish={handleTeamUpdate}
+ initialValues={{
+ ...info,
+ team_alias: info.team_alias,
+ models: info.models,
+ tpm_limit: info.tpm_limit,
+ rpm_limit: info.rpm_limit,
+ max_budget: info.max_budget,
+ soft_budget: info.soft_budget,
+ budget_duration: info.budget_duration,
+ team_member_tpm_limit: info.team_member_budget_table?.tpm_limit,
+ team_member_rpm_limit: info.team_member_budget_table?.rpm_limit,
+ team_member_budget: info.team_member_budget_table?.max_budget,
+ team_member_budget_duration: info.team_member_budget_table?.budget_duration,
+ guardrails: info.metadata?.guardrails || [],
+ policies: info.policies || [],
+ disable_global_guardrails: info.metadata?.disable_global_guardrails || false,
+ soft_budget_alerting_emails:
+ Array.isArray(info.metadata?.soft_budget_alerting_emails)
+ ? info.metadata.soft_budget_alerting_emails.join(", ")
+ : "",
+ metadata: info.metadata
+ ? JSON.stringify(
+ (({ logging, secret_manager_settings, soft_budget_alerting_emails, ...rest }) => rest)(info.metadata),
+ null,
+ 2,
+ )
+ : "",
+ logging_settings: info.metadata?.logging || [],
+ secret_manager_settings: info.metadata?.secret_manager_settings
+ ? JSON.stringify(info.metadata.secret_manager_settings, null, 2)
+ : "",
+ organization_id: info.organization_id,
+ vector_stores: info.object_permission?.vector_stores || [],
+ mcp_servers: info.object_permission?.mcp_servers || [],
+ mcp_access_groups: info.object_permission?.mcp_access_groups || [],
+ mcp_servers_and_groups: {
+ servers: info.object_permission?.mcp_servers || [],
+ accessGroups: info.object_permission?.mcp_access_groups || [],
+ },
+ mcp_tool_permissions: info.object_permission?.mcp_tool_permissions || {},
+ agents_and_groups: {
+ agents: info.object_permission?.agents || [],
+ accessGroups: info.object_permission?.agent_access_groups || [],
+ },
+ }}
+ layout="vertical"
+ >
+ <Form.Item
+ label="Team Name"
+ name="team_alias"
+ rules={[{ required: true, message: "Please input a team name" }]}
+ >
+ <Input type="" />
+ </Form.Item>
+
+ <Form.Item
+ label="Models"
+ name="models"
+ rules={[{ required: true, message: "Please select at least one model" }]}
+ >
+ <ModelSelect
+ value={form.getFieldValue("models") || []}
+ onChange={(values) => form.setFieldValue("models", values)}
+ teamID={teamId}
+ organizationID={teamData?.team_info?.organization_id || undefined}
+ options={{
+ includeSpecialOptions: true,
+ includeUserModels: !teamData?.team_info?.organization_id,
+ showAllProxyModelsOverride: isProxyAdminRole(userRole) && !teamData?.team_info?.organization_id,
+ }}
+ context="team"
+ dataTestId="models-select"
+ />
+ </Form.Item>
+
+ <Form.Item label="Max Budget (USD)" name="max_budget">
+ <NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
+ </Form.Item>
+
+ <Form.Item label="Soft Budget (USD)" name="soft_budget">
+ <NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
+ </Form.Item>
+
+ <Form.Item
+ label="Soft Budget Alerting Emails"
+ name="soft_budget_alerting_emails"
+ tooltip="Comma-separated email addresses to receive alerts when the soft budget is reached"
+ >
+ <Input placeholder="[email protected], [email protected]" />
+ </Form.Item>
+
+ <Form.Item
+ label="Team Member Budget (USD)"
+ name="team_member_budget"
+ tooltip="This is the individual budget for a user in the team."
+ >
+ <NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
+ </Form.Item>
+
+ <Form.Item label="Team Member Budget Duration" name="team_member_budget_duration">
+ <DurationSelect
+ onChange={(value) => form.setFieldValue("team_member_budget_duration", value)}
+ value={form.getFieldValue("team_member_budget_duration")}
+ />
+ </Form.Item>
+
+ <Form.Item
+ label="Team Member Key Duration (eg: 1d, 1mo)"
+ name="team_member_key_duration"
+ tooltip="Set a limit to the duration of a team member's key. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days), 1mo (month)"
+ >
+ <TextInput placeholder="e.g., 30d" />
+ </Form.Item>
+
+ <Form.Item
+ label="Team Member TPM Limit"
+ name="team_member_tpm_limit"
+ tooltip="Default tokens per minute limit for an individual team member. This limit applies to all requests the user makes within this team. Can be overridden per member."
+ >
+ <NumericalInput step={1} style={{ width: "100%" }} placeholder="e.g., 1000" />
+ </Form.Item>
+
+ <Form.Item
+ label="Team Member RPM Limit"
+ name="team_member_rpm_limit"
+ tooltip="Default requests per minute limit for an individual team member. This limit applies to all requests the user makes within this team. Can be overridden per member."
+ >
+ <NumericalInput step={1} style={{ width: "100%" }} placeholder="e.g., 100" />
+ </Form.Item>
+
+ <Form.Item label="Reset Budget" name="budget_duration">
+ <Select placeholder="n/a">
+ <Select.Option value="24h">daily</Select.Option>
+ <Select.Option value="7d">weekly</Select.Option>
+ <Select.Option value="30d">monthly</Select.Option>
+ </Select>
+ </Form.Item>
+
+ <Form.Item label="Tokens per minute Limit (TPM)" name="tpm_limit">
+ <NumericalInput step={1} style={{ width: "100%" }} />
+ </Form.Item>
+
+ <Form.Item label="Requests per minute Limit (RPM)" name="rpm_limit">
+ <NumericalInput step={1} style={{ width: "100%" }} />
+ </Form.Item>
+
+ <Form.Item
+ label={
+ <span>
+ Guardrails{" "}
+ <Tooltip title="Setup your first guardrail">
+ <a
+ href="https://docs.litellm.ai/docs/proxy/guardrails/quick_start"
+ target="_blank"
+ rel="noopener noreferrer"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </a>
+ </Tooltip>
+ </span>
+ }
+ name="guardrails"
+ help="Select existing guardrails or enter new ones"
+ >
+ <Select
+ mode="tags"
+ placeholder="Select or enter guardrails"
+ options={guardrailsList.map((name) => ({ value: name, label: name }))}
+ />
+ </Form.Item>
+
+ <Form.Item
+ label={
+ <span>
+ Disable Global Guardrails
+ <Tooltip title="When enabled, this team will bypass any guardrails configured to run on every request (global guardrails)">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </span>
+ }
+ name="disable_global_guardrails"
+ valuePropName="checked"
+ help="Bypass global guardrails for this team"
+ >
+ <Switch checkedChildren="Yes" unCheckedChildren="No" />
+ </Form.Item>
+
+ <Form.Item
+ label={
+ <span>
+ Policies{" "}
+ <Tooltip title="Apply policies to this team to control guardrails and other settings">
+ <a
+ href="https://docs.litellm.ai/docs/proxy/guardrails/guardrail_policies"
+ target="_blank"
+ rel="noopener noreferrer"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </a>
+ </Tooltip>
+ </span>
+ }
+ name="policies"
+ help="Select existing policies or enter new ones"
+ >
+ <Select
+ mode="tags"
+ placeholder="Select or enter policies"
+ options={policiesList.map((name) => ({ value: name, label: name }))}
+ />
+ </Form.Item>
+
+ <Form.Item label="Vector Stores" name="vector_stores" aria-label="Vector Stores">
+ <VectorStoreSelector
+ onChange={(values: string[]) => form.setFieldValue("vector_stores", values)}
+ value={form.getFieldValue("vector_stores")}
+ accessToken={accessToken || ""}
+ placeholder="Select vector stores"
+ />
+ </Form.Item>
+
+ <Form.Item label="Allowed Pass Through Routes" name="allowed_passthrough_routes">
+ <PassThroughRoutesSelector
+ onChange={(values: string[]) => form.setFieldValue("allowed_passthrough_routes", values)}
+ value={form.getFieldValue("allowed_passthrough_routes")}
+ accessToken={accessToken || ""}
+ placeholder="Select pass through routes"
+ />
+ </Form.Item>
+
+ <Form.Item label="MCP Servers / Access Groups" name="mcp_servers_and_groups">
+ <MCPServerSelector
+ onChange={(val) => form.setFieldValue("mcp_servers_and_groups", val)}
+ value={form.getFieldValue("mcp_servers_and_groups")}
+ accessToken={accessToken || ""}
+ placeholder="Select MCP servers or access groups (optional)"
+ />
+ </Form.Item>
+
+ {/* Hidden field to register mcp_tool_permissions with the form */}
+ <Form.Item name="mcp_tool_permissions" initialValue={{}} hidden>
+ <Input type="hidden" />
+ </Form.Item>
+
+ <Form.Item
+ noStyle
+ shouldUpdate={(prevValues, currentValues) =>
+ prevValues.mcp_servers_and_groups !== currentValues.mcp_servers_and_groups ||
+ prevValues.mcp_tool_permissions !== currentValues.mcp_tool_permissions
+ }
+ >
+ {() => (
+ <div className="mb-6">
+ <MCPToolPermissions
+ accessToken={accessToken || ""}
+ selectedServers={form.getFieldValue("mcp_servers_and_groups")?.servers || []}
+ toolPermissions={form.getFieldValue("mcp_tool_permissions") || {}}
+ onChange={(toolPerms) => form.setFieldsValue({ mcp_tool_permissions: toolPerms })}
+ />
+ </div>
+ )}
+ </Form.Item>
+
+ <Form.Item label="Agents / Access Groups" name="agents_and_groups">
+ <AgentSelector
+ onChange={(val) => form.setFieldValue("agents_and_groups", val)}
+ value={form.getFieldValue("agents_and_groups")}
+ accessToken={accessToken || ""}
+ placeholder="Select agents or access groups (optional)"
+ />
+ </Form.Item>
+
+ <Form.Item label="Organization ID" name="organization_id">
+ <Input type="" disabled />
+ </Form.Item>
+
+ <Form.Item label="Logging Settings" name="logging_settings">
+ <EditLoggingSettings
+ value={form.getFieldValue("logging_settings")}
+ onChange={(values) => form.setFieldValue("logging_settings", values)}
+ />
+ </Form.Item>
+
+ <Form.Item
+ label="Secret Manager Settings"
+ name="secret_manager_settings"
+ help={
+ premiumUser
+ ? "Enter secret manager configuration as a JSON object."
+ : "Premium feature - Upgrade to manage secret manager settings."
+ }
+ rules={[
+ {
+ validator: async (_, value) => {
+ if (!value) {
+ return Promise.resolve();
+ }
+ try {
+ JSON.parse(value);
+ return Promise.resolve();
+ } catch (error) {
+ return Promise.reject(new Error("Please enter valid JSON"));
+ }
+ },
+ },
+ ]}
+ >
+ <Input.TextArea
+ rows={6}
+ placeholder='{"namespace": "admin", "mount": "secret", "path_prefix": "litellm"}'
+ disabled={!premiumUser}
+ />
+ </Form.Item>
+
+ <Form.Item label="Metadata" name="metadata">
+ <Input.TextArea rows={10} />
+ </Form.Item>
+
+ <div className="sticky z-10 bg-white p-4 pr-0 border-t border-gray-200 bottom-[-1.5rem] inset-x-[-1.5rem]">
+ <div className="flex justify-end items-center gap-2">
+ <Button onClick={() => setIsEditing(false)} disabled={isTeamSaving}>
+ Cancel
+ </Button>
+ <Button icon={<SaveOutlined className="h-4 w-4" />} type="primary" htmlType="submit" loading={isTeamSaving}>
+ Save Changes
+ </Button>
+ </div>
+ </div>
+ </Form>
+ ) : (
+ <div className="space-y-4">
+ <div>
+ <Text className="font-medium">Team Name</Text>
+ <div>{info.team_alias}</div>
+ </div>
+ <div>
+ <Text className="font-medium">Team ID</Text>
+ <div className="font-mono">{info.team_id}</div>
+ </div>
+ <div>
+ <Text className="font-medium">Created At</Text>
+ <div>{new Date(info.created_at).toLocaleString()}</div>
+ </div>
+ <div>
+ <Text className="font-medium">Models</Text>
+ <div className="flex flex-wrap gap-2 mt-1">
+ {info.models.map((model, index) => (
+ <Badge key={index} color="red">
+ {model}
+ </Badge>
+ ))}
+ </div>
+ </div>
+ <div>
+ <Text className="font-medium">Rate Limits</Text>
+ <div>TPM: {info.tpm_limit || "Unlimited"}</div>
+ <div>RPM: {info.rpm_limit || "Unlimited"}</div>
+ </div>
+ <div>
+ <Text className="font-medium">Team Budget</Text>
+ <div>
+ Max Budget:{" "}
+ {info.max_budget !== null ? `$${formatNumberWithCommas(info.max_budget, 4)}` : "No Limit"}
+ </div>
+ <div>
+ Soft Budget:{" "}
+ {info.soft_budget !== null && info.soft_budget !== undefined
+ ? `$${formatNumberWithCommas(info.soft_budget, 4)}`
+ : "No Limit"}
+ </div>
+ <div>Budget Reset: {info.budget_duration || "Never"}</div>
+ {info.metadata?.soft_budget_alerting_emails &&
+ Array.isArray(info.metadata.soft_budget_alerting_emails) &&
+ info.metadata.soft_budget_alerting_emails.length > 0 && (
+ <div>
+ Soft Budget Alerting Emails: {info.metadata.soft_budget_alerting_emails.join(", ")}
+ </div>
+ )}
+ </div>
+ <div>
+ <Text className="font-medium">
+ Team Member Settings{" "}
+ <Tooltip title="These are limits on individual team members">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </Text>
+ <div>Max Budget: {info.team_member_budget_table?.max_budget || "No Limit"}</div>
+ <div>Budget Duration: {info.team_member_budget_table?.budget_duration || "No Limit"}</div>
+ <div>Key Duration: {info.metadata?.team_member_key_duration || "No Limit"}</div>
+ <div>TPM Limit: {info.team_member_budget_table?.tpm_limit || "No Limit"}</div>
+ <div>RPM Limit: {info.team_member_budget_table?.rpm_limit || "No Limit"}</div>
+ </div>
+ <div>
+ <Text className="font-medium">Organization ID</Text>
+ <div>{info.organization_id}</div>
+ </div>
+ <div>
+ <Text className="font-medium">Status</Text>
+ <Badge color={info.blocked ? "red" : "green"}>{info.blocked ? "Blocked" : "Active"}</Badge>
+ </div>
+
+ <div>
+ <Text className="font-medium">Disable Global Guardrails</Text>
+ <div>
+ {info.metadata?.disable_global_guardrails === true ? (
+ <Badge color="yellow">Enabled - Global guardrails bypassed</Badge>
+ ) : (
+ <Badge color="green">Disabled - Global guardrails active</Badge>
+ )}
+ </div>
+ </div>
+
+ <ObjectPermissionsView
+ objectPermission={info.object_permission}
+ variant="inline"
+ className="pt-4 border-t border-gray-200"
+ accessToken={accessToken}
+ />
+
+ <LoggingSettingsView
+ loggingConfigs={info.metadata?.logging || []}
+ disabledCallbacks={[]}
+ variant="inline"
+ className="pt-4 border-t border-gray-200"
+ />
+
+ {info.metadata?.secret_manager_settings && (
+ <div className="pt-4 border-t border-gray-200">
+ <Text className="font-medium">Secret Manager Settings</Text>
+ <pre className="mt-2 bg-gray-50 p-3 rounded text-xs overflow-x-auto">
+ {JSON.stringify(info.metadata.secret_manager_settings, null, 2)}
+ </pre>
+ </div>
+ )}
+ </div>
+ )}
+ </Card>
+ ),
+ },
+ ].filter(tab => visibleTabs.includes(tab.key))}
+ />
+
+ <MemberModal
+ visible={isEditMemberModalVisible}
+ onCancel={() => setIsEditMemberModalVisible(false)}
+ onSubmit={handleMemberUpdate}
+ initialData={selectedEditMember}
+ mode="edit"
+ config={{
+ title: "Edit Member",
+ showEmail: true,
+ showUserId: true,
+ roleOptions: [
+ { label: "Admin", value: "admin" },
+ { label: "User", value: "user" },
+ ],
+ additionalFields: [
+ {
+ name: "max_budget_in_team",
+ label: (
+ <span>
+ Team Member Budget (USD){" "}
+ <Tooltip title="Maximum amount in USD this member can spend within this team. This is separate from any global user budget limits">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </span>
+ ),
+ type: "numerical" as const,
+ step: 0.01,
+ min: 0,
+ placeholder: "Budget limit for this member within this team",
+ },
+ {
+ name: "tpm_limit",
+ label: (
+ <span>
+ Team Member TPM Limit{" "}
+ <Tooltip title="Maximum tokens per minute this member can use within this team. This is separate from any global user TPM limit">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </span>
+ ),
+ type: "numerical" as const,
+ step: 1,
+ min: 0,
+ placeholder: "Tokens per minute limit for this member in this team",
+ },
+ {
+ name: "rpm_limit",
+ label: (
+ <span>
+ Team Member RPM Limit{" "}
+ <Tooltip title="Maximum requests per minute this member can make within this team. This is separate from any global user RPM limit">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </span>
+ ),
+ type: "numerical" as const,
+ step: 1,
+ min: 0,
+ placeholder: "Requests per minute limit for this member in this team",
+ },
+ ],
+ }}
+ />
+
+ <UserSearchModal
+ isVisible={isAddMemberModalVisible}
+ onCancel={() => setIsAddMemberModalVisible(false)}
+ onSubmit={handleMemberCreate}
+ accessToken={accessToken}
+ />
+
+ {/* Delete Member Confirmation Modal */}
+ <DeleteResourceModal
+ isOpen={isDeleteModalOpen}
+ title="Delete Team Member"
+ alertMessage="Removing team members will also delete any keys created by or created for this member."
+ message="Are you sure you want to remove this member from the team? This action cannot be undone."
+ resourceInformationTitle="Team Member Information"
+ resourceInformation={[
+ { label: "User ID", value: memberToDelete?.user_id, code: true },
+ { label: "Email", value: memberToDelete?.user_email },
+ { label: "Role", value: memberToDelete?.role },
+ ]}
+ onCancel={handleDeleteCancel}
+ onOk={handleDeleteConfirm}
+ confirmLoading={isDeleting}
+ />
+ </div>
+ );
+};
+
+export default TeamInfoView;
diff --git a/ui/litellm-dashboard/src/components/team/TeamMemberTab.test.tsx b/ui/litellm-dashboard/src/components/team/TeamMemberTab.test.tsx
new file mode 100644
index 00000000000..d494b874e4d
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/team/TeamMemberTab.test.tsx
@@ -0,0 +1,386 @@
+import { screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { renderWithProviders } from "../../../tests/test-utils";
+import { TeamData } from "./TeamInfo";
+import TeamMembersComponent from "./TeamMemberTab";
+
+vi.mock("@/app/(dashboard)/hooks/uiSettings/useUISettings", () => ({
+ useUISettings: vi.fn(),
+}));
+
+vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
+ default: vi.fn(),
+}));
+
+vi.mock("@/utils/roles", () => ({
+ isUserTeamAdminForSingleTeam: vi.fn(() => false),
+ isProxyAdminRole: vi.fn(() => false),
+}));
+
+import { useUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUISettings";
+import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
+import { isProxyAdminRole, isUserTeamAdminForSingleTeam } from "@/utils/roles";
+
+const mockHandleMemberDelete = vi.fn();
+const mockSetSelectedEditMember = vi.fn();
+const mockSetIsEditMemberModalVisible = vi.fn();
+const mockSetIsAddMemberModalVisible = vi.fn();
+
+const createMockTeamData = (overrides: Partial<TeamData> = {}): TeamData => ({
+ team_id: "team-123",
+ team_info: {
+ team_alias: "Test Team",
+ team_id: "team-123",
+ organization_id: null,
+ admins: ["[email protected]"],
+ members: ["[email protected]"],
+ members_with_roles: [
+ {
+ user_id: "[email protected]",
+ user_email: "[email protected]",
+ role: "member",
+ },
+ {
+ user_id: "[email protected]",
+ user_email: "[email protected]",
+ role: "admin",
+ },
+ ],
+ metadata: {},
+ tpm_limit: null,
+ rpm_limit: null,
+ max_budget: null,
+ budget_duration: null,
+ models: [],
+ blocked: false,
+ spend: 0,
+ max_parallel_requests: null,
+ budget_reset_at: null,
+ model_id: null,
+ litellm_model_table: null,
+ created_at: "2024-01-01T00:00:00Z",
+ team_member_budget_table: null,
+ },
+ keys: [],
+ team_memberships: [
+ {
+ user_id: "[email protected]",
+ team_id: "team-123",
+ budget_id: "budget1",
+ spend: 100.5,
+ litellm_budget_table: {
+ budget_id: "budget1",
+ soft_budget: null,
+ max_budget: 1000,
+ max_parallel_requests: null,
+ tpm_limit: 10000,
+ rpm_limit: 100,
+ model_max_budget: null,
+ budget_duration: null,
+ },
+ },
+ ],
+ ...overrides,
+});
+
+describe("TeamMembersComponent", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ vi.mocked(useUISettings).mockReturnValue({
+ data: { values: { disable_team_admin_delete_team_user: false } },
+ isLoading: false,
+ isError: false,
+ error: null,
+ isSuccess: true,
+ isFetching: false,
+ refetch: vi.fn(),
+ } as any);
+
+ vi.mocked(useAuthorized).mockReturnValue({
+ isLoading: false,
+ isAuthorized: true,
+ userId: "test-user-id",
+ userRole: "Admin",
+ accessToken: "test-token",
+ token: "test-token",
+ userEmail: "[email protected]",
+ premiumUser: false,
+ disabledPersonalKeyCreation: null,
+ showSSOBanner: false,
+ });
+ });
+
+ it("should render", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getByRole("table")).toBeInTheDocument();
+ });
+
+ it("should render team members table with headers", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getByRole("columnheader", { name: /user email/i })).toBeInTheDocument();
+ expect(screen.getByRole("columnheader", { name: /user id/i })).toBeInTheDocument();
+ expect(screen.getByRole("columnheader", { name: /team role/i })).toBeInTheDocument();
+ expect(screen.getByRole("columnheader", { name: /actions/i })).toBeInTheDocument();
+ });
+
+ it("should render team members data", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ // [email protected] appears twice (User ID and User Email columns)
+ expect(screen.getAllByText("[email protected]").length).toBeGreaterThanOrEqual(1);
+ expect(screen.getAllByText("[email protected]").length).toBeGreaterThanOrEqual(1);
+ const table = screen.getByRole("table");
+ expect(table).toHaveTextContent("member");
+ expect(table).toHaveTextContent("admin");
+ });
+
+ it("should render Add Member button", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getByText("Add Member")).toBeInTheDocument();
+ });
+
+ it("should display dash when user email is null", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData({
+ team_info: {
+ ...createMockTeamData().team_info,
+ members_with_roles: [
+ {
+ user_id: "user-without-email",
+ user_email: null,
+ role: "user",
+ },
+ ],
+ },
+ })}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getByText("-")).toBeInTheDocument();
+ });
+
+ it("should display Default Proxy Admin tag for default_user_id", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData({
+ team_info: {
+ ...createMockTeamData().team_info,
+ members_with_roles: [
+ {
+ user_id: "default_user_id",
+ user_email: "[email protected]",
+ role: "admin",
+ },
+ ],
+ },
+ })}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getByText("Default Proxy Admin")).toBeInTheDocument();
+ });
+
+ it("should display spend and rate limits for member with membership", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getByText(/\$100\.5/)).toBeInTheDocument();
+ expect(screen.getByText(/100 RPM/)).toBeInTheDocument();
+ expect(screen.getByText(/10000 TPM/)).toBeInTheDocument();
+ });
+
+ it("should display No Limit for budget when member has no budget", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getByText("No Limit")).toBeInTheDocument();
+ });
+
+ it("should display No Limits for rate limits when member has no limits", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getByText("No Limits")).toBeInTheDocument();
+ });
+
+ it("should call setIsEditMemberModalVisible and setSelectedEditMember when edit button is clicked", async () => {
+ const user = userEvent.setup();
+ vi.mocked(isProxyAdminRole).mockReturnValue(true);
+ vi.mocked(isUserTeamAdminForSingleTeam).mockReturnValue(false);
+
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={true}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ const editButtons = screen.getAllByTestId("edit-member");
+ await user.click(editButtons[0]);
+
+ expect(mockSetIsEditMemberModalVisible).toHaveBeenCalledWith(true);
+ expect(mockSetSelectedEditMember).toHaveBeenCalled();
+ });
+
+ it("should call setIsAddMemberModalVisible when Add Member button is clicked", async () => {
+ const user = userEvent.setup();
+
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={true}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ const addButton = screen.getByRole("button", { name: /add member/i });
+ await user.click(addButton);
+
+ expect(mockSetIsAddMemberModalVisible).toHaveBeenCalledWith(true);
+ });
+
+ it("should hide delete button when disable_team_admin_delete_team_user is true and user is team admin", () => {
+ vi.mocked(isProxyAdminRole).mockReturnValue(false);
+ vi.mocked(isUserTeamAdminForSingleTeam).mockReturnValue(true);
+ vi.mocked(useUISettings).mockReturnValue({
+ data: { values: { disable_team_admin_delete_team_user: true } },
+ isLoading: false,
+ isError: false,
+ error: null,
+ isSuccess: true,
+ isFetching: false,
+ refetch: vi.fn(),
+ } as any);
+
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={true}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.queryByTestId("delete-member")).not.toBeInTheDocument();
+ expect(screen.getAllByTestId("edit-member")).toHaveLength(2);
+ });
+
+ it("should show delete button for proxy admin when canEditTeam is true", () => {
+ vi.mocked(isProxyAdminRole).mockReturnValue(true);
+ vi.mocked(isUserTeamAdminForSingleTeam).mockReturnValue(false);
+
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={true}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.getAllByTestId("delete-member")).toHaveLength(2);
+ expect(screen.getAllByTestId("edit-member")).toHaveLength(2);
+ });
+
+ it("should hide action buttons when canEditTeam is false", () => {
+ renderWithProviders(
+ <TeamMembersComponent
+ teamData={createMockTeamData()}
+ canEditTeam={false}
+ handleMemberDelete={mockHandleMemberDelete}
+ setSelectedEditMember={mockSetSelectedEditMember}
+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
+ />,
+ );
+
+ expect(screen.queryByTestId("edit-member")).not.toBeInTheDocument();
+ expect(screen.queryByTestId("delete-member")).not.toBeInTheDocument();
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx
new file mode 100644
index 00000000000..09a6b0f468d
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx
@@ -0,0 +1,233 @@
+import { useUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUISettings";
+import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
+import { Member } from "@/components/networking";
+import { formatNumberWithCommas } from "@/utils/dataUtils";
+import { isProxyAdminRole, isUserTeamAdminForSingleTeam } from "@/utils/roles";
+import { CrownOutlined, InfoCircleOutlined, UserAddOutlined, UserOutlined } from "@ant-design/icons";
+import { Button, Space, Table, Tag, Tooltip, Typography } from "antd";
+import type { ColumnsType } from "antd/es/table";
+import TableIconActionButton from "../common_components/IconActionButton/TableIconActionButtons/TableIconActionButton";
+import { TeamData } from "./TeamInfo";
+
+const { Text } = Typography;
+
+interface TeamMemberTabProps {
+ teamData: TeamData;
+ canEditTeam: boolean;
+ handleMemberDelete: (member: Member) => void;
+ setSelectedEditMember: (member: Member) => void;
+ setIsEditMemberModalVisible: (visible: boolean) => void;
+ setIsAddMemberModalVisible: (visible: boolean) => void;
+}
+
+export default function TeamMemberTab({
+ teamData,
+ canEditTeam,
+ handleMemberDelete,
+ setSelectedEditMember,
+ setIsEditMemberModalVisible,
+ setIsAddMemberModalVisible,
+}: TeamMemberTabProps) {
+ const formatNumber = (value: number | null): string => {
+ if (value === null || value === undefined) return "0";
+
+ if (typeof value === "number") {
+ // Convert scientific notation to normal decimal
+ const normalNumber = Number(value);
+
+ // If it's a whole number, return it without decimals
+ if (normalNumber === Math.floor(normalNumber)) {
+ return normalNumber.toString();
+ }
+
+ // For decimal numbers, use toFixed and remove trailing zeros
+ return formatNumberWithCommas(normalNumber, 8).replace(/\.?0+$/, "");
+ }
+
+ return "0";
+ };
+
+ // Helper function to get spend for a user
+ const getUserSpend = (userId: string | null): number | null => {
+ if (!userId) return 0;
+ const membership = teamData.team_memberships.find((tm) => tm.user_id === userId);
+ return membership?.spend || 0;
+ };
+
+ const getUserBudget = (userId: string | null): string | null => {
+ if (!userId) return null;
+ const membership = teamData.team_memberships.find((tm) => tm.user_id === userId);
+ const maxBudget = membership?.litellm_budget_table?.max_budget;
+ if (maxBudget === null || maxBudget === undefined) {
+ return null;
+ }
+ return formatNumber(maxBudget);
+ };
+
+ // Helper function to get rate limits for a user
+ const getUserRateLimits = (userId: string | null): string => {
+ if (!userId) return "No Limits";
+ const membership = teamData.team_memberships.find((tm) => tm.user_id === userId);
+ const rpmLimit = membership?.litellm_budget_table?.rpm_limit;
+ const tpmLimit = membership?.litellm_budget_table?.tpm_limit;
+
+ const rpmText = rpmLimit ? `${formatNumber(rpmLimit)} RPM` : null;
+ const tpmText = tpmLimit ? `${formatNumber(tpmLimit)} TPM` : null;
+
+ const limits = [rpmText, tpmText].filter(Boolean);
+ return limits.length > 0 ? limits.join(" / ") : "No Limits";
+ };
+
+ const { data: uiSettingsData } = useUISettings();
+ const { userId, userRole } = useAuthorized();
+ const disableTeamAdminDeleteTeamUser = Boolean(uiSettingsData?.values?.disable_team_admin_delete_team_user);
+ const isUserTeamAdmin = isUserTeamAdminForSingleTeam(teamData.team_info.members_with_roles, userId || "");
+ const isProxyAdmin = isProxyAdminRole(userRole || "");
+
+ const columns: ColumnsType<Member> = [
+ {
+ title: "User Email",
+ dataIndex: "user_email",
+ key: "user_email",
+ render: (email: string | null) => (
+ <Text>{email || "-"}</Text>
+ ),
+ },
+ {
+ title: "User ID",
+ dataIndex: "user_id",
+ key: "user_id",
+ render: (userId: string | null) =>
+ userId === "default_user_id" ? (
+ <Tag color="blue">Default Proxy Admin</Tag>
+ ) : (
+ <Text>{userId}</Text>
+ ),
+ },
+ {
+ title: (
+ <Space direction="horizontal">
+ Team Role
+ <Tooltip title="This role applies only to this team and is independent from the user's proxy-level role.">
+ <InfoCircleOutlined />
+ </Tooltip>
+ </Space>
+ ),
+ dataIndex: "role",
+ key: "role",
+ render: (role: string) => (
+ <Space>
+ {role?.toLowerCase() === "admin" ? (
+ <CrownOutlined />
+ ) : (
+ <UserOutlined />
+ )}
+ <Text style={{ textTransform: "capitalize" }}>{role}</Text>
+ </Space>
+ ),
+ },
+ {
+ title: (
+ <Space direction="horizontal">
+ Team Member Spend (USD)
+ <Tooltip title="This is the amount spent by a user in the team.">
+ <InfoCircleOutlined />
+ </Tooltip>
+ </Space>
+ ),
+ key: "spend",
+ render: (_: unknown, record: Member) => (
+ <Text>
+ ${formatNumberWithCommas(getUserSpend(record.user_id), 4)}
+ </Text>
+ ),
+ },
+ {
+ title: "Team Member Budget (USD)",
+ key: "budget",
+ render: (_: unknown, record: Member) => {
+ const budget = getUserBudget(record.user_id);
+ return (
+ <Text >
+ {budget ? `$${formatNumberWithCommas(Number(budget), 4)}` : "No Limit"}
+ </Text>
+ );
+ },
+ },
+ {
+ title: (
+ <Space direction="horizontal">
+ Team Member Rate Limits
+ <Tooltip title="Rate limits for this member's usage within this team.">
+ <InfoCircleOutlined />
+ </Tooltip>
+ </Space>
+ ),
+ key: "rate_limits",
+ render: (_: unknown, record: Member) => (
+ <Text>{getUserRateLimits(record.user_id)}</Text>
+ ),
+ },
+ {
+ title: "Actions",
+ key: "actions",
+ fixed: "right",
+ width: 120,
+ render: (_: unknown, record: Member) =>
+ canEditTeam ? (
+ <div className="flex gap-2">
+ <TableIconActionButton
+ variant="Edit"
+ tooltipText="Edit member"
+ dataTestId="edit-member"
+ onClick={() => {
+ const membership = teamData.team_memberships.find(
+ (tm) => tm.user_id === record.user_id
+ );
+ const enhancedMember = {
+ ...record,
+ max_budget_in_team:
+ membership?.litellm_budget_table?.max_budget || null,
+ tpm_limit:
+ membership?.litellm_budget_table?.tpm_limit || null,
+ rpm_limit:
+ membership?.litellm_budget_table?.rpm_limit || null,
+ };
+ setSelectedEditMember(enhancedMember);
+ setIsEditMemberModalVisible(true);
+ }}
+ />
+ {(isProxyAdmin ||
+ (isUserTeamAdmin && !disableTeamAdminDeleteTeamUser)) && (
+ <TableIconActionButton
+ variant="Delete"
+ tooltipText="Delete member"
+ dataTestId="delete-member"
+ onClick={() => handleMemberDelete(record)}
+ />
+ )}
+ </div>
+ ) : null,
+ },
+ ];
+
+ return (
+ <div className="space-y-4">
+ <Table
+ columns={columns}
+ dataSource={teamData.team_info.members_with_roles}
+ rowKey={(record, index) => record.user_id || String(index)}
+ pagination={false}
+ size="small"
+ scroll={{ x: "max-content" }}
+ />
+ <Button
+ icon={<UserAddOutlined />}
+ type="primary"
+ onClick={() => setIsAddMemberModalVisible(true)}
+ >
+ Add Member
+ </Button>
+ </div>
+ );
+};
diff --git a/ui/litellm-dashboard/src/components/team/tabVisibilityUtils.test.ts b/ui/litellm-dashboard/src/components/team/tabVisibilityUtils.test.ts
new file mode 100644
index 00000000000..5a09b4fa36c
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/team/tabVisibilityUtils.test.ts
@@ -0,0 +1,74 @@
+import { describe, expect, it } from "vitest";
+import {
+ getTeamInfoDefaultTab,
+ getTeamInfoVisibleTabs,
+ isTeamInfoTabVisible,
+ TEAM_INFO_TAB_KEYS,
+ TEAM_INFO_TAB_LABELS,
+} from "./tabVisibilityUtils";
+
+describe("team_info_tabs", () => {
+ describe("TEAM_INFO_TAB_LABELS", () => {
+ it("should have label for every tab key", () => {
+ expect(TEAM_INFO_TAB_LABELS[TEAM_INFO_TAB_KEYS.OVERVIEW]).toBe("Overview");
+ expect(TEAM_INFO_TAB_LABELS[TEAM_INFO_TAB_KEYS.MEMBERS]).toBe("Members");
+ expect(TEAM_INFO_TAB_LABELS[TEAM_INFO_TAB_KEYS.MEMBER_PERMISSIONS]).toBe("Member Permissions");
+ expect(TEAM_INFO_TAB_LABELS[TEAM_INFO_TAB_KEYS.SETTINGS]).toBe("Settings");
+ });
+ });
+
+ describe("getTeamInfoVisibleTabs", () => {
+ it("returns only overview when user cannot edit team", () => {
+ const tabs = getTeamInfoVisibleTabs(false);
+ expect(tabs).toEqual([TEAM_INFO_TAB_KEYS.OVERVIEW]);
+ });
+
+ it("returns all tabs when user can edit team", () => {
+ const tabs = getTeamInfoVisibleTabs(true);
+ expect(tabs).toEqual([
+ TEAM_INFO_TAB_KEYS.OVERVIEW,
+ TEAM_INFO_TAB_KEYS.MEMBERS,
+ TEAM_INFO_TAB_KEYS.MEMBER_PERMISSIONS,
+ TEAM_INFO_TAB_KEYS.SETTINGS,
+ ]);
+ });
+ });
+
+ describe("getTeamInfoDefaultTab", () => {
+ it("returns overview when editTeam is false", () => {
+ expect(getTeamInfoDefaultTab(false, true)).toBe(TEAM_INFO_TAB_KEYS.OVERVIEW);
+ expect(getTeamInfoDefaultTab(false, false)).toBe(TEAM_INFO_TAB_KEYS.OVERVIEW);
+ });
+
+ it("returns settings when editTeam is true and user can edit", () => {
+ expect(getTeamInfoDefaultTab(true, true)).toBe(TEAM_INFO_TAB_KEYS.SETTINGS);
+ });
+
+ it("returns overview when editTeam is true but user cannot edit", () => {
+ expect(getTeamInfoDefaultTab(true, false)).toBe(TEAM_INFO_TAB_KEYS.OVERVIEW);
+ });
+ });
+
+ describe("isTeamInfoTabVisible", () => {
+ it("always returns true for overview tab", () => {
+ expect(isTeamInfoTabVisible(TEAM_INFO_TAB_KEYS.OVERVIEW, false)).toBe(true);
+ expect(isTeamInfoTabVisible(TEAM_INFO_TAB_KEYS.OVERVIEW, true)).toBe(true);
+ });
+
+ it("returns false for members tab when user cannot edit", () => {
+ expect(isTeamInfoTabVisible(TEAM_INFO_TAB_KEYS.MEMBERS, false)).toBe(false);
+ });
+
+ it("returns true for members tab when user can edit", () => {
+ expect(isTeamInfoTabVisible(TEAM_INFO_TAB_KEYS.MEMBERS, true)).toBe(true);
+ });
+
+ it("returns false for settings tab when user cannot edit", () => {
+ expect(isTeamInfoTabVisible(TEAM_INFO_TAB_KEYS.SETTINGS, false)).toBe(false);
+ });
+
+ it("returns true for settings tab when user can edit", () => {
+ expect(isTeamInfoTabVisible(TEAM_INFO_TAB_KEYS.SETTINGS, true)).toBe(true);
+ });
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/team/tabVisibilityUtils.ts b/ui/litellm-dashboard/src/components/team/tabVisibilityUtils.ts
new file mode 100644
index 00000000000..d77230ea09b
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/team/tabVisibilityUtils.ts
@@ -0,0 +1,59 @@
+/**
+ * Team info tab configuration and permission logic.
+ * Extracted for testability - permission rules can be unit tested in isolation.
+ */
+
+export const TEAM_INFO_TAB_KEYS = {
+ OVERVIEW: "overview",
+ MEMBERS: "members",
+ MEMBER_PERMISSIONS: "member-permissions",
+ SETTINGS: "settings",
+} as const;
+
+export const TEAM_INFO_TAB_LABELS: Record<string, string> = {
+ [TEAM_INFO_TAB_KEYS.OVERVIEW]: "Overview",
+ [TEAM_INFO_TAB_KEYS.MEMBERS]: "Members",
+ [TEAM_INFO_TAB_KEYS.MEMBER_PERMISSIONS]: "Member Permissions",
+ [TEAM_INFO_TAB_KEYS.SETTINGS]: "Settings",
+};
+
+/**
+ * Returns the list of tab keys that should be visible based on permissions.
+ * - Overview: always visible
+ * - Members, Member Permissions, Settings: only when canEditTeam is true
+ */
+export function getTeamInfoVisibleTabs(canEditTeam: boolean): readonly string[] {
+ const baseTabs = [TEAM_INFO_TAB_KEYS.OVERVIEW];
+ if (canEditTeam) {
+ return [
+ ...baseTabs,
+ TEAM_INFO_TAB_KEYS.MEMBERS,
+ TEAM_INFO_TAB_KEYS.MEMBER_PERMISSIONS,
+ TEAM_INFO_TAB_KEYS.SETTINGS,
+ ];
+ }
+ return baseTabs;
+}
+
+/**
+ * Returns the default active tab key based on permissions and edit intent.
+ * - When editTeam is true and user can edit: open Settings tab
+ * - Otherwise: open Overview tab
+ */
+export function getTeamInfoDefaultTab(editTeam: boolean, canEditTeam: boolean): string {
+ if (editTeam && canEditTeam) {
+ return TEAM_INFO_TAB_KEYS.SETTINGS;
+ }
+ return TEAM_INFO_TAB_KEYS.OVERVIEW;
+}
+
+/**
+ * Checks if a specific tab should be visible based on permissions.
+ */
+export function isTeamInfoTabVisible(
+ tabKey: string,
+ canEditTeam: boolean
+): boolean {
+ const visibleTabs = getTeamInfoVisibleTabs(canEditTeam);
+ return visibleTabs.includes(tabKey);
+}
diff --git a/ui/litellm-dashboard/src/components/team/team_info.tsx b/ui/litellm-dashboard/src/components/team/team_info.tsx
deleted file mode 100644
index 014f8fb9010..00000000000
--- a/ui/litellm-dashboard/src/components/team/team_info.tsx
+++ /dev/null
@@ -1,1296 +0,0 @@
-import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
-import UserSearchModal from "@/components/common_components/user_search_modal";
-import {
- getGuardrailsList,
- getPoliciesList,
- getPolicyInfoWithGuardrails,
- Member,
- Organization,
- organizationInfoCall,
- teamInfoCall,
- teamMemberAddCall,
- teamMemberDeleteCall,
- teamMemberUpdateCall,
- teamUpdateCall,
-} from "@/components/networking";
-import { formatNumberWithCommas } from "@/utils/dataUtils";
-import { mapEmptyStringToNull } from "@/utils/keyUpdateUtils";
-import { isProxyAdminRole } from "@/utils/roles";
-import { InfoCircleOutlined } from "@ant-design/icons";
-import { ArrowLeftIcon } from "@heroicons/react/outline";
-import {
- Badge,
- Card,
- Grid,
- Tab,
- TabGroup,
- TabList,
- TabPanel,
- TabPanels,
- Text,
- TextInput,
- Title,
- Button as TremorButton,
-} from "@tremor/react";
-import { Button, Form, Input, message, Select, Switch, Tooltip } from "antd";
-import { CheckIcon, CopyIcon } from "lucide-react";
-import React, { useEffect, useMemo, useState } from "react";
-import { copyToClipboard as utilCopyToClipboard } from "../../utils/dataUtils";
-import AgentSelector from "../agent_management/AgentSelector";
-import DeleteResourceModal from "../common_components/DeleteResourceModal";
-import DurationSelect from "../common_components/DurationSelect";
-import PassThroughRoutesSelector from "../common_components/PassThroughRoutesSelector";
-import { unfurlWildcardModelsInList } from "../key_team_helpers/fetch_available_models_team_key";
-import LoggingSettingsView from "../logging_settings_view";
-import MCPServerSelector from "../mcp_server_management/MCPServerSelector";
-import MCPToolPermissions from "../mcp_server_management/MCPToolPermissions";
-import { ModelSelect } from "../ModelSelect/ModelSelect";
-import NotificationsManager from "../molecules/notifications_manager";
-import { fetchMCPAccessGroups } from "../networking";
-import ObjectPermissionsView from "../object_permissions_view";
-import NumericalInput from "../shared/numerical_input";
-import VectorStoreSelector from "../vector_store_management/VectorStoreSelector";
-import EditLoggingSettings from "./EditLoggingSettings";
-import MemberModal from "./EditMembership";
-import MemberPermissions from "./member_permissions";
-import TeamMembersComponent from "./team_member_view";
-
-export interface TeamMembership {
- user_id: string;
- team_id: string;
- budget_id: string;
- spend: number;
- litellm_budget_table: {
- budget_id: string;
- soft_budget: number | null;
- max_budget: number | null;
- max_parallel_requests: number | null;
- tpm_limit: number | null;
- rpm_limit: number | null;
- model_max_budget: Record<string, number> | null;
- budget_duration: string | null;
- };
-}
-
-export interface TeamData {
- team_id: string;
- team_info: {
- team_alias: string;
- team_id: string;
- organization_id: string | null;
- admins: string[];
- members: string[];
- members_with_roles: Member[];
- metadata: Record<string, any>;
- tpm_limit: number | null;
- rpm_limit: number | null;
- max_budget: number | null;
- soft_budget?: number | null;
- budget_duration: string | null;
- models: string[];
- blocked: boolean;
- spend: number;
- max_parallel_requests: number | null;
- budget_reset_at: string | null;
- model_id: string | null;
- litellm_model_table: {
- model_aliases: Record<string, string>;
- } | null;
- created_at: string;
- guardrails?: string[];
- policies?: string[];
- object_permission?: {
- object_permission_id: string;
- mcp_servers: string[];
- mcp_access_groups?: string[];
- mcp_tool_permissions?: Record<string, string[]>;
- vector_stores: string[];
- agents?: string[];
- agent_access_groups?: string[];
- };
- team_member_budget_table: {
- max_budget: number;
- budget_duration: string;
- tpm_limit: number | null;
- rpm_limit: number | null;
- } | null;
- };
- keys: any[];
- team_memberships: TeamMembership[];
-}
-
-export interface TeamInfoProps {
- teamId: string;
- onUpdate: (data: any) => void;
- onClose: () => void;
- accessToken: string | null;
- is_team_admin: boolean;
- is_proxy_admin: boolean;
- userModels: string[];
- editTeam: boolean;
- premiumUser?: boolean;
-}
-
-const getOrganizationModels = (organization: Organization | null, userModels: string[]) => {
- let tempModelsToPick = [];
-
- if (organization) {
- // Check if organization has "all-proxy-models" in its models array
- if (organization.models.includes("all-proxy-models")) {
- // Treat as all-proxy-models (use userModels)
- tempModelsToPick = userModels;
- } else if (organization.models.length > 0) {
- // Organization has specific models
- tempModelsToPick = organization.models;
- } else {
- // Empty array [] is treated as all-proxy-models
- tempModelsToPick = userModels;
- }
- } else {
- // No organization, show all available models
- tempModelsToPick = userModels;
- }
-
- return unfurlWildcardModelsInList(tempModelsToPick, userModels);
-};
-
-const TeamInfoView: React.FC<TeamInfoProps> = ({
- teamId,
- onClose,
- accessToken,
- is_team_admin,
- is_proxy_admin,
- userModels,
- editTeam,
- premiumUser = false,
- onUpdate,
-}) => {
- const [teamData, setTeamData] = useState<TeamData | null>(null);
- const [loading, setLoading] = useState(true);
- const [isAddMemberModalVisible, setIsAddMemberModalVisible] = useState(false);
- const [form] = Form.useForm();
- const [isEditMemberModalVisible, setIsEditMemberModalVisible] = useState(false);
- const [selectedEditMember, setSelectedEditMember] = useState<Member | null>(null);
- const [isEditing, setIsEditing] = useState(false);
- const [mcpAccessGroups, setMcpAccessGroups] = useState<string[]>([]);
- const [mcpAccessGroupsLoaded, setMcpAccessGroupsLoaded] = useState(false);
- const [copiedStates, setCopiedStates] = useState<Record<string, boolean>>({});
- const [guardrailsList, setGuardrailsList] = useState<string[]>([]);
- const [policiesList, setPoliciesList] = useState<string[]>([]);
- const [policyGuardrails, setPolicyGuardrails] = useState<Record<string, string[]>>({});
- const [loadingPolicies, setLoadingPolicies] = useState(false);
- const [memberToDelete, setMemberToDelete] = useState<Member | null>(null);
- const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
- const [isDeleting, setIsDeleting] = useState(false);
- const [isTeamSaving, setIsTeamSaving] = useState(false);
- const [organization, setOrganization] = useState<Organization | null>(null);
- const { userRole } = useAuthorized();
-
- const canEditTeam = is_team_admin || is_proxy_admin;
-
- const fetchTeamInfo = async () => {
- try {
- setLoading(true);
- if (!accessToken) return;
- const response = await teamInfoCall(accessToken, teamId);
- setTeamData(response);
- } catch (error) {
- NotificationsManager.fromBackend("Failed to load team information");
- console.error("Error fetching team info:", error);
- } finally {
- setLoading(false);
- }
- };
-
- useEffect(() => {
- fetchTeamInfo();
- }, [teamId, accessToken]);
-
- // Fetch organization data when team has organization_id
- useEffect(() => {
- const fetchOrganization = async () => {
- if (!accessToken || !teamData?.team_info?.organization_id) {
- setOrganization(null);
- return;
- }
-
- try {
- const orgData = await organizationInfoCall(accessToken, teamData.team_info.organization_id);
- setOrganization(orgData);
- } catch (error) {
- console.error("Error fetching organization info:", error);
- setOrganization(null);
- }
- };
-
- fetchOrganization();
- }, [accessToken, teamData?.team_info?.organization_id]);
-
- // Compute modelsToPick based on organization and userModels
- const modelsToPick = useMemo(() => {
- return getOrganizationModels(organization, userModels);
- }, [organization, userModels]);
-
- const fetchMcpAccessGroups = async () => {
- if (!accessToken) return;
- if (mcpAccessGroupsLoaded) return;
- try {
- const groups = await fetchMCPAccessGroups(accessToken);
- setMcpAccessGroups(groups);
- setMcpAccessGroupsLoaded(true);
- } catch (error) {
- console.error("Failed to fetch MCP access groups:", error);
- }
- };
-
- useEffect(() => {
- const fetchGuardrails = async () => {
- try {
- if (!accessToken) return;
- const response = await getGuardrailsList(accessToken);
- const guardrailNames = response.guardrails.map((g: { guardrail_name: string }) => g.guardrail_name);
- setGuardrailsList(guardrailNames);
- } catch (error) {
- console.error("Failed to fetch guardrails:", error);
- }
- };
-
- const fetchPolicies = async () => {
- try {
- if (!accessToken) return;
- const response = await getPoliciesList(accessToken);
- const policyNames = response.policies.map((p: { policy_name: string }) => p.policy_name);
- setPoliciesList(policyNames);
- } catch (error) {
- console.error("Failed to fetch policies:", error);
- }
- };
-
- fetchGuardrails();
- fetchPolicies();
- }, [accessToken]);
-
- // Fetch resolved guardrails for all policies
- useEffect(() => {
- const fetchPolicyGuardrails = async () => {
- if (!accessToken || !teamData?.team_info?.policies || teamData.team_info.policies.length === 0) {
- return;
- }
-
- setLoadingPolicies(true);
- const guardrailsMap: Record<string, string[]> = {};
-
- try {
- await Promise.all(
- teamData.team_info.policies.map(async (policyName: string) => {
- try {
- const policyInfo = await getPolicyInfoWithGuardrails(accessToken, policyName);
- guardrailsMap[policyName] = policyInfo.resolved_guardrails || [];
- } catch (error) {
- console.error(`Failed to fetch guardrails for policy ${policyName}:`, error);
- guardrailsMap[policyName] = [];
- }
- })
- );
- setPolicyGuardrails(guardrailsMap);
- } catch (error) {
- console.error("Failed to fetch policy guardrails:", error);
- } finally {
- setLoadingPolicies(false);
- }
- };
-
- fetchPolicyGuardrails();
- }, [accessToken, teamData?.team_info?.policies]);
-
- const handleMemberCreate = async (values: any) => {
- try {
- if (accessToken == null) return;
-
- const member: Member = {
- user_email: values.user_email,
- user_id: values.user_id,
- role: values.role,
- };
-
- await teamMemberAddCall(accessToken, teamId, member);
-
- NotificationsManager.success("Team member added successfully");
- setIsAddMemberModalVisible(false);
- form.resetFields();
-
- // Fetch updated team info
- const updatedTeamData = await teamInfoCall(accessToken, teamId);
- setTeamData(updatedTeamData);
-
- // Notify parent component of the update
- onUpdate(updatedTeamData);
- } catch (error: any) {
- let errMsg = "Failed to add team member";
-
- if (error?.raw?.detail?.error?.includes("Assigning team admins is a premium feature")) {
- errMsg = "Assigning admins is an enterprise-only feature. Please upgrade your LiteLLM plan to enable this.";
- } else if (error?.message) {
- errMsg = error.message;
- }
-
- NotificationsManager.fromBackend(errMsg);
- console.error("Error adding team member:", error);
- }
- };
-
- const handleMemberUpdate = async (values: any) => {
- try {
- if (accessToken == null) {
- return;
- }
-
- const member: Member = {
- user_email: values.user_email,
- user_id: values.user_id,
- role: values.role,
- max_budget_in_team: values.max_budget_in_team,
- tpm_limit: values.tpm_limit,
- rpm_limit: values.rpm_limit,
- };
- console.log("Updating member with values:", member);
- message.destroy(); // Remove all existing toasts
-
- await teamMemberUpdateCall(accessToken, teamId, member);
-
- NotificationsManager.success("Team member updated successfully");
- setIsEditMemberModalVisible(false);
-
- // Fetch updated team info
- const updatedTeamData = await teamInfoCall(accessToken, teamId);
- setTeamData(updatedTeamData);
-
- // Notify parent component of the update
- onUpdate(updatedTeamData);
- } catch (error: any) {
- let errMsg = "Failed to update team member";
- if (error?.raw?.detail?.includes("Assigning team admins is a premium feature")) {
- errMsg = "Assigning admins is an enterprise-only feature. Please upgrade your LiteLLM plan to enable this.";
- } else if (error?.message) {
- errMsg = error.message;
- }
- setIsEditMemberModalVisible(false);
-
- message.destroy(); // Remove all existing toasts
-
- NotificationsManager.fromBackend(errMsg);
- console.error("Error updating team member:", error);
- }
- };
-
- const handleMemberDelete = (member: Member) => {
- setMemberToDelete(member);
- setIsDeleteModalOpen(true);
- };
-
- const handleDeleteConfirm = async () => {
- if (!memberToDelete || !accessToken) return;
-
- setIsDeleting(true);
- try {
- await teamMemberDeleteCall(accessToken, teamId, memberToDelete);
-
- NotificationsManager.success("Team member removed successfully");
-
- // Fetch updated team info
- const updatedTeamData = await teamInfoCall(accessToken, teamId);
- setTeamData(updatedTeamData);
-
- // Notify parent component of the update
- onUpdate(updatedTeamData);
- } catch (error) {
- NotificationsManager.fromBackend("Failed to remove team member");
- console.error("Error removing team member:", error);
- } finally {
- setIsDeleting(false);
- setIsDeleteModalOpen(false);
- setMemberToDelete(null);
- }
- };
-
- const handleDeleteCancel = () => {
- setIsDeleteModalOpen(false);
- setMemberToDelete(null);
- };
-
- const handleTeamUpdate = async (values: any) => {
- try {
- if (!accessToken) return;
- setIsTeamSaving(true);
-
- let parsedMetadata = {};
- try {
- const rawMetadata = values.metadata ? JSON.parse(values.metadata) : {};
- // Exclude soft_budget_alerting_emails from parsed metadata since it's handled separately
- const { soft_budget_alerting_emails, ...rest } = rawMetadata;
- parsedMetadata = rest;
- } catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in metadata field");
- return;
- }
-
- let secretManagerSettings: Record<string, any> | undefined;
- if (typeof values.secret_manager_settings === "string") {
- const trimmedSecretConfig = values.secret_manager_settings.trim();
- if (trimmedSecretConfig.length > 0) {
- try {
- secretManagerSettings = JSON.parse(values.secret_manager_settings);
- } catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in secret manager settings");
- return;
- }
- }
- }
-
- const sanitizeNumeric = (v: any) => {
- if (v === null || v === undefined) return null;
- if (typeof v === "string" && v.trim() === "") return null;
- if (typeof v === "number" && Number.isNaN(v)) return null;
- return v;
- };
-
- const updateData: any = {
- team_id: teamId,
- team_alias: values.team_alias,
- models: values.models,
- tpm_limit: sanitizeNumeric(values.tpm_limit),
- rpm_limit: sanitizeNumeric(values.rpm_limit),
- max_budget: values.max_budget,
- soft_budget: sanitizeNumeric(values.soft_budget),
- budget_duration: values.budget_duration,
- metadata: {
- ...parsedMetadata,
- ...(values.guardrails?.length > 0 ? { guardrails: values.guardrails } : {}),
- ...(values.logging_settings?.length > 0 ? { logging: values.logging_settings } : {}),
- disable_global_guardrails: values.disable_global_guardrails || false,
- soft_budget_alerting_emails:
- typeof values.soft_budget_alerting_emails === "string"
- ? values.soft_budget_alerting_emails
- .split(",")
- .map((email: string) => email.trim())
- .filter((email: string) => email.length > 0)
- : values.soft_budget_alerting_emails || [],
- ...(secretManagerSettings !== undefined ? { secret_manager_settings: secretManagerSettings } : {}),
- },
- ...(values.policies?.length > 0 ? { policies: values.policies } : {}),
- organization_id: values.organization_id,
- };
-
- updateData.max_budget = mapEmptyStringToNull(updateData.max_budget);
- updateData.team_member_budget_duration = values.team_member_budget_duration;
-
- if (values.team_member_budget !== undefined) {
- updateData.team_member_budget = Number(values.team_member_budget);
- }
-
- if (values.team_member_key_duration !== undefined) {
- updateData.team_member_key_duration = values.team_member_key_duration;
- }
-
- if (values.team_member_tpm_limit !== undefined || values.team_member_rpm_limit !== undefined) {
- updateData.team_member_tpm_limit = sanitizeNumeric(values.team_member_tpm_limit);
- updateData.team_member_rpm_limit = sanitizeNumeric(values.team_member_rpm_limit);
- }
-
- // Handle object_permission updates
- const { servers, accessGroups } = values.mcp_servers_and_groups || {
- servers: [],
- accessGroups: [],
- };
- const serverIds = new Set(servers || []);
- const mcpToolPermissions = Object.fromEntries(
- Object.entries(values.mcp_tool_permissions || {}).filter(([serverId]) => serverIds.has(serverId)),
- );
-
- updateData.object_permission = {};
- if (servers) {
- updateData.object_permission.mcp_servers = servers;
- }
- if (accessGroups) {
- updateData.object_permission.mcp_access_groups = accessGroups;
- }
- if (mcpToolPermissions) {
- updateData.object_permission.mcp_tool_permissions = mcpToolPermissions;
- }
- delete values.mcp_servers_and_groups;
- delete values.mcp_tool_permissions;
-
- // Handle agent permissions
- const { agents, accessGroups: agentAccessGroups } = values.agents_and_groups || {
- agents: [],
- accessGroups: [],
- };
- if (agents && agents.length > 0) {
- updateData.object_permission.agents = agents;
- }
- if (agentAccessGroups && agentAccessGroups.length > 0) {
- updateData.object_permission.agent_access_groups = agentAccessGroups;
- }
- delete values.agents_and_groups;
-
- // Handle vector stores permissions
- if (values.vector_stores && values.vector_stores.length > 0) {
- updateData.object_permission.vector_stores = values.vector_stores;
- }
-
- const response = await teamUpdateCall(accessToken, updateData);
-
- NotificationsManager.success("Team settings updated successfully");
- setIsEditing(false);
- fetchTeamInfo();
- } catch (error) {
- console.error("Error updating team:", error);
- } finally {
- setIsTeamSaving(false);
- }
- };
-
- if (loading) {
- return <div className="p-4">Loading...</div>;
- }
-
- if (!teamData?.team_info) {
- return <div className="p-4">Team not found</div>;
- }
-
- const { team_info: info } = teamData;
-
- const copyToClipboard = async (text: string, key: string) => {
- const success = await utilCopyToClipboard(text);
- if (success) {
- setCopiedStates((prev) => ({ ...prev, [key]: true }));
- setTimeout(() => {
- setCopiedStates((prev) => ({ ...prev, [key]: false }));
- }, 2000);
- }
- };
-
- return (
- <div className="p-4">
- <div className="flex justify-between items-center mb-6">
- <div>
- <TremorButton icon={ArrowLeftIcon} variant="light" onClick={onClose} className="mb-4">
- Back to Teams
- </TremorButton>
- <Title>{info.team_alias}</Title>
- <div className="flex items-center">
- <Text className="text-gray-500 font-mono">{info.team_id}</Text>
- <Button
- type="text"
- size="small"
- icon={copiedStates["team-id"] ? <CheckIcon size={12} /> : <CopyIcon size={12} />}
- onClick={() => copyToClipboard(info.team_id, "team-id")}
- className={`left-2 z-10 transition-all duration-200 ${copiedStates["team-id"]
- ? "text-green-600 bg-green-50 border-green-200"
- : "text-gray-500 hover:text-gray-700 hover:bg-gray-100"
- }`}
- />
- </div>
- </div>
- </div>
-
- <TabGroup defaultIndex={editTeam ? 3 : 0}>
- <TabList className="mb-4">
- {[
- <Tab key="overview">Overview</Tab>,
- ...(canEditTeam
- ? [
- <Tab key="members">Members</Tab>,
- <Tab key="member-permissions">Member Permissions</Tab>,
- <Tab key="settings">Settings</Tab>,
- ]
- : []),
- ]}
- </TabList>
-
- <TabPanels>
- {/* Overview Panel */}
- <TabPanel>
- <Grid numItems={1} numItemsSm={2} numItemsLg={3} className="gap-6">
- <Card>
- <Text>Budget Status</Text>
- <div className="mt-2">
- <Title>${formatNumberWithCommas(info.spend, 4)}</Title>
- <Text>
- of {info.max_budget === null ? "Unlimited" : `$${formatNumberWithCommas(info.max_budget, 4)}`}
- </Text>
- {info.budget_duration && <Text className="text-gray-500">Reset: {info.budget_duration}</Text>}
- <br />
- {info.team_member_budget_table && (
- <Text className="text-gray-500">
- Team Member Budget: ${formatNumberWithCommas(info.team_member_budget_table.max_budget, 4)}
- </Text>
- )}
- </div>
- </Card>
-
- <Card>
- <Text>Rate Limits</Text>
- <div className="mt-2">
- <Text>TPM: {info.tpm_limit || "Unlimited"}</Text>
- <Text>RPM: {info.rpm_limit || "Unlimited"}</Text>
- {info.max_parallel_requests && <Text>Max Parallel Requests: {info.max_parallel_requests}</Text>}
- </div>
- </Card>
-
- <Card>
- <Text>Models</Text>
- <div className="mt-2 flex flex-wrap gap-2">
- {info.models.length === 0 ? (
- <Badge color="red">All proxy models</Badge>
- ) : (
- info.models.map((model, index) => (
- <Badge key={index} color="red">
- {model}
- </Badge>
- ))
- )}
- </div>
- </Card>
-
- <Card>
- <Text className="font-semibold text-gray-900">Virtual Keys</Text>
- <div className="mt-2">
- <Text>User Keys: {teamData.keys.filter((key) => key.user_id).length}</Text>
- <Text>Service Account Keys: {teamData.keys.filter((key) => !key.user_id).length}</Text>
- <Text className="text-gray-500">Total: {teamData.keys.length}</Text>
- </div>
- </Card>
-
- <ObjectPermissionsView
- objectPermission={info.object_permission}
- variant="card"
- accessToken={accessToken}
- />
-
- <Card>
- <Text className="font-semibold text-gray-900 mb-3">Guardrails</Text>
- {info.guardrails && info.guardrails.length > 0 ? (
- <div className="flex flex-wrap gap-2">
- {info.guardrails.map((guardrail: string, index: number) => (
- <Badge key={index} color="blue">
- {guardrail}
- </Badge>
- ))}
- </div>
- ) : (
- <Text className="text-gray-500">No guardrails configured</Text>
- )}
- {info.metadata?.disable_global_guardrails && (
- <div className="mt-3 pt-3 border-t border-gray-200">
- <Badge color="yellow">Global Guardrails Disabled</Badge>
- </div>
- )}
- </Card>
-
- <Card>
- <Text className="font-semibold text-gray-900 mb-3">Policies</Text>
- {info.policies && info.policies.length > 0 ? (
- <div className="space-y-4">
- {info.policies.map((policy: string, index: number) => (
- <div key={index} className="space-y-2">
- <div className="flex items-center gap-2">
- <Badge color="purple">{policy}</Badge>
- {loadingPolicies && <Text className="text-xs text-gray-400">Loading guardrails...</Text>}
- </div>
- {!loadingPolicies && policyGuardrails[policy] && policyGuardrails[policy].length > 0 && (
- <div className="ml-4 pl-3 border-l-2 border-gray-200">
- <Text className="text-xs text-gray-500 mb-1">Resolved Guardrails:</Text>
- <div className="flex flex-wrap gap-1">
- {policyGuardrails[policy].map((guardrail: string, gIndex: number) => (
- <Badge key={gIndex} color="blue" size="xs">
- {guardrail}
- </Badge>
- ))}
- </div>
- </div>
- )}
- </div>
- ))}
- </div>
- ) : (
- <Text className="text-gray-500">No policies configured</Text>
- )}
- </Card>
-
- <LoggingSettingsView
- loggingConfigs={info.metadata?.logging || []}
- disabledCallbacks={[]}
- variant="card"
- />
- </Grid>
- </TabPanel>
-
- {/* Members Panel */}
- <TabPanel>
- <TeamMembersComponent
- teamData={teamData}
- canEditTeam={canEditTeam}
- handleMemberDelete={handleMemberDelete}
- setSelectedEditMember={setSelectedEditMember}
- setIsEditMemberModalVisible={setIsEditMemberModalVisible}
- setIsAddMemberModalVisible={setIsAddMemberModalVisible}
- />
- </TabPanel>
-
- {/* Member Permissions Panel */}
- {canEditTeam && (
- <TabPanel>
- <MemberPermissions teamId={teamId} accessToken={accessToken} canEditTeam={canEditTeam} />
- </TabPanel>
- )}
-
- {/* Settings Panel */}
- <TabPanel>
- <Card className="overflow-y-auto max-h-[65vh]">
- <div className="flex justify-between items-center mb-4">
- <Title>Team Settings</Title>
- {canEditTeam && !isEditing && (
- <TremorButton onClick={() => setIsEditing(true)}>Edit Settings</TremorButton>
- )}
- </div>
-
- {isEditing ? (
- <Form
- form={form}
- onFinish={handleTeamUpdate}
- initialValues={{
- ...info,
- team_alias: info.team_alias,
- models: info.models,
- tpm_limit: info.tpm_limit,
- rpm_limit: info.rpm_limit,
- max_budget: info.max_budget,
- soft_budget: info.soft_budget,
- budget_duration: info.budget_duration,
- team_member_tpm_limit: info.team_member_budget_table?.tpm_limit,
- team_member_rpm_limit: info.team_member_budget_table?.rpm_limit,
- team_member_budget: info.team_member_budget_table?.max_budget,
- team_member_budget_duration: info.team_member_budget_table?.budget_duration,
- guardrails: info.metadata?.guardrails || [],
- policies: info.policies || [],
- disable_global_guardrails: info.metadata?.disable_global_guardrails || false,
- soft_budget_alerting_emails:
- Array.isArray(info.metadata?.soft_budget_alerting_emails)
- ? info.metadata.soft_budget_alerting_emails.join(", ")
- : "",
- metadata: info.metadata
- ? JSON.stringify(
- (({ logging, secret_manager_settings, soft_budget_alerting_emails, ...rest }) => rest)(info.metadata),
- null,
- 2,
- )
- : "",
- logging_settings: info.metadata?.logging || [],
- secret_manager_settings: info.metadata?.secret_manager_settings
- ? JSON.stringify(info.metadata.secret_manager_settings, null, 2)
- : "",
- organization_id: info.organization_id,
- vector_stores: info.object_permission?.vector_stores || [],
- mcp_servers: info.object_permission?.mcp_servers || [],
- mcp_access_groups: info.object_permission?.mcp_access_groups || [],
- mcp_servers_and_groups: {
- servers: info.object_permission?.mcp_servers || [],
- accessGroups: info.object_permission?.mcp_access_groups || [],
- },
- mcp_tool_permissions: info.object_permission?.mcp_tool_permissions || {},
- agents_and_groups: {
- agents: info.object_permission?.agents || [],
- accessGroups: info.object_permission?.agent_access_groups || [],
- },
- }}
- layout="vertical"
- >
- <Form.Item
- label="Team Name"
- name="team_alias"
- rules={[{ required: true, message: "Please input a team name" }]}
- >
- <Input type="" />
- </Form.Item>
-
- <Form.Item
- label="Models"
- name="models"
- rules={[{ required: true, message: "Please select at least one model" }]}
- >
- <ModelSelect
- value={form.getFieldValue("models") || []}
- onChange={(values) => form.setFieldValue("models", values)}
- teamID={teamId}
- organizationID={teamData?.team_info?.organization_id || undefined}
- options={{
- includeSpecialOptions: true,
- includeUserModels: !teamData?.team_info?.organization_id,
- showAllProxyModelsOverride: isProxyAdminRole(userRole) && !teamData?.team_info?.organization_id,
- }}
- context="team"
- dataTestId="models-select"
- />
- </Form.Item>
-
- <Form.Item label="Max Budget (USD)" name="max_budget">
- <NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
- </Form.Item>
-
- <Form.Item label="Soft Budget (USD)" name="soft_budget">
- <NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
- </Form.Item>
-
- <Form.Item
- label="Soft Budget Alerting Emails"
- name="soft_budget_alerting_emails"
- tooltip="Comma-separated email addresses to receive alerts when the soft budget is reached"
- >
- <Input placeholder="[email protected], [email protected]" />
- </Form.Item>
-
- <Form.Item
- label="Team Member Budget (USD)"
- name="team_member_budget"
- tooltip="This is the individual budget for a user in the team."
- >
- <NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
- </Form.Item>
-
- <Form.Item label="Team Member Budget Duration" name="team_member_budget_duration">
- <DurationSelect
- onChange={(value) => form.setFieldValue("team_member_budget_duration", value)}
- value={form.getFieldValue("team_member_budget_duration")}
- />
- </Form.Item>
-
- <Form.Item
- label="Team Member Key Duration (eg: 1d, 1mo)"
- name="team_member_key_duration"
- tooltip="Set a limit to the duration of a team member's key. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days), 1mo (month)"
- >
- <TextInput placeholder="e.g., 30d" />
- </Form.Item>
-
- <Form.Item
- label="Team Member TPM Limit"
- name="team_member_tpm_limit"
- tooltip="Default tokens per minute limit for an individual team member. This limit applies to all requests the user makes within this team. Can be overridden per member."
- >
- <NumericalInput step={1} style={{ width: "100%" }} placeholder="e.g., 1000" />
- </Form.Item>
-
- <Form.Item
- label="Team Member RPM Limit"
- name="team_member_rpm_limit"
- tooltip="Default requests per minute limit for an individual team member. This limit applies to all requests the user makes within this team. Can be overridden per member."
- >
- <NumericalInput step={1} style={{ width: "100%" }} placeholder="e.g., 100" />
- </Form.Item>
-
- <Form.Item label="Reset Budget" name="budget_duration">
- <Select placeholder="n/a">
- <Select.Option value="24h">daily</Select.Option>
- <Select.Option value="7d">weekly</Select.Option>
- <Select.Option value="30d">monthly</Select.Option>
- </Select>
- </Form.Item>
-
- <Form.Item label="Tokens per minute Limit (TPM)" name="tpm_limit">
- <NumericalInput step={1} style={{ width: "100%" }} />
- </Form.Item>
-
- <Form.Item label="Requests per minute Limit (RPM)" name="rpm_limit">
- <NumericalInput step={1} style={{ width: "100%" }} />
- </Form.Item>
-
- <Form.Item
- label={
- <span>
- Guardrails{" "}
- <Tooltip title="Setup your first guardrail">
- <a
- href="https://docs.litellm.ai/docs/proxy/guardrails/quick_start"
- target="_blank"
- rel="noopener noreferrer"
- onClick={(e) => e.stopPropagation()}
- >
- <InfoCircleOutlined style={{ marginLeft: "4px" }} />
- </a>
- </Tooltip>
- </span>
- }
- name="guardrails"
- help="Select existing guardrails or enter new ones"
- >
- <Select
- mode="tags"
- placeholder="Select or enter guardrails"
- options={guardrailsList.map((name) => ({ value: name, label: name }))}
- />
- </Form.Item>
-
- <Form.Item
- label={
- <span>
- Disable Global Guardrails
- <Tooltip title="When enabled, this team will bypass any guardrails configured to run on every request (global guardrails)">
- <InfoCircleOutlined style={{ marginLeft: "4px" }} />
- </Tooltip>
- </span>
- }
- name="disable_global_guardrails"
- valuePropName="checked"
- help="Bypass global guardrails for this team"
- >
- <Switch checkedChildren="Yes" unCheckedChildren="No" />
- </Form.Item>
-
- <Form.Item
- label={
- <span>
- Policies{" "}
- <Tooltip title="Apply policies to this team to control guardrails and other settings">
- <a
- href="https://docs.litellm.ai/docs/proxy/guardrails/guardrail_policies"
- target="_blank"
- rel="noopener noreferrer"
- onClick={(e) => e.stopPropagation()}
- >
- <InfoCircleOutlined style={{ marginLeft: "4px" }} />
- </a>
- </Tooltip>
- </span>
- }
- name="policies"
- help="Select existing policies or enter new ones"
- >
- <Select
- mode="tags"
- placeholder="Select or enter policies"
- options={policiesList.map((name) => ({ value: name, label: name }))}
- />
- </Form.Item>
-
- <Form.Item label="Vector Stores" name="vector_stores" aria-label="Vector Stores">
- <VectorStoreSelector
- onChange={(values: string[]) => form.setFieldValue("vector_stores", values)}
- value={form.getFieldValue("vector_stores")}
- accessToken={accessToken || ""}
- placeholder="Select vector stores"
- />
- </Form.Item>
-
- <Form.Item label="Allowed Pass Through Routes" name="allowed_passthrough_routes">
- <PassThroughRoutesSelector
- onChange={(values: string[]) => form.setFieldValue("allowed_passthrough_routes", values)}
- value={form.getFieldValue("allowed_passthrough_routes")}
- accessToken={accessToken || ""}
- placeholder="Select pass through routes"
- />
- </Form.Item>
-
- <Form.Item label="MCP Servers / Access Groups" name="mcp_servers_and_groups">
- <MCPServerSelector
- onChange={(val) => form.setFieldValue("mcp_servers_and_groups", val)}
- value={form.getFieldValue("mcp_servers_and_groups")}
- accessToken={accessToken || ""}
- placeholder="Select MCP servers or access groups (optional)"
- />
- </Form.Item>
-
- {/* Hidden field to register mcp_tool_permissions with the form */}
- <Form.Item name="mcp_tool_permissions" initialValue={{}} hidden>
- <Input type="hidden" />
- </Form.Item>
-
- <Form.Item
- noStyle
- shouldUpdate={(prevValues, currentValues) =>
- prevValues.mcp_servers_and_groups !== currentValues.mcp_servers_and_groups ||
- prevValues.mcp_tool_permissions !== currentValues.mcp_tool_permissions
- }
- >
- {() => (
- <div className="mb-6">
- <MCPToolPermissions
- accessToken={accessToken || ""}
- selectedServers={form.getFieldValue("mcp_servers_and_groups")?.servers || []}
- toolPermissions={form.getFieldValue("mcp_tool_permissions") || {}}
- onChange={(toolPerms) => form.setFieldsValue({ mcp_tool_permissions: toolPerms })}
- />
- </div>
- )}
- </Form.Item>
-
- <Form.Item label="Agents / Access Groups" name="agents_and_groups">
- <AgentSelector
- onChange={(val) => form.setFieldValue("agents_and_groups", val)}
- value={form.getFieldValue("agents_and_groups")}
- accessToken={accessToken || ""}
- placeholder="Select agents or access groups (optional)"
- />
- </Form.Item>
-
- <Form.Item label="Organization ID" name="organization_id">
- <Input type="" disabled />
- </Form.Item>
-
- <Form.Item label="Logging Settings" name="logging_settings">
- <EditLoggingSettings
- value={form.getFieldValue("logging_settings")}
- onChange={(values) => form.setFieldValue("logging_settings", values)}
- />
- </Form.Item>
-
- <Form.Item
- label="Secret Manager Settings"
- name="secret_manager_settings"
- help={
- premiumUser
- ? "Enter secret manager configuration as a JSON object."
- : "Premium feature - Upgrade to manage secret manager settings."
- }
- rules={[
- {
- validator: async (_, value) => {
- if (!value) {
- return Promise.resolve();
- }
- try {
- JSON.parse(value);
- return Promise.resolve();
- } catch (error) {
- return Promise.reject(new Error("Please enter valid JSON"));
- }
- },
- },
- ]}
- >
- <Input.TextArea
- rows={6}
- placeholder='{"namespace": "admin", "mount": "secret", "path_prefix": "litellm"}'
- disabled={!premiumUser}
- />
- </Form.Item>
-
- <Form.Item label="Metadata" name="metadata">
- <Input.TextArea rows={10} />
- </Form.Item>
-
- <div className="sticky z-10 bg-white p-4 border-t border-gray-200 bottom-[-1.5rem] inset-x-[-1.5rem]">
- <div className="flex justify-end items-center gap-2">
- <TremorButton variant="secondary" onClick={() => setIsEditing(false)} disabled={isTeamSaving}>
- Cancel
- </TremorButton>
- <TremorButton type="submit" loading={isTeamSaving}>
- Save Changes
- </TremorButton>
- </div>
- </div>
- </Form>
- ) : (
- <div className="space-y-4">
- <div>
- <Text className="font-medium">Team Name</Text>
- <div>{info.team_alias}</div>
- </div>
- <div>
- <Text className="font-medium">Team ID</Text>
- <div className="font-mono">{info.team_id}</div>
- </div>
- <div>
- <Text className="font-medium">Created At</Text>
- <div>{new Date(info.created_at).toLocaleString()}</div>
- </div>
- <div>
- <Text className="font-medium">Models</Text>
- <div className="flex flex-wrap gap-2 mt-1">
- {info.models.map((model, index) => (
- <Badge key={index} color="red">
- {model}
- </Badge>
- ))}
- </div>
- </div>
- <div>
- <Text className="font-medium">Rate Limits</Text>
- <div>TPM: {info.tpm_limit || "Unlimited"}</div>
- <div>RPM: {info.rpm_limit || "Unlimited"}</div>
- </div>
- <div>
- <Text className="font-medium">Team Budget</Text>
- <div>
- Max Budget:{" "}
- {info.max_budget !== null ? `$${formatNumberWithCommas(info.max_budget, 4)}` : "No Limit"}
- </div>
- <div>
- Soft Budget:{" "}
- {info.soft_budget !== null && info.soft_budget !== undefined
- ? `$${formatNumberWithCommas(info.soft_budget, 4)}`
- : "No Limit"}
- </div>
- <div>Budget Reset: {info.budget_duration || "Never"}</div>
- {info.metadata?.soft_budget_alerting_emails &&
- Array.isArray(info.metadata.soft_budget_alerting_emails) &&
- info.metadata.soft_budget_alerting_emails.length > 0 && (
- <div>
- Soft Budget Alerting Emails: {info.metadata.soft_budget_alerting_emails.join(", ")}
- </div>
- )}
- </div>
- <div>
- <Text className="font-medium">
- Team Member Settings{" "}
- <Tooltip title="These are limits on individual team members">
- <InfoCircleOutlined style={{ marginLeft: "4px" }} />
- </Tooltip>
- </Text>
- <div>Max Budget: {info.team_member_budget_table?.max_budget || "No Limit"}</div>
- <div>Budget Duration: {info.team_member_budget_table?.budget_duration || "No Limit"}</div>
- <div>Key Duration: {info.metadata?.team_member_key_duration || "No Limit"}</div>
- <div>TPM Limit: {info.team_member_budget_table?.tpm_limit || "No Limit"}</div>
- <div>RPM Limit: {info.team_member_budget_table?.rpm_limit || "No Limit"}</div>
- </div>
- <div>
- <Text className="font-medium">Organization ID</Text>
- <div>{info.organization_id}</div>
- </div>
- <div>
- <Text className="font-medium">Status</Text>
- <Badge color={info.blocked ? "red" : "green"}>{info.blocked ? "Blocked" : "Active"}</Badge>
- </div>
-
- <div>
- <Text className="font-medium">Disable Global Guardrails</Text>
- <div>
- {info.metadata?.disable_global_guardrails === true ? (
- <Badge color="yellow">Enabled - Global guardrails bypassed</Badge>
- ) : (
- <Badge color="green">Disabled - Global guardrails active</Badge>
- )}
- </div>
- </div>
-
- <ObjectPermissionsView
- objectPermission={info.object_permission}
- variant="inline"
- className="pt-4 border-t border-gray-200"
- accessToken={accessToken}
- />
-
- <LoggingSettingsView
- loggingConfigs={info.metadata?.logging || []}
- disabledCallbacks={[]}
- variant="inline"
- className="pt-4 border-t border-gray-200"
- />
-
- {info.metadata?.secret_manager_settings && (
- <div className="pt-4 border-t border-gray-200">
- <Text className="font-medium">Secret Manager Settings</Text>
- <pre className="mt-2 bg-gray-50 p-3 rounded text-xs overflow-x-auto">
- {JSON.stringify(info.metadata.secret_manager_settings, null, 2)}
- </pre>
- </div>
- )}
- </div>
- )}
- </Card>
- </TabPanel>
- </TabPanels>
- </TabGroup>
-
- <MemberModal
- visible={isEditMemberModalVisible}
- onCancel={() => setIsEditMemberModalVisible(false)}
- onSubmit={handleMemberUpdate}
- initialData={selectedEditMember}
- mode="edit"
- config={{
- title: "Edit Member",
- showEmail: true,
- showUserId: true,
- roleOptions: [
- { label: "Admin", value: "admin" },
- { label: "User", value: "user" },
- ],
- additionalFields: [
- {
- name: "max_budget_in_team",
- label: (
- <span>
- Team Member Budget (USD){" "}
- <Tooltip title="Maximum amount in USD this member can spend within this team. This is separate from any global user budget limits">
- <InfoCircleOutlined style={{ marginLeft: "4px" }} />
- </Tooltip>
- </span>
- ),
- type: "numerical" as const,
- step: 0.01,
- min: 0,
- placeholder: "Budget limit for this member within this team",
- },
- {
- name: "tpm_limit",
- label: (
- <span>
- Team Member TPM Limit{" "}
- <Tooltip title="Maximum tokens per minute this member can use within this team. This is separate from any global user TPM limit">
- <InfoCircleOutlined style={{ marginLeft: "4px" }} />
- </Tooltip>
- </span>
- ),
- type: "numerical" as const,
- step: 1,
- min: 0,
- placeholder: "Tokens per minute limit for this member in this team",
- },
- {
- name: "rpm_limit",
- label: (
- <span>
- Team Member RPM Limit{" "}
- <Tooltip title="Maximum requests per minute this member can make within this team. This is separate from any global user RPM limit">
- <InfoCircleOutlined style={{ marginLeft: "4px" }} />
- </Tooltip>
- </span>
- ),
- type: "numerical" as const,
- step: 1,
- min: 0,
- placeholder: "Requests per minute limit for this member in this team",
- },
- ],
- }}
- />
-
- <UserSearchModal
- isVisible={isAddMemberModalVisible}
- onCancel={() => setIsAddMemberModalVisible(false)}
- onSubmit={handleMemberCreate}
- accessToken={accessToken}
- />
-
- {/* Delete Member Confirmation Modal */}
- <DeleteResourceModal
- isOpen={isDeleteModalOpen}
- title="Delete Team Member"
- alertMessage="Removing team members will also delete any keys created by or created for this member."
- message="Are you sure you want to remove this member from the team? This action cannot be undone."
- resourceInformationTitle="Team Member Information"
- resourceInformation={[
- { label: "User ID", value: memberToDelete?.user_id, code: true },
- { label: "Email", value: memberToDelete?.user_email },
- { label: "Role", value: memberToDelete?.role },
- ]}
- onCancel={handleDeleteCancel}
- onOk={handleDeleteConfirm}
- confirmLoading={isDeleting}
- />
- </div>
- );
-};
-
-export default TeamInfoView;
diff --git a/ui/litellm-dashboard/src/components/team/team_member_view.test.tsx b/ui/litellm-dashboard/src/components/team/team_member_view.test.tsx
deleted file mode 100644
index 30a06179c2f..00000000000
--- a/ui/litellm-dashboard/src/components/team/team_member_view.test.tsx
+++ /dev/null
@@ -1,193 +0,0 @@
-import { screen } from "@testing-library/react";
-import { beforeEach, describe, expect, it, vi } from "vitest";
-import { renderWithProviders } from "../../../tests/test-utils";
-import { TeamData } from "./team_info";
-import TeamMembersComponent from "./team_member_view";
-
-// Mock the hooks
-vi.mock("@/app/(dashboard)/hooks/uiSettings/useUISettings", () => ({
- useUISettings: vi.fn(),
-}));
-
-vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
- default: vi.fn(),
-}));
-
-vi.mock("@/utils/roles", () => ({
- isUserTeamAdminForSingleTeam: vi.fn(() => false),
- isProxyAdminRole: vi.fn(() => false),
-}));
-
-import { useUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUISettings";
-import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
-import { isProxyAdminRole, isUserTeamAdminForSingleTeam } from "@/utils/roles";
-
-describe("TeamMembersComponent", () => {
- const mockHandleMemberDelete = vi.fn();
- const mockSetSelectedEditMember = vi.fn();
- const mockSetIsEditMemberModalVisible = vi.fn();
- const mockSetIsAddMemberModalVisible = vi.fn();
-
- const mockTeamData: TeamData = {
- team_id: "team-123",
- team_info: {
- team_alias: "Test Team",
- team_id: "team-123",
- organization_id: null,
- admins: ["[email protected]"],
- members: ["[email protected]"],
- members_with_roles: [
- {
- user_id: "[email protected]",
- user_email: "[email protected]",
- role: "member",
- },
- {
- user_id: "[email protected]",
- user_email: "[email protected]",
- role: "admin",
- },
- ],
- metadata: {},
- tpm_limit: null,
- rpm_limit: null,
- max_budget: null,
- budget_duration: null,
- models: [],
- blocked: false,
- spend: 0,
- max_parallel_requests: null,
- budget_reset_at: null,
- model_id: null,
- litellm_model_table: null,
- created_at: "2024-01-01T00:00:00Z",
- team_member_budget_table: null,
- },
- keys: [],
- team_memberships: [
- {
- user_id: "[email protected]",
- team_id: "team-123",
- budget_id: "budget1",
- spend: 100.5,
- litellm_budget_table: {
- budget_id: "budget1",
- soft_budget: null,
- max_budget: 1000,
- max_parallel_requests: null,
- tpm_limit: 10000,
- rpm_limit: 100,
- model_max_budget: null,
- budget_duration: null,
- },
- },
- ],
- };
-
- beforeEach(() => {
- vi.clearAllMocks();
- vi.mocked(useUISettings).mockReturnValue({
- data: { values: { disable_team_admin_delete_team_user: false } },
- isLoading: false,
- isError: false,
- error: null,
- isSuccess: true,
- isFetching: false,
- refetch: vi.fn(),
- } as any);
-
- vi.mocked(useAuthorized).mockReturnValue({
- userId: "test-user-id",
- userRole: "Admin",
- accessToken: "test-token",
- token: "test-token",
- userEmail: "[email protected]",
- premiumUser: false,
- disabledPersonalKeyCreation: null,
- showSSOBanner: false,
- });
- });
-
- it("should render team members table with headers", () => {
- renderWithProviders(
- <TeamMembersComponent
- teamData={mockTeamData}
- canEditTeam={false}
- handleMemberDelete={mockHandleMemberDelete}
- setSelectedEditMember={mockSetSelectedEditMember}
- setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
- setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
- />,
- );
-
- expect(screen.getByText("User ID")).toBeInTheDocument();
- expect(screen.getByText("User Email")).toBeInTheDocument();
- expect(screen.getByText("Role")).toBeInTheDocument();
- expect(screen.getByText("Team Member Spend (USD)")).toBeInTheDocument();
- expect(screen.getByText("Team Member Budget (USD)")).toBeInTheDocument();
- expect(screen.getByText("Team Member Rate Limits")).toBeInTheDocument();
- expect(screen.getByText("Actions")).toBeInTheDocument();
- });
-
- it("should render team members data", () => {
- renderWithProviders(
- <TeamMembersComponent
- teamData={mockTeamData}
- canEditTeam={false}
- handleMemberDelete={mockHandleMemberDelete}
- setSelectedEditMember={mockSetSelectedEditMember}
- setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
- setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
- />,
- );
-
- // [email protected] appears twice (User ID and User Email columns)
- expect(screen.getAllByText("[email protected]")).toHaveLength(2);
- // [email protected] appears twice (User ID and User Email columns)
- expect(screen.getAllByText("[email protected]")).toHaveLength(2);
- expect(screen.getByText("member")).toBeInTheDocument();
- expect(screen.getByText("admin")).toBeInTheDocument();
- });
-
- it("should render Add Member button", () => {
- renderWithProviders(
- <TeamMembersComponent
- teamData={mockTeamData}
- canEditTeam={false}
- handleMemberDelete={mockHandleMemberDelete}
- setSelectedEditMember={mockSetSelectedEditMember}
- setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
- setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
- />,
- );
-
- expect(screen.getByText("Add Member")).toBeInTheDocument();
- });
-
- it("should show delete button for proxy admin when canEditTeam is true", () => {
- vi.mocked(isProxyAdminRole).mockReturnValue(true);
- vi.mocked(isUserTeamAdminForSingleTeam).mockReturnValue(false);
-
- const { container } = renderWithProviders(
- <TeamMembersComponent
- teamData={mockTeamData}
- canEditTeam={true}
- handleMemberDelete={mockHandleMemberDelete}
- setSelectedEditMember={mockSetSelectedEditMember}
- setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}
- setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}
- />,
- );
-
- // Verify that action buttons are rendered when canEditTeam is true
- // For proxy admin, both edit and delete buttons should be visible
- // Check for clickable icon elements (Tremor Icon components with cursor-pointer class)
- const clickableIcons = container.querySelectorAll('[class*="cursor-pointer"]');
- // Should have at least 4 icons: 2 edit buttons + 2 delete buttons for 2 members
- expect(clickableIcons.length).toBeGreaterThanOrEqual(4);
-
- // Verify members are rendered
- expect(screen.getAllByText("[email protected]").length).toBeGreaterThan(0);
- expect(screen.getAllByText("[email protected]").length).toBeGreaterThan(0);
- });
-});
diff --git a/ui/litellm-dashboard/src/components/team/team_member_view.tsx b/ui/litellm-dashboard/src/components/team/team_member_view.tsx
deleted file mode 100644
index 10b3cbd83e6..00000000000
--- a/ui/litellm-dashboard/src/components/team/team_member_view.tsx
+++ /dev/null
@@ -1,193 +0,0 @@
-import { useUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUISettings";
-import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
-import { Member } from "@/components/networking";
-import { formatNumberWithCommas } from "@/utils/dataUtils";
-import { isProxyAdminRole, isUserTeamAdminForSingleTeam } from "@/utils/roles";
-import { InfoCircleOutlined } from "@ant-design/icons";
-import {
- Card,
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeaderCell,
- TableRow,
- Text,
- Button as TremorButton,
-} from "@tremor/react";
-import { Tooltip } from "antd";
-import React from "react";
-import TableIconActionButton from "../common_components/IconActionButton/TableIconActionButtons/TableIconActionButton";
-import { TeamData } from "./team_info";
-
-interface TeamMembersComponentProps {
- teamData: TeamData;
- canEditTeam: boolean;
- handleMemberDelete: (member: Member) => void;
- setSelectedEditMember: (member: Member) => void;
- setIsEditMemberModalVisible: (visible: boolean) => void;
- setIsAddMemberModalVisible: (visible: boolean) => void;
-}
-
-const TeamMembersComponent: React.FC<TeamMembersComponentProps> = ({
- teamData,
- canEditTeam,
- handleMemberDelete,
- setSelectedEditMember,
- setIsEditMemberModalVisible,
- setIsAddMemberModalVisible,
-}) => {
- console.log("Team data", teamData);
- // Helper function to convert scientific notation to normal decimal format
- const formatNumber = (value: number | null): string => {
- if (value === null || value === undefined) return "0";
-
- if (typeof value === "number") {
- // Convert scientific notation to normal decimal
- const normalNumber = Number(value);
-
- // If it's a whole number, return it without decimals
- if (normalNumber === Math.floor(normalNumber)) {
- return normalNumber.toString();
- }
-
- // For decimal numbers, use toFixed and remove trailing zeros
- return formatNumberWithCommas(normalNumber, 8).replace(/\.?0+$/, "");
- }
-
- return "0";
- };
-
- // Helper function to get spend for a user
- const getUserSpend = (userId: string | null): number | null => {
- if (!userId) return 0;
- const membership = teamData.team_memberships.find((tm) => tm.user_id === userId);
- return membership?.spend || 0;
- };
-
- const getUserBudget = (userId: string | null): string | null => {
- if (!userId) return null;
- const membership = teamData.team_memberships.find((tm) => tm.user_id === userId);
- console.log(`membership=${membership}`);
- const maxBudget = membership?.litellm_budget_table?.max_budget;
- if (maxBudget === null || maxBudget === undefined) {
- return null;
- }
- return formatNumber(maxBudget);
- };
-
- // Helper function to get rate limits for a user
- const getUserRateLimits = (userId: string | null): string => {
- if (!userId) return "No Limits";
- const membership = teamData.team_memberships.find((tm) => tm.user_id === userId);
- const rpmLimit = membership?.litellm_budget_table?.rpm_limit;
- const tpmLimit = membership?.litellm_budget_table?.tpm_limit;
-
- const rpmText = rpmLimit ? `${formatNumber(rpmLimit)} RPM` : null;
- const tpmText = tpmLimit ? `${formatNumber(tpmLimit)} TPM` : null;
-
- const limits = [rpmText, tpmText].filter(Boolean);
- return limits.length > 0 ? limits.join(" / ") : "No Limits";
- };
-
- const { data: uiSettingsData } = useUISettings();
- const { userId, userRole } = useAuthorized();
- const disableTeamAdminDeleteTeamUser = Boolean(uiSettingsData?.values?.disable_team_admin_delete_team_user);
- const isUserTeamAdmin = isUserTeamAdminForSingleTeam(teamData.team_info.members_with_roles, userId || "");
- const isProxyAdmin = isProxyAdminRole(userRole || "");
-
- return (
- <div className="space-y-4">
- <Card className="w-full mx-auto flex-auto overflow-auto max-h-[50vh]">
- <div className="overflow-x-auto">
- <Table className="min-w-full">
- <TableHead>
- <TableRow>
- <TableHeaderCell>User ID</TableHeaderCell>
- <TableHeaderCell>User Email</TableHeaderCell>
- <TableHeaderCell>Role</TableHeaderCell>
- <TableHeaderCell>
- Team Member Spend (USD){" "}
- <Tooltip title="This is the amount spent by a user in the team.">
- <InfoCircleOutlined />
- </Tooltip>
- </TableHeaderCell>
- <TableHeaderCell>Team Member Budget (USD)</TableHeaderCell>
- <TableHeaderCell>
- Team Member Rate Limits{" "}
- <Tooltip title="Rate limits for this member's usage within this team.">
- <InfoCircleOutlined />
- </Tooltip>
- </TableHeaderCell>
- <TableHeaderCell className="sticky right-0 bg-white z-10 border-l border-gray-200">
- Actions
- </TableHeaderCell>
- </TableRow>
- </TableHead>
-
- <TableBody>
- {teamData.team_info.members_with_roles.map((member: Member, index: number) => (
- <TableRow key={index}>
- <TableCell>
- <Text className="font-mono">{member.user_id}</Text>
- </TableCell>
- <TableCell>
- <Text className="font-mono">{member.user_email ? member.user_email : "No Email"}</Text>
- </TableCell>
- <TableCell>
- <Text className="font-mono">{member.role}</Text>
- </TableCell>
- <TableCell>
- <Text className="font-mono">${formatNumberWithCommas(getUserSpend(member.user_id), 4)}</Text>
- </TableCell>
- <TableCell>
- <Text className="font-mono">
- {getUserBudget(member.user_id)
- ? `$${formatNumberWithCommas(Number(getUserBudget(member.user_id)), 4)}`
- : "No Limit"}
- </Text>
- </TableCell>
- <TableCell>
- <Text className="font-mono">{getUserRateLimits(member.user_id)}</Text>
- </TableCell>
- <TableCell className="sticky right-0 bg-white z-10 border-l border-gray-200">
- {canEditTeam && (
- <div className="flex gap-2">
- <TableIconActionButton
- variant="Edit"
- tooltipText="Edit member"
- onClick={() => {
- // Get budget and rate limit data from team membership
- const membership = teamData.team_memberships.find((tm) => tm.user_id === member.user_id);
- const enhancedMember = {
- ...member,
- max_budget_in_team: membership?.litellm_budget_table?.max_budget || null,
- tpm_limit: membership?.litellm_budget_table?.tpm_limit || null,
- rpm_limit: membership?.litellm_budget_table?.rpm_limit || null,
- };
- setSelectedEditMember(enhancedMember);
- setIsEditMemberModalVisible(true);
- }}
- />
- {(isProxyAdmin || (isUserTeamAdmin && !disableTeamAdminDeleteTeamUser)) && (
- <TableIconActionButton
- variant="Delete"
- tooltipText="Delete member"
- onClick={() => handleMemberDelete(member)}
- />
- )}
- </div>
- )}
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </div>
- </Card>
- <TremorButton onClick={() => setIsAddMemberModalVisible(true)}>Add Member</TremorButton>
- </div>
- );
-};
-
-export default TeamMembersComponent;