Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useDeleteProxyConfigField,
getProxyConfigCall,
deleteProxyConfigFieldCall,
proxyConfigKeys,
ConfigType,
GeneralSettingsFieldName,
type ProxyConfigResponse,
Expand Down Expand Up @@ -426,6 +427,28 @@ describe("useDeleteProxyConfigField", () => {

expect(result.current.error).toBeDefined();
});

it("should invalidate proxyConfig queries after a successful delete", async () => {
(fetchSpy as any).mockResolvedValue({
ok: true,
json: async () => mockDeleteResponse,
});

const invalidateSpy = vi.spyOn(queryClient, "invalidateQueries");

const { result } = renderHook(() => useDeleteProxyConfigField(), { wrapper });

result.current.mutate({
config_type: ConfigType.GENERAL_SETTINGS,
field_name: GeneralSettingsFieldName.MAXIMUM_SPEND_LOGS_RETENTION_PERIOD,
});

await waitFor(() => {
expect(result.current.isSuccess).toBe(true);
});

expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: proxyConfigKeys.all });
});
});

describe("getProxyConfigCall", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useQuery, useMutation, UseMutationResult } from "@tanstack/react-query";
import { useQuery, useMutation, UseMutationResult, useQueryClient } from "@tanstack/react-query";
import { createQueryKeys } from "../common/queryKeysFactory";
import useAuthorized from "../useAuthorized";
import { proxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage, handleError } from "@/components/networking";
Expand Down Expand Up @@ -101,7 +101,7 @@ export const getProxyConfigCall = async (accessToken: string, configType: Config
}
};

const proxyConfigKeys = createQueryKeys("proxyConfig");
export const proxyConfigKeys = createQueryKeys("proxyConfig");

/**
* Network call function to delete a proxy config field
Expand Down Expand Up @@ -168,6 +168,7 @@ export const useDeleteProxyConfigField = (): UseMutationResult<
DeleteProxyConfigFieldRequest
> => {
const { accessToken } = useAuthorized();
const queryClient = useQueryClient();

return useMutation<DeleteProxyConfigFieldResponse, Error, DeleteProxyConfigFieldRequest>({
mutationFn: async (request: DeleteProxyConfigFieldRequest) => {
Expand All @@ -176,5 +177,8 @@ export const useDeleteProxyConfigField = (): UseMutationResult<
}
return await deleteProxyConfigFieldCall(accessToken, request);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: proxyConfigKeys.all });
},
});
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useMutation, UseMutationResult } from "@tanstack/react-query";
import { useMutation, UseMutationResult, useQueryClient } from "@tanstack/react-query";
import { getProxyBaseUrl, getGlobalLitellmHeaderName } from "@/components/networking";
import useAuthorized from "../useAuthorized";
import { proxyConfigKeys } from "../proxyConfig/useProxyConfig";

export interface StoreRequestInSpendLogsParams {
store_prompts_in_spend_logs: boolean;
Expand Down Expand Up @@ -51,6 +52,7 @@ export const useStoreRequestInSpendLogs = (): UseMutationResult<
StoreRequestInSpendLogsParams
> => {
const { accessToken } = useAuthorized();
const queryClient = useQueryClient();

return useMutation<StoreRequestInSpendLogsResponse, Error, StoreRequestInSpendLogsParams>({
mutationFn: async (params: StoreRequestInSpendLogsParams) => {
Expand All @@ -59,5 +61,8 @@ export const useStoreRequestInSpendLogs = (): UseMutationResult<
}
return await performStoreRequestInSpendLogs(accessToken, params);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: proxyConfigKeys.all });
},
});
};
6 changes: 6 additions & 0 deletions ui/litellm-dashboard/src/components/AdminPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useBaseUrl } from "./constants";
import NotificationsManager from "./molecules/notifications_manager";
import { addAllowedIP, deleteAllowedIP, getAllowedIPs, getSSOSettings } from "./networking";
import SCIMConfig from "./SCIM";
import LoggingSettings from "./Settings/AdminSettings/LoggingSettings/LoggingSettings";
import SSOSettings from "./Settings/AdminSettings/SSOSettings/SSOSettings";
import UISettings from "./Settings/AdminSettings/UISettings/UISettings";
import HashicorpVault from "./Settings/AdminSettings/HashicorpVault/HashicorpVault";
Expand Down Expand Up @@ -362,6 +363,11 @@ const AdminPanel: React.FC<AdminPanelProps> = ({ proxySettings }) => {
),
children: <UISettings />,
},
{
key: "logging-settings",
label: "Logging Settings",
children: <LoggingSettings />,
},
{
key: "hashicorp-vault",
label: "Hashicorp Vault",
Expand Down
Loading
Loading