diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/policies/usePolicyVersions.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/policies/usePolicyVersions.test.ts index 438246eab07..f773614388f 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/policies/usePolicyVersions.test.ts +++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/policies/usePolicyVersions.test.ts @@ -96,6 +96,8 @@ describe("usePolicyVersions", () => { ); expect(result.current.fetchStatus).toBe("idle"); + // isLoading (not isPending) must be false when query is disabled + expect(result.current.isLoading).toBe(false); expect(mockListPolicyVersions).not.toHaveBeenCalled(); }); @@ -106,6 +108,8 @@ describe("usePolicyVersions", () => { ); expect(result.current.fetchStatus).toBe("idle"); + // isLoading (not isPending) must be false when query is disabled + expect(result.current.isLoading).toBe(false); expect(mockListPolicyVersions).not.toHaveBeenCalled(); }); diff --git a/ui/litellm-dashboard/src/components/policies/pipeline_flow_builder.tsx b/ui/litellm-dashboard/src/components/policies/pipeline_flow_builder.tsx index 6dc235e459e..6984948271e 100644 --- a/ui/litellm-dashboard/src/components/policies/pipeline_flow_builder.tsx +++ b/ui/litellm-dashboard/src/components/policies/pipeline_flow_builder.tsx @@ -1305,7 +1305,7 @@ export const FlowBuilderPage: React.FC = ({ const { data: versionsData, - isPending: isVersionsLoading, + isLoading: isVersionsLoading, } = usePolicyVersions({ policyName: editingPolicy?.policy_name, enabled: showVersionsSidebar, @@ -1316,8 +1316,12 @@ export const FlowBuilderPage: React.FC = ({ const updateStatusMutation = useUpdatePolicyVersionStatus(editingPolicy?.policy_name); const handleNewVersion = async () => { - const newPolicy = await createVersionMutation.mutateAsync(); - onVersionCreated?.(newPolicy); + try { + const newPolicy = await createVersionMutation.mutateAsync(); + onVersionCreated?.(newPolicy); + } catch { + // Notification already shown by onError in the mutation hook + } }; const handleSelectVersion = (policy: Policy) => { @@ -1326,20 +1330,28 @@ export const FlowBuilderPage: React.FC = ({ const handlePublishVersion = async () => { if (!editingPolicy?.policy_id) return; - const updated = await updateStatusMutation.mutateAsync({ - policyId: editingPolicy.policy_id, - status: "published", - }); - onVersionStatusUpdated?.(updated); + try { + const updated = await updateStatusMutation.mutateAsync({ + policyId: editingPolicy.policy_id, + status: "published", + }); + onVersionStatusUpdated?.(updated); + } catch { + // Notification already shown by onError in the mutation hook + } }; const handlePromoteToProduction = async () => { if (!editingPolicy?.policy_id) return; - const updated = await updateStatusMutation.mutateAsync({ - policyId: editingPolicy.policy_id, - status: "production", - }); - onVersionStatusUpdated?.(updated); + try { + const updated = await updateStatusMutation.mutateAsync({ + policyId: editingPolicy.policy_id, + status: "production", + }); + onVersionStatusUpdated?.(updated); + } catch { + // Notification already shown by onError in the mutation hook + } }; const handleSave = async () => {