diff --git a/ui/litellm-dashboard/.eslintrc.json b/ui/litellm-dashboard/.eslintrc.json index 3ec2a72eaad..760b215c757 100644 --- a/ui/litellm-dashboard/.eslintrc.json +++ b/ui/litellm-dashboard/.eslintrc.json @@ -68,6 +68,7 @@ "src/components/mcp_tools/MCPPermissionManagement.tsx", "src/components/model_add/credentials.tsx", "src/components/model_dashboard/health_check_columns.tsx", + "src/components/UsagePage/components/EntityUsage/TopKeyView.tsx", "src/components/permissions/VectorStorePermissions.tsx", "src/components/permissions/AgentPermissions.tsx", "src/components/permissions/MCPServerPermissions.tsx", diff --git a/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/TopKeyView.tsx b/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/TopKeyView.tsx index 8903f74f232..484aa0fcb18 100644 --- a/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/TopKeyView.tsx +++ b/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/TopKeyView.tsx @@ -1,7 +1,15 @@ import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized"; -import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/outline"; -import { BarChart, Button } from "@tremor/react"; -import { Segmented, Tooltip } from "antd"; +import { ChevronDown, ChevronUp, X } from "lucide-react"; +// eslint-disable-next-line litellm-ui/no-banned-ui-imports +import { BarChart } from "@tremor/react"; +import { Segmented } from "antd"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; +import { cn } from "@/lib/utils"; import React, { useState } from "react"; import { formatNumberWithCommas } from "../../../../utils/dataUtils"; import { transformKeyInfo } from "../../../key_team_helpers/transform_key_info"; @@ -11,7 +19,9 @@ import { DataTable } from "../../../view_logs/table"; import { TagUsage } from "../../types"; interface TopKeyViewProps { + // eslint-disable-next-line @typescript-eslint/no-explicit-any topKeys: any[]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any teams: any[] | null; showTags?: boolean; topKeysLimit: number; @@ -22,6 +32,7 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals const { accessToken, userRole, userId: userID, premiumUser } = useAuthorized(); const [isModalOpen, setIsModalOpen] = useState(false); const [selectedKey, setSelectedKey] = useState(null); + // eslint-disable-next-line @typescript-eslint/no-explicit-any const [keyData, setKeyData] = useState(undefined); const [viewMode, setViewMode] = useState<"chart" | "table">("table"); const [expandedTags, setExpandedTags] = useState>(new Set()); @@ -38,6 +49,7 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals }); }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const handleKeyClick = async (item: any) => { if (!accessToken) return; @@ -83,24 +95,32 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals { header: "Key ID", accessorKey: "api_key", + // eslint-disable-next-line @typescript-eslint/no-explicit-any cell: (info: any) => (
- - - + + + + + + {info.getValue() as string} + +
), }, { header: "Key Alias", accessorKey: "key_alias", + // eslint-disable-next-line @typescript-eslint/no-explicit-any cell: (info: any) => info.getValue() || "-", }, ]; @@ -108,6 +128,7 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals const tagsColumn = { header: "Tags", accessorKey: "tags", + // eslint-disable-next-line @typescript-eslint/no-explicit-any cell: (info: any) => { const tags = info.getValue() as TagUsage[] | undefined; const apiKey = info.row.original.api_key; @@ -125,33 +146,43 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals
{displayTags.map((tag, index) => ( - + + + + + {tag.tag.slice(0, 7)}... + + +
- Tag Name: {tag.tag} +
+ + Tag Name: + {" "} + {tag.tag} +
+
+ Spend:{" "} + {tag.usage > 0 && tag.usage < 0.01 + ? "<$0.01" + : `$${formatNumberWithCommas(tag.usage, 2)}`} +
-
- Spend:{" "} - {tag.usage > 0 && tag.usage < 0.01 ? "<$0.01" : `$${formatNumberWithCommas(tag.usage, 2)}`} -
-
- } - > - {tag.tag.slice(0, 7)}... - + + + ))} {hasMoreTags && ( )} @@ -164,9 +195,12 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals const spendColumn = { header: "Spend (USD)", accessorKey: "spend", + // eslint-disable-next-line @typescript-eslint/no-explicit-any cell: (info: any) => { const value = info.getValue(); - return value > 0 && value < 0.01 ? "<$0.01" : `$${formatNumberWithCommas(value, 2)}`; + return value > 0 && value < 0.01 + ? "<$0.01" + : `$${formatNumberWithCommas(value, 2)}`; }, }; @@ -192,14 +226,26 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals />
@@ -246,7 +292,7 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals />
) : ( -
+
= ({ topKeys, teams, showTags = fals
)} - {isModalOpen && - selectedKey && - keyData && - (console.log("Rendering modal with:", { isModalOpen, selectedKey, keyData }), - ( -
-
- {/* Close button */} - + {isModalOpen && selectedKey && keyData && ( +
+
+ - {/* Content */} -
- -
+
+
- ))} +
+ )} ); };