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(ui): remove dead useKeyList hook from key_list.tsx

mateob46bc2130951
diff --git a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
index d8c331110c0..ad357f5925d 100644
--- a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
+++ b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
@@ -1,6 +1,4 @@
-import { Setter } from "@/types";
-import { useEffect, useState } from "react";
-import { keyListCall, Member, Organization } from "../networking";
+import { Member } from "../networking";
import type { ObjectPermission } from "../object_permission_types";
import type { ModelBudgetUsage, ModelMaxBudget } from "./ModelMaxBudgetEditor";
@@ -126,114 +124,3 @@ export interface KeyResponse {
user_alias: string | null;
};
}
-
-interface KeyListResponse {
- keys: KeyResponse[];
- total_count: number;
- current_page: number;
- total_pages: number;
-}
-
-interface UseKeyListProps {
- selectedTeam?: Team;
- currentOrg: Organization | null;
- selectedKeyAlias: string | null;
- accessToken: string;
- createClicked: boolean;
- expand?: string[];
-}
-
-interface PaginationData {
- currentPage: number;
- totalPages: number;
- totalCount: number;
-}
-
-interface UseKeyListReturn {
- keys: KeyResponse[];
- isLoading: boolean;
- error: Error | null;
- pagination: PaginationData;
- refresh: (params?: Record<string, unknown>) => Promise<void>;
- setKeys: Setter<KeyResponse[]>;
-}
-
-const useKeyList = ({
- selectedTeam,
- currentOrg,
- selectedKeyAlias,
- accessToken,
- createClicked,
- expand = [],
-}: UseKeyListProps): UseKeyListReturn => {
- const [keyData, setKeyData] = useState<KeyListResponse>({
- keys: [],
- total_count: 0,
- current_page: 1,
- total_pages: 0,
- });
- const [isLoading, setIsLoading] = useState<boolean>(true);
- const [error, setError] = useState<Error | null>(null);
-
- const fetchKeys = async (params: Record<string, unknown> = {}): Promise<void> => {
- try {
- if (!accessToken) {
- return;
- }
- setIsLoading(true);
-
- const page = typeof params.page === "number" ? params.page : 1;
- const pageSize = typeof params.pageSize === "number" ? params.pageSize : 100;
-
- const data = await keyListCall(
- accessToken,
- null,
- null,
- null,
- null,
- null,
- page,
- pageSize,
- null,
- null,
- expand.join(","),
- );
- setKeyData(data);
- setError(null);
- } catch (err) {
- setError(err instanceof Error ? err : new Error("An error occurred"));
- } finally {
- setIsLoading(false);
- }
- };
-
- useEffect(() => {
- fetchKeys();
- }, [selectedTeam, currentOrg, accessToken, selectedKeyAlias, createClicked]);
-
- const setKeys = (newKeysOrUpdater: KeyResponse[] | ((prevKeys: KeyResponse[]) => KeyResponse[])) => {
- setKeyData((prevData) => {
- const newKeys = typeof newKeysOrUpdater === "function" ? newKeysOrUpdater(prevData.keys) : newKeysOrUpdater;
-
- return {
- ...prevData,
- keys: newKeys,
- };
- });
- };
-
- return {
- keys: keyData.keys,
- isLoading,
- error,
- pagination: {
- currentPage: keyData.current_page,
- totalPages: keyData.total_pages,
- totalCount: keyData.total_count,
- },
- refresh: fetchKeys,
- setKeys,
- };
-};
-
-export default useKeyList;