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): codemod every toast call site onto lib/toast and delete the antd-era facades (#37253)

ryan-crabbe-berri83ae62373377
diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.json
index c3b2bb03f11..e83c2d678ed 100644
--- a/ui/litellm-dashboard/eslint-suppressions.json
+++ b/ui/litellm-dashboard/eslint-suppressions.json
@@ -2497,16 +2497,6 @@
"count": 1
}
},
- "src/components/molecules/message_manager.tsx": {
- "local/filename-pascal-case": {
- "count": 1
- }
- },
- "src/components/molecules/notifications_manager.tsx": {
- "local/filename-pascal-case": {
- "count": 1
- }
- },
"src/components/navbar.tsx": {
"local/filename-pascal-case": {
"count": 1
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/AccessGroupsModal/AccessGroupEditModal.tsx b/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/AccessGroupsModal/AccessGroupEditModal.tsx
index ec557260aa5..c65f8bf951f 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/AccessGroupsModal/AccessGroupEditModal.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/AccessGroupsModal/AccessGroupEditModal.tsx
@@ -1,6 +1,6 @@
import React, { useEffect } from "react";
import { Modal, Form } from "antd";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { AccessGroupBaseForm, AccessGroupFormValues } from "./AccessGroupBaseForm";
import { useEditAccessGroup, AccessGroupUpdateParams } from "@/app/(dashboard)/hooks/accessGroups/useEditAccessGroup";
import { AccessGroupResponse } from "@/app/(dashboard)/hooks/accessGroups/useAccessGroups";
@@ -45,7 +45,7 @@ export function AccessGroupEditModal({ visible, accessGroup, onCancel, onSuccess
{ accessGroupId: accessGroup.access_group_id, params },
{
onSuccess: () => {
- MessageManager.success("Access group updated successfully");
+ toast.success("Access group updated successfully");
onSuccess?.();
onCancel();
},
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-create/AccessGroupCreateDialog.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-create/AccessGroupCreateDialog.test.tsx
index 8547610ee60..7a006efce1e 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-create/AccessGroupCreateDialog.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-create/AccessGroupCreateDialog.test.tsx
@@ -4,10 +4,6 @@ import userEvent from "@testing-library/user-event";
import React from "react";
import { describe, expect, it, vi } from "vitest";
-vi.mock("@/components/molecules/notifications_manager", () => ({
- __esModule: true,
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
vi.mock("@/components/ModelSelect/ModelSelect", () => ({
ModelSelect: ({ onChange }: { onChange: (values: string[]) => void }) => (
<button type="button" onClick={() => onChange(["gpt-5.2"])}>
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-create/AccessGroupCreateDialog.tsx b/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-create/AccessGroupCreateDialog.tsx
index 3f2205b4206..624c85cc818 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-create/AccessGroupCreateDialog.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-create/AccessGroupCreateDialog.tsx
@@ -8,7 +8,7 @@ import { accessGroupKeys } from "@/app/(dashboard)/hooks/accessGroups/useAccessG
import { useAgents } from "@/app/(dashboard)/hooks/agents/useAgents";
import { useMCPServers } from "@/app/(dashboard)/hooks/mcpServers/useMCPServers";
import { ModelSelect } from "@/components/ModelSelect/ModelSelect";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { FieldGroup } from "@/components/shared/form/field";
import { FormField } from "@/components/shared/form/FormField";
import { Button } from "@/components/ui/button";
@@ -113,12 +113,12 @@ export const AccessGroupCreateDialog = ({
const mutation = useMutation({
mutationFn: (body: AccessGroupCreateBody) => createAccessGroup(body),
onSuccess: () => {
- NotificationsManager.success("Access group created successfully");
+ toast.success("Access group created successfully");
queryClient.invalidateQueries({ queryKey: accessGroupKeys.all });
closeAndReset();
},
onError: (error: unknown) =>
- NotificationsManager.fromBackend(error instanceof Error ? error.message : "Failed to create access group"),
+ toast.fromError(error instanceof Error ? error.message : "Failed to create access group"),
});
const handleOpenChange = (nextOpen: boolean) => {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/admin-panel/_components/AdminPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/admin-panel/_components/AdminPanel.tsx
index 6af9d65b994..9c1343ccbea 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/admin-panel/_components/AdminPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/admin-panel/_components/AdminPanel.tsx
@@ -18,7 +18,7 @@ import { Alert, Button as Button2, Form, Input, Modal, Space, Tabs, Typography }
import React, { useEffect, useState } from "react";
import NewBadge from "@/components/common_components/NewBadge";
import { useBaseUrl } from "@/components/constants";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { addAllowedIP, deleteAllowedIP, getAllowedIPs, getSSOSettings } from "@/components/networking";
import SCIMConfig from "@/components/SCIM";
import LoggingSettings from "@/components/Settings/AdminSettings/LoggingSettings/LoggingSettings";
@@ -79,9 +79,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({ proxySettings }) => {
const handleShowAllowedIPs = async () => {
try {
if (premiumUser !== true) {
- NotificationsManager.fromBackend(
- "This feature is only available for premium users. Please upgrade your account.",
- );
+ toast.fromError("This feature is only available for premium users. Please upgrade your account.");
return;
}
if (accessToken) {
@@ -92,7 +90,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({ proxySettings }) => {
}
} catch (error) {
console.error("Error fetching allowed IPs:", error);
- NotificationsManager.fromBackend(`Failed to fetch allowed IPs ${error}`);
+ toast.fromError(`Failed to fetch allowed IPs ${error}`);
setAllowedIPs([all_ip_address_allowed]);
} finally {
if (premiumUser === true) {
@@ -108,11 +106,11 @@ const AdminPanel: React.FC<AdminPanelProps> = ({ proxySettings }) => {
// Fetch the updated list of IPs
const updatedIPs = await getAllowedIPs(accessToken);
setAllowedIPs(updatedIPs);
- NotificationsManager.success("IP address added successfully");
+ toast.success("IP address added successfully");
}
} catch (error) {
console.error("Error adding IP:", error);
- NotificationsManager.fromBackend(`Failed to add IP address ${error}`);
+ toast.fromError(`Failed to add IP address ${error}`);
} finally {
setIsAddIPModalVisible(false);
}
@@ -130,10 +128,10 @@ const AdminPanel: React.FC<AdminPanelProps> = ({ proxySettings }) => {
// Fetch the updated list of IPs
const updatedIPs = await getAllowedIPs(accessToken);
setAllowedIPs(updatedIPs.length > 0 ? updatedIPs : [all_ip_address_allowed]);
- NotificationsManager.success("IP address deleted successfully");
+ toast.success("IP address deleted successfully");
} catch (error) {
console.error("Error deleting IP:", error);
- NotificationsManager.fromBackend(`Failed to delete IP address ${error}`);
+ toast.fromError(`Failed to delete IP address ${error}`);
} finally {
setIsDeleteIPModalVisible(false);
setIPToDelete(null);
@@ -229,7 +227,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({ proxySettings }) => {
onClick={() =>
premiumUser === true
? setIsUIAccessControlModalVisible(true)
- : NotificationsManager.fromBackend("Only premium users can configure UI access control")
+ : toast.fromError("Only premium users can configure UI access control")
}
>
UI Access Control
@@ -335,7 +333,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({ proxySettings }) => {
accessToken={accessToken}
onSuccess={() => {
handleUIAccessControlOk();
- NotificationsManager.success("UI Access Control settings updated successfully");
+ toast.success("UI Access Control settings updated successfully");
}}
/>
</Modal>
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/AgentsPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/AgentsPanel.tsx
index 4459ee0c377..f53b03b6a08 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/AgentsPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/AgentsPanel.tsx
@@ -5,7 +5,7 @@ import AddAgentForm from "./add_agent_form";
import { isAdminRole } from "@/utils/roles";
import AgentInfoView from "./agent_info";
import AgentsTable from "./AgentsTable";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Agent } from "@/components/agents/types";
import { Team } from "@/components/key_team_helpers/key_list";
import { Alert, AlertDescription, AlertTitle } from "@/components/shared/Alert";
@@ -120,11 +120,11 @@ const AgentsPanel: React.FC<AgentsPanelProps> = ({ accessToken, userRole, teams
setIsDeleting(true);
try {
await deleteAgentCall(accessToken, agentToDelete.id);
- NotificationsManager.success(`Agent "${agentToDelete.name}" deleted successfully`);
+ toast.success(`Agent "${agentToDelete.name}" deleted successfully`);
await refetchAgents(healthCheckEnabled);
} catch (error) {
console.error("Error deleting agent:", error);
- NotificationsManager.fromBackend("Failed to delete agent");
+ toast.fromError("Failed to delete agent");
} finally {
setIsDeleting(false);
setAgentToDelete(null);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/add_agent_form.tsx b/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/add_agent_form.tsx
index 677ba9e6285..7bd6b68a26d 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/add_agent_form.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/add_agent_form.tsx
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import { Modal, Form, Select, Input, Steps, Radio, Tag, Divider, Switch, InputNumber } from "antd";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { Logo } from "@/components/molecules/logo/Logo";
import { Button } from "@tremor/react";
import { CheckCircleFilled, KeyOutlined, RobotOutlined, AppstoreOutlined, InfoCircleOutlined } from "@ant-design/icons";
@@ -241,7 +241,7 @@ const AddAgentForm: React.FC<AddAgentFormProps> = ({ visible, onClose, accessTok
const handleCreateAgent = async () => {
if (!accessToken) {
- MessageManager.error("No access token available");
+ toast.error("No access token available");
return;
}
@@ -251,7 +251,7 @@ const AddAgentForm: React.FC<AddAgentFormProps> = ({ visible, onClose, accessTok
const values = { ...form.getFieldsValue(true) };
const agentData = buildAgentData(values);
if (!agentData) {
- MessageManager.error("Failed to build agent data");
+ toast.error("Failed to build agent data");
setIsSubmitting(false);
return;
}
@@ -327,7 +327,7 @@ const AddAgentForm: React.FC<AddAgentFormProps> = ({ visible, onClose, accessTok
setCreatedKeyValue(keyResponse.key || null);
} else if (keyAssignOption === "existing_key") {
if (!selectedExistingKey) {
- MessageManager.error("Please select an existing key to assign");
+ toast.error("Please select an existing key to assign");
setIsSubmitting(false);
return;
}
@@ -344,7 +344,7 @@ const AddAgentForm: React.FC<AddAgentFormProps> = ({ visible, onClose, accessTok
} catch (error) {
console.error("Error creating agent:", error);
const errorMessage = error instanceof Error ? error.message : String(error);
- MessageManager.error(errorMessage ? `Failed to create agent: ${errorMessage}` : "Failed to create agent");
+ toast.error(errorMessage ? `Failed to create agent: ${errorMessage}` : "Failed to create agent");
} finally {
setIsSubmitting(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/agent_info.tsx b/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/agent_info.tsx
index d82ef82df8c..f97a370a96a 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/agent_info.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/agents/_components/agent_info.tsx
@@ -1,7 +1,7 @@
import React, { useState, useEffect, useMemo } from "react";
import { Card, Title, Text, Button as TremorButton, Tab, TabGroup, TabList, TabPanel, TabPanels } from "@tremor/react";
import { Form, Input, InputNumber, Button as AntButton, Spin, Descriptions, Divider } from "antd";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { ArrowLeftIcon } from "@heroicons/react/outline";
import { getAgentInfo, patchAgentCall, getAgentCreateMetadata, AgentCreateInfo } from "@/components/networking";
import { Agent } from "@/components/agents/types";
@@ -80,7 +80,7 @@ const AgentInfoView: React.FC<AgentInfoViewProps> = ({ agentId, onClose, accessT
}
} catch (error) {
console.error("Error fetching agent info:", error);
- MessageManager.error("Failed to load agent information");
+ toast.error("Failed to load agent information");
} finally {
setIsLoading(false);
}
@@ -160,12 +160,12 @@ const AgentInfoView: React.FC<AgentInfoViewProps> = ({ agentId, onClose, accessT
}
await patchAgentCall(accessToken, agentId, updateData);
- MessageManager.success("Agent updated successfully");
+ toast.success("Agent updated successfully");
setIsEditing(false);
fetchAgentInfo();
} catch (error) {
console.error("Error updating agent:", error);
- MessageManager.error("Failed to update agent");
+ toast.error("Failed to update agent");
} finally {
setIsSaving(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_modal.tsx b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_modal.tsx
index a0ca8bc7ae9..fd657376066 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_modal.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_modal.tsx
@@ -4,7 +4,7 @@ import { Modal } from "antd";
import { z } from "zod/v4";
import { useCreateBudget } from "@/app/(dashboard)/hooks/budgets/useBudgets";
import { applyBudgetPrecision } from "./budgetPrecision";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { FieldGroup } from "@/components/shared/form/field";
import { FormField } from "@/components/shared/form/FormField";
import { Button } from "@/components/ui/button";
@@ -52,18 +52,18 @@ const BudgetModal: React.FC<BudgetModalProps> = ({ isModalVisible, setIsModalVis
const handleCreate = async (formValues: BudgetFormValues) => {
try {
- NotificationsManager.info("Making API Call");
+ toast.info("Making API Call");
await createBudget.mutateAsync(
applyBudgetPrecision(
optionalSettingsOpen ? formValues : { ...formValues, max_budget: undefined, budget_duration: undefined },
),
);
- NotificationsManager.success("Budget Created");
+ toast.success("Budget Created");
form.reset();
setIsModalVisible(false);
} catch (error) {
console.error("Error creating the budget:", error);
- NotificationsManager.fromBackend(`Error creating the budget: ${error}`);
+ toast.fromError(`Error creating the budget: ${error}`);
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_panel.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_panel.test.tsx
index 46f72cd8886..e709732e908 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_panel.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_panel.test.tsx
@@ -25,10 +25,6 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
default: () => ({ accessToken: "sk-test", userRole: "Admin", userId: "u1" }),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), info: vi.fn(), fromBackend: vi.fn() },
-}));
-
interface BudgetSeed {
budget_id: string;
max_budget: number | null;
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_panel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_panel.tsx
index e49f0ffc722..1dbb0793735 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_panel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/budget_panel.tsx
@@ -11,7 +11,7 @@ import { ToolbarSeparator } from "@/components/shared/ToolbarSeparator";
import { Button } from "@/components/ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { useBudgetList, useDeleteBudget, budgetItem } from "@/app/(dashboard)/hooks/budgets/useBudgets";
import BudgetModal from "./budget_modal";
import BudgetTable from "./BudgetTable";
@@ -60,14 +60,10 @@ const BudgetPanel: React.FC<BudgetSettingsPageProps> = ({ accessToken }) => {
}
try {
await deleteBudget.mutateAsync(selectedBudget.budget_id);
- NotificationsManager.success("Budget deleted.");
+ toast.success("Budget deleted.");
} catch (error) {
console.error("Error deleting budget:", error);
- if (typeof NotificationsManager.fromBackend === "function") {
- NotificationsManager.fromBackend("Failed to delete budget");
- } else {
- NotificationsManager.info("Failed to delete budget");
- }
+ toast.fromError("Failed to delete budget");
} finally {
setIsDeleteModalVisible(false);
setSelectedBudget(null);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/edit_budget_modal.tsx b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/edit_budget_modal.tsx
index 1ed4e6b4f21..7ebab06cba6 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/edit_budget_modal.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/edit_budget_modal.tsx
@@ -5,7 +5,7 @@ import { useForm } from "react-hook-form";
import { useUpdateBudget } from "@/app/(dashboard)/hooks/budgets/useBudgets";
import { budgetItem } from "@/app/(dashboard)/hooks/budgets/useBudgets";
import { applyBudgetPrecision } from "./budgetPrecision";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { FieldGroup } from "@/components/shared/form/field";
import { FormField } from "@/components/shared/form/FormField";
import { Button } from "@/components/ui/button";
@@ -58,18 +58,18 @@ const EditBudgetModal: React.FC<EditBudgetModalProps> = ({ isModalVisible, setIs
const handleUpdate = async (formValues: EditBudgetFormValues) => {
try {
- NotificationsManager.info("Making API Call");
+ toast.info("Making API Call");
await updateBudget.mutateAsync(
applyBudgetPrecision(
optionalSettingsOpen ? formValues : { ...formValues, max_budget: undefined, budget_duration: undefined },
),
);
- NotificationsManager.success("Budget Updated");
+ toast.success("Budget Updated");
form.reset();
setIsModalVisible(false);
} catch (error) {
console.error("Error updating the budget:", error);
- NotificationsManager.fromBackend(`Error updating the budget: ${error}`);
+ toast.fromError(`Error updating the budget: ${error}`);
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_dashboard.tsx b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_dashboard.tsx
index c1a4968f58b..efdd4c479ee 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_dashboard.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_dashboard.tsx
@@ -1,6 +1,6 @@
import type { DateRangePickerValue } from "@/components/shared/date_picker_types";
import React, { useEffect, useState } from "react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import UsageDatePicker from "@/components/shared/usage_date_picker";
import { BarChart } from "@/components/shared/charts";
import { Button } from "@/components/ui/button";
@@ -104,7 +104,7 @@ const CacheDashboard: React.FC<CachePageProps> = ({ accessToken, token, userRole
const runCachingHealthCheck = async () => {
try {
- NotificationsManager.info("Running cache health check...");
+ toast.info("Running cache health check...");
setHealthCheckResponse("");
const response = await cachingHealthCheckCall(accessToken !== null ? accessToken : "");
setHealthCheckResponse(response);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_settings/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_settings/index.tsx
index fea2c04015b..ad3341bc171 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_settings/index.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/cache_settings/index.tsx
@@ -3,7 +3,7 @@ import { Button, Accordion, AccordionHeader, AccordionBody } from "@tremor/react
import { Form } from "antd";
import { getCacheSettingsCall, testCacheConnectionCall, updateCacheSettingsCall } from "@/components/networking";
import { fetchAvailableModels, ModelGroup } from "@/components/llm_calls/fetch_models";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import RedisTypeSelector from "./RedisTypeSelector";
import CacheFieldSection from "./CacheFieldSection";
import { EmbeddingModelOption } from "./CacheFormField";
@@ -39,7 +39,7 @@ const CacheSettings: React.FC<CacheSettingsProps> = ({ accessToken }) => {
setRedisType(toRedisType(currentValues.redis_type));
} catch (error) {
console.error("Failed to load cache settings:", error);
- NotificationsManager.fromBackend("Failed to load cache settings");
+ toast.fromError("Failed to load cache settings");
}
}, [accessToken, form]);
@@ -86,15 +86,13 @@ const CacheSettings: React.FC<CacheSettingsProps> = ({ accessToken }) => {
buildCachePayload(redisType, values, { forTesting: true }),
);
if (result.status === "success") {
- NotificationsManager.success("Cache connection test successful!");
+ toast.success("Cache connection test successful!");
} else {
- NotificationsManager.fromBackend(`Connection test failed: ${result.message || result.error}`);
+ toast.fromError(`Connection test failed: ${result.message || result.error}`);
}
} catch (error) {
console.error("Test connection error:", error);
- NotificationsManager.fromBackend(
- `Connection test failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
+ toast.fromError(`Connection test failed: ${error instanceof Error ? error.message : "Unknown error"}`);
} finally {
setIsTesting(false);
}
@@ -112,11 +110,11 @@ const CacheSettings: React.FC<CacheSettingsProps> = ({ accessToken }) => {
setIsSaving(true);
try {
await updateCacheSettingsCall(accessToken, buildCachePayload(redisType, values, { forTesting: false }));
- NotificationsManager.success("Cache settings updated successfully");
+ toast.success("Cache settings updated successfully");
await loadCacheSettings();
} catch (error) {
console.error("Failed to save cache settings:", error);
- NotificationsManager.fromBackend("Failed to update cache settings");
+ toast.fromError("Failed to update cache settings");
} finally {
setIsSaving(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/coordination_redis_settings/index.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/coordination_redis_settings/index.test.tsx
index 70149bba2d3..2ed6d9d4a90 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/coordination_redis_settings/index.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/coordination_redis_settings/index.test.tsx
@@ -5,7 +5,7 @@ import userEvent from "@testing-library/user-event";
import CoordinationRedisSettings from "./index";
import { REDACTED_VALUE } from "./types";
import * as networking from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
getCoordinationRedisSettingsCall: vi.fn(),
@@ -17,14 +17,10 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
default: () => ({ accessToken: "sk-test" }),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
const getSettings = vi.mocked(networking.getCoordinationRedisSettingsCall);
const updateSettings = vi.mocked(networking.updateCoordinationRedisSettingsCall);
const testConnection = vi.mocked(networking.testCoordinationRedisConnectionCall);
-const notifications = vi.mocked(NotificationsManager);
+const notifications = vi.mocked(toast);
const settingsResponse = (
values: Record<string, unknown>,
@@ -238,7 +234,7 @@ describe("CoordinationRedisSettings", () => {
await user.click(screen.getByRole("button", { name: /test connection/i }));
await waitFor(() =>
- expect(notifications.fromBackend).toHaveBeenCalledWith(expect.stringContaining("connection refused")),
+ expect(notifications.fromError).toHaveBeenCalledWith(expect.stringContaining("connection refused")),
);
expect(notifications.success).not.toHaveBeenCalled();
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/coordination_redis_settings/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/coordination_redis_settings/index.tsx
index 69727251afb..2ed1727eece 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/coordination_redis_settings/index.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/caching/_components/coordination_redis_settings/index.tsx
@@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useState } from "react";
import { Button, Form } from "antd";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { StatusBadge } from "@/components/shared/table_cells/status_badge";
import {
useCoordinationRedisSettings,
@@ -37,7 +37,7 @@ const CoordinationRedisSettings: React.FC = () => {
useEffect(() => {
if (isError) {
- NotificationsManager.fromBackend("Failed to load coordination Redis settings");
+ toast.fromError("Failed to load coordination Redis settings");
}
}, [isError]);
@@ -58,14 +58,12 @@ const CoordinationRedisSettings: React.FC = () => {
try {
const result = await testConnection.mutateAsync(buildCoordinationPayload(redisType, values));
if (result.status === "healthy") {
- NotificationsManager.success("Coordination Redis connection test successful!");
+ toast.success("Coordination Redis connection test successful!");
} else {
- NotificationsManager.fromBackend(`Connection test failed: ${result.error ?? "Unknown error"}`);
+ toast.fromError(`Connection test failed: ${result.error ?? "Unknown error"}`);
}
} catch (error) {
- NotificationsManager.fromBackend(
- `Connection test failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
+ toast.fromError(`Connection test failed: ${error instanceof Error ? error.message : "Unknown error"}`);
}
};
@@ -77,9 +75,9 @@ const CoordinationRedisSettings: React.FC = () => {
try {
await updateSettings.mutateAsync(buildCoordinationPayload(redisType, values));
- NotificationsManager.success("Coordination Redis settings saved. Restart the proxy to apply them.");
+ toast.success("Coordination Redis settings saved. Restart the proxy to apply them.");
} catch {
- NotificationsManager.fromBackend("Failed to update coordination Redis settings");
+ toast.fromError("Failed to update coordination Redis settings");
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTab.tsx b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTab.tsx
index 952e9f653ac..59b38f272e0 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTab.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTab.tsx
@@ -3,7 +3,7 @@
import React, { useCallback, useEffect, useState } from "react";
import { getGeneralSettingsCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
PromptCachingPanel,
generalSettingsItem,
@@ -27,7 +27,7 @@ const PromptCachingTab: React.FC<PromptCachingTabProps> = ({ accessToken, activi
.then((data: generalSettingsItem[]) => setSettings(data))
.catch((error) => {
console.error("Failed to load prompt caching settings:", error);
- NotificationsManager.fromBackend("Failed to load prompt caching settings");
+ toast.fromError("Failed to load prompt caching settings");
});
}, [accessToken]);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCompressionTab.tsx b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCompressionTab.tsx
index 071ad1d6bd5..3aab8c59259 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCompressionTab.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCompressionTab.tsx
@@ -5,7 +5,7 @@ import { Button, Form, Input, Switch } from "antd";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { createGuardrailCall, getGuardrailsList } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
buildCompressionGuardrailPayload,
compressionGuardrailsOf,
@@ -37,7 +37,7 @@ const PromptCompressionTab: React.FC<PromptCompressionTabProps> = ({ accessToken
.then((response) => setGuardrails(compressionGuardrailsOf(response as GuardrailListResponse)))
.catch((error) => {
console.error("Failed to load compression guardrails:", error);
- NotificationsManager.fromBackend("Failed to load compression guardrails");
+ toast.fromError("Failed to load compression guardrails");
})
.finally(() => setIsLoading(false));
}, [accessToken]);
@@ -60,12 +60,12 @@ const PromptCompressionTab: React.FC<PromptCompressionTabProps> = ({ accessToken
defaultOn: values.defaultOn ?? true,
}),
);
- NotificationsManager.success("Compression guardrail created");
+ toast.success("Compression guardrail created");
form.resetFields();
await loadGuardrails();
} catch (error) {
console.error("Failed to create compression guardrail:", error);
- NotificationsManager.fromBackend("Failed to create compression guardrail");
+ toast.fromError("Failed to create compression guardrail");
} finally {
setIsSaving(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/useShadowEval.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/useShadowEval.test.ts
index 13b24bc00fc..3b7e9dc04a0 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/useShadowEval.test.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/useShadowEval.test.ts
@@ -1,7 +1,6 @@
import { describe, expect, it, vi } from "vitest";
vi.mock("@/lib/http/api", () => ({ $api: { useQuery: vi.fn() }, fetchClient: { POST: vi.fn() } }));
-vi.mock("@/components/molecules/notifications_manager", () => ({ default: { fromBackend: vi.fn() } }));
import { shadowEvalListPollMs, shadowEvalPollMs } from "./useShadowEval";
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/useShadowEval.ts b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/useShadowEval.ts
index 027003df46f..7645fcc3346 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/useShadowEval.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/useShadowEval.ts
@@ -1,7 +1,7 @@
import { useMutation, useQueryClient, type QueryClient } from "@tanstack/react-query";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { $api, fetchClient } from "@/lib/http/api";
import type { components } from "@/lib/http/schema";
@@ -60,7 +60,7 @@ const useShadowEvalMutation = <TVariables>(mutationFn: (variables: TVariables) =
return useMutation({
mutationFn,
onSuccess: () => invalidateShadowEval(queryClient),
- onError: (error: unknown) => NotificationsManager.fromBackend(error),
+ onError: (error: unknown) => toast.fromError(error),
});
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_discount_config.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_discount_config.test.ts
index 0ab5f0b08c2..3d6fe014acf 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_discount_config.test.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_discount_config.test.ts
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { renderHook, act } from "@testing-library/react";
import { useDiscountConfig } from "./use_discount_config";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
getProxyBaseUrl: vi.fn(() => ""),
@@ -70,7 +70,7 @@ describe("useDiscountConfig", () => {
await result.current.fetchDiscountConfig();
});
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(expect.stringMatching(/failed to fetch/i));
+ expect(toast.fromError).toHaveBeenCalledWith(expect.stringMatching(/failed to fetch/i));
});
});
@@ -84,9 +84,7 @@ describe("useDiscountConfig", () => {
});
expect(success!).toBe(false);
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(
- "Please select a provider and enter discount percentage",
- );
+ expect(toast.fromError).toHaveBeenCalledWith("Please select a provider and enter discount percentage");
});
it("should return false and notify when no discount is provided", async () => {
@@ -98,9 +96,7 @@ describe("useDiscountConfig", () => {
});
expect(success!).toBe(false);
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(
- "Please select a provider and enter discount percentage",
- );
+ expect(toast.fromError).toHaveBeenCalledWith("Please select a provider and enter discount percentage");
});
it("should return false and notify when the discount exceeds 100", async () => {
@@ -112,7 +108,7 @@ describe("useDiscountConfig", () => {
});
expect(success!).toBe(false);
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(expect.stringMatching(/0%.*100%/i));
+ expect(toast.fromError).toHaveBeenCalledWith(expect.stringMatching(/0%.*100%/i));
});
it("should return false and notify when the provider already exists in the config", async () => {
@@ -135,7 +131,7 @@ describe("useDiscountConfig", () => {
});
expect(success!).toBe(false);
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(expect.stringMatching(/already exists/i));
+ expect(toast.fromError).toHaveBeenCalledWith(expect.stringMatching(/already exists/i));
});
it("should save the config and return true on a valid new provider", async () => {
@@ -156,7 +152,7 @@ describe("useDiscountConfig", () => {
});
expect(success!).toBe(true);
- expect(NotificationsManager.success).toHaveBeenCalledWith("Discount configuration updated successfully");
+ expect(toast.success).toHaveBeenCalledWith("Discount configuration updated successfully");
});
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_discount_config.ts b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_discount_config.ts
index c9b4f47a7b8..5c620a50c90 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_discount_config.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_discount_config.ts
@@ -1,6 +1,6 @@
import { useState, useCallback } from "react";
import { getProxyBaseUrl, getGlobalLitellmHeaderName } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { DiscountConfig } from "./types";
import { getProviderBackendValue } from "./provider_display_helpers";
import { Providers } from "@/components/provider_info_helpers";
@@ -43,7 +43,7 @@ export function useDiscountConfig({ accessToken }: UseDiscountConfigProps): UseD
}
} catch (error) {
console.error("Error fetching discount config:", error);
- NotificationsManager.fromBackend("Failed to fetch discount configuration");
+ toast.fromError("Failed to fetch discount configuration");
}
}, [accessToken]);
@@ -63,16 +63,16 @@ export function useDiscountConfig({ accessToken }: UseDiscountConfigProps): UseD
});
if (response.ok) {
- NotificationsManager.success("Discount configuration updated successfully");
+ toast.success("Discount configuration updated successfully");
await fetchDiscountConfig();
} else {
const errorData = await response.json();
const errorMessage = errorData.detail?.error || errorData.detail || "Failed to update settings";
- NotificationsManager.fromBackend(errorMessage);
+ toast.fromError(errorMessage);
}
} catch (error) {
console.error("Error updating discount config:", error);
- NotificationsManager.fromBackend("Failed to update discount configuration");
+ toast.fromError("Failed to update discount configuration");
}
},
[accessToken, fetchDiscountConfig],
@@ -81,25 +81,25 @@ export function useDiscountConfig({ accessToken }: UseDiscountConfigProps): UseD
const handleAddProvider = useCallback(
async (selectedProvider: string | undefined, newDiscount: string): Promise<boolean> => {
if (!selectedProvider || !newDiscount) {
- NotificationsManager.fromBackend("Please select a provider and enter discount percentage");
+ toast.fromError("Please select a provider and enter discount percentage");
return false;
}
const percentageValue = parseFloat(newDiscount);
if (isNaN(percentageValue) || percentageValue < 0 || percentageValue > 100) {
- NotificationsManager.fromBackend("Discount must be between 0% and 100%");
+ toast.fromError("Discount must be between 0% and 100%");
return false;
}
const providerValue = getProviderBackendValue(selectedProvider);
if (!providerValue) {
- NotificationsManager.fromBackend("Invalid provider selected");
+ toast.fromError("Invalid provider selected");
return false;
}
if (discountConfig[providerValue]) {
- NotificationsManager.fromBackend(
+ toast.fromError(
`Discount for ${Providers[selectedProvider as keyof typeof Providers]} already exists. Edit it in the table above.`,
);
return false;
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_margin_config.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_margin_config.test.ts
index 10db6a0e7fb..7b28ea75608 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_margin_config.test.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_margin_config.test.ts
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { renderHook, act } from "@testing-library/react";
import { useMarginConfig } from "./use_margin_config";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
getProxyBaseUrl: vi.fn(() => ""),
@@ -70,7 +70,7 @@ describe("useMarginConfig", () => {
await result.current.fetchMarginConfig();
});
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(expect.stringMatching(/failed to fetch/i));
+ expect(toast.fromError).toHaveBeenCalledWith(expect.stringMatching(/failed to fetch/i));
});
});
@@ -89,7 +89,7 @@ describe("useMarginConfig", () => {
});
expect(success!).toBe(false);
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith("Please select a provider");
+ expect(toast.fromError).toHaveBeenCalledWith("Please select a provider");
});
it("should return false and notify when percentage is out of range", async () => {
@@ -106,7 +106,7 @@ describe("useMarginConfig", () => {
});
expect(success!).toBe(false);
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(expect.stringMatching(/0%.*1000%/i));
+ expect(toast.fromError).toHaveBeenCalledWith(expect.stringMatching(/0%.*1000%/i));
});
it("should return false when the provider already has a margin configured", async () => {
@@ -134,7 +134,7 @@ describe("useMarginConfig", () => {
});
expect(success!).toBe(false);
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(expect.stringMatching(/already exists/i));
+ expect(toast.fromError).toHaveBeenCalledWith(expect.stringMatching(/already exists/i));
});
it("should save a percentage margin and return true for a valid new provider", async () => {
@@ -160,7 +160,7 @@ describe("useMarginConfig", () => {
});
expect(success!).toBe(true);
- expect(NotificationsManager.success).toHaveBeenCalledWith("Margin configuration updated successfully");
+ expect(toast.success).toHaveBeenCalledWith("Margin configuration updated successfully");
});
it("should save a fixed amount margin and return true for a valid new provider", async () => {
@@ -189,7 +189,7 @@ describe("useMarginConfig", () => {
});
expect(success!).toBe(true);
- expect(NotificationsManager.success).toHaveBeenCalledWith("Margin configuration updated successfully");
+ expect(toast.success).toHaveBeenCalledWith("Margin configuration updated successfully");
});
it("should accept the global provider without provider_map lookup", async () => {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_margin_config.ts b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_margin_config.ts
index 4994e9e6678..4f1e43166b1 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_margin_config.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/use_margin_config.ts
@@ -1,6 +1,6 @@
import { useState, useCallback } from "react";
import { getProxyBaseUrl, getGlobalLitellmHeaderName } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { MarginConfig } from "./types";
import { getProviderBackendValue } from "./provider_display_helpers";
import { Providers } from "@/components/provider_info_helpers";
@@ -53,7 +53,7 @@ export function useMarginConfig({ accessToken }: UseMarginConfigProps): UseMargi
}
} catch (error) {
console.error("Error fetching margin config:", error);
- NotificationsManager.fromBackend("Failed to fetch margin configuration");
+ toast.fromError("Failed to fetch margin configuration");
}
}, [accessToken]);
@@ -73,16 +73,16 @@ export function useMarginConfig({ accessToken }: UseMarginConfigProps): UseMargi
});
if (response.ok) {
- NotificationsManager.success("Margin configuration updated successfully");
+ toast.success("Margin configuration updated successfully");
await fetchMarginConfig();
} else {
const errorData = await response.json();
const errorMessage = errorData.detail?.error || errorData.detail || "Failed to update settings";
- NotificationsManager.fromBackend(errorMessage);
+ toast.fromError(errorMessage);
}
} catch (error) {
console.error("Error updating margin config:", error);
- NotificationsManager.fromBackend("Failed to update margin configuration");
+ toast.fromError("Failed to update margin configuration");
}
},
[accessToken, fetchMarginConfig],
@@ -93,7 +93,7 @@ export function useMarginConfig({ accessToken }: UseMarginConfigProps): UseMargi
const { selectedProvider, marginType, percentageValue, fixedAmountValue } = params;
if (!selectedProvider) {
- NotificationsManager.fromBackend("Please select a provider");
+ toast.fromError("Please select a provider");
return false;
}
@@ -103,7 +103,7 @@ export function useMarginConfig({ accessToken }: UseMarginConfigProps): UseMargi
} else {
const backendValue = getProviderBackendValue(selectedProvider);
if (!backendValue) {
- NotificationsManager.fromBackend("Invalid provider selected");
+ toast.fromError("Invalid provider selected");
return false;
}
providerValue = backendValue;
@@ -112,7 +112,7 @@ export function useMarginConfig({ accessToken }: UseMarginConfigProps): UseMargi
if (marginConfig[providerValue]) {
const displayName =
providerValue === "global" ? "Global" : Providers[selectedProvider as keyof typeof Providers];
- NotificationsManager.fromBackend(`Margin for ${displayName} already exists. Edit it in the table above.`);
+ toast.fromError(`Margin for ${displayName} already exists. Edit it in the table above.`);
return false;
}
@@ -120,14 +120,14 @@ export function useMarginConfig({ accessToken }: UseMarginConfigProps): UseMargi
if (marginType === "percentage") {
const percentValue = parseFloat(percentageValue);
if (isNaN(percentValue) || percentValue < 0 || percentValue > 1000) {
- NotificationsManager.fromBackend("Percentage must be between 0% and 1000%");
+ toast.fromError("Percentage must be between 0% and 1000%");
return false;
}
marginValue = percentValue / 100;
} else {
const fixedValue = parseFloat(fixedAmountValue);
if (isNaN(fixedValue) || fixedValue < 0) {
- NotificationsManager.fromBackend("Fixed amount must be non-negative");
+ toast.fromError("Fixed amount must be non-negative");
return false;
}
marginValue = { fixed_amount: fixedValue };
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestPanel.tsx
index 5c79a2292a2..feac3b56369 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestPanel.tsx
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { Copy, Info } from "lucide-react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
@@ -45,14 +45,14 @@ export function GuardrailTestPanel({
const handleSubmit = () => {
if (!inputText.trim()) {
- NotificationsManager.fromBackend("Please enter text to test");
+ toast.fromError("Please enter text to test");
return;
}
const { metadata, error } = parseMetadata(metadataText);
if (error) {
setMetadataError(error);
- NotificationsManager.fromBackend(`Metadata: ${error}`);
+ toast.fromError(`Metadata: ${error}`);
return;
}
setMetadataError(null);
@@ -98,9 +98,9 @@ export function GuardrailTestPanel({
const handleCopyInput = async () => {
const success = await copyToClipboard(inputText);
if (success) {
- NotificationsManager.success("Input copied to clipboard");
+ toast.success("Input copied to clipboard");
} else {
- NotificationsManager.fromBackend("Failed to copy input");
+ toast.fromError("Failed to copy input");
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestPlayground.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestPlayground.tsx
index 08916b03312..fd8ed22867b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestPlayground.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestPlayground.tsx
@@ -2,7 +2,7 @@ import React, { useState } from "react";
import { FlaskConical, Search } from "lucide-react";
import GuardrailTestPanel from "./GuardrailTestPanel";
import { applyGuardrail } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Card, CardContent } from "@/components/ui/card";
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group";
import { UiLoadingSpinner } from "@/components/ui/ui-loading-spinner";
@@ -105,10 +105,10 @@ const GuardrailTestPlayground: React.FC<GuardrailTestPlaygroundProps> = ({
setIsTesting(false);
if (results.length > 0) {
- NotificationsManager.success(`${results.length} guardrail${results.length > 1 ? "s" : ""} applied successfully`);
+ toast.success(`${results.length} guardrail${results.length > 1 ? "s" : ""} applied successfully`);
}
if (errors.length > 0) {
- NotificationsManager.fromBackend(`${errors.length} guardrail${errors.length > 1 ? "s" : ""} failed`);
+ toast.fromError(`${errors.length} guardrail${errors.length > 1 ? "s" : ""} failed`);
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestResults.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestResults.tsx
index ba410a8a800..ed9e7368918 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestResults.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailTestResults.tsx
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { Check, ChevronDown, ChevronRight, Clock, Copy } from "lucide-react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
@@ -102,9 +102,9 @@ export function GuardrailTestResults({ results, errors }: GuardrailTestResultsPr
onClick={async () => {
const success = await copyToClipboard(result.response_text);
if (success) {
- NotificationsManager.success("Result copied to clipboard");
+ toast.success("Result copied to clipboard");
} else {
- NotificationsManager.fromBackend("Failed to copy result");
+ toast.fromError("Failed to copy result");
}
}}
>
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailsPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailsPanel.tsx
index 80267f97a94..b4c29bd9c40 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailsPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/GuardrailsPanel.tsx
@@ -15,7 +15,7 @@ import GuardrailTable from "./guardrail_table";
import { isAdminRole } from "@/utils/roles";
import GuardrailInfoView from "./guardrail_info";
import GuardrailTestPlayground from "./GuardrailTestPlayground";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Guardrail } from "@/components/guardrails/types";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
import { getGuardrailLogoAndName } from "./guardrail_info_helpers";
@@ -101,11 +101,11 @@ const GuardrailsPanel: React.FC<GuardrailsPanelProps> = ({ accessToken, userRole
setIsDeleting(true);
try {
await deleteGuardrailCall(accessToken, guardrailToDelete.guardrail_id);
- NotificationsManager.success(`Guardrail "${guardrailToDelete.guardrail_name}" deleted successfully`);
+ toast.success(`Guardrail "${guardrailToDelete.guardrail_name}" deleted successfully`);
await fetchGuardrails();
} catch (error) {
console.error("Error deleting guardrail:", error);
- NotificationsManager.fromBackend("Failed to delete guardrail");
+ toast.fromError("Failed to delete guardrail");
} finally {
setIsDeleting(false);
setIsDeleteModalOpen(false);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/TeamGuardrailsTab.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/TeamGuardrailsTab.tsx
index 496e1129371..92fc117ebf8 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/TeamGuardrailsTab.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/TeamGuardrailsTab.tsx
@@ -24,7 +24,7 @@ import {
updateGuardrailCall,
type GuardrailSubmissionItem,
} from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import TeamDropdown from "@/components/common_components/team_dropdown";
import { useRegisterGuardrail } from "@/app/(dashboard)/hooks/guardrails/useRegisterGuardrail";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
@@ -814,9 +814,9 @@ export function TeamGuardrailsTab({ accessToken }: TeamGuardrailsTabProps) {
litellm_params: { forward_api_key: newValue },
});
setGuardrails((prev) => prev.map((x) => (x.id === id ? { ...x, forwardKey: newValue } : x)));
- NotificationsManager.success(newValue ? "Forward API key enabled" : "Forward API key disabled");
+ toast.success(newValue ? "Forward API key enabled" : "Forward API key disabled");
} catch {
- NotificationsManager.fromBackend("Failed to update forward API key");
+ toast.fromError("Failed to update forward API key");
}
}
@@ -840,9 +840,9 @@ export function TeamGuardrailsTab({ accessToken }: TeamGuardrailsTabProps) {
: x,
),
);
- NotificationsManager.success("Static headers updated");
+ toast.success("Static headers updated");
} catch {
- NotificationsManager.fromBackend("Failed to update static headers");
+ toast.fromError("Failed to update static headers");
}
}
@@ -853,9 +853,9 @@ export function TeamGuardrailsTab({ accessToken }: TeamGuardrailsTabProps) {
litellm_params: { extra_headers: extraHeaders },
});
setGuardrails((prev) => prev.map((x) => (x.id === id ? { ...x, extraHeaders } : x)));
- NotificationsManager.success("Forward client headers updated");
+ toast.success("Forward client headers updated");
} catch {
- NotificationsManager.fromBackend("Failed to update forward client headers");
+ toast.fromError("Failed to update forward client headers");
}
}
@@ -866,9 +866,9 @@ export function TeamGuardrailsTab({ accessToken }: TeamGuardrailsTabProps) {
setConfirmAction(null);
if (selectedId === id) setSelectedId(null);
await fetchSubmissions();
- NotificationsManager.success("Guardrail approved");
+ toast.success("Guardrail approved");
} catch {
- NotificationsManager.fromBackend("Failed to approve guardrail");
+ toast.fromError("Failed to approve guardrail");
}
}
@@ -879,9 +879,9 @@ export function TeamGuardrailsTab({ accessToken }: TeamGuardrailsTabProps) {
setConfirmAction(null);
if (selectedId === id) setSelectedId(null);
await fetchSubmissions();
- NotificationsManager.success("Guardrail rejected");
+ toast.success("Guardrail rejected");
} catch {
- NotificationsManager.fromBackend("Failed to reject guardrail");
+ toast.fromError("Failed to reject guardrail");
}
}
@@ -1011,7 +1011,7 @@ export function TeamGuardrailsTab({ accessToken }: TeamGuardrailsTabProps) {
litellm_params,
guardrail_info: values.guardrail_info ? JSON.parse(values.guardrail_info) : undefined,
});
- NotificationsManager.success("Guardrail submitted for review");
+ toast.success("Guardrail submitted for review");
setIsSubmitModalOpen(false);
submitForm.resetFields();
fetchSubmissions();
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/add_guardrail_form.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/add_guardrail_form.tsx
index 5f15eaceb28..7affbded6cc 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/add_guardrail_form.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/add_guardrail_form.tsx
@@ -1,6 +1,6 @@
import { Form, Input, Modal, Select, Tag, Button } from "antd";
import React, { useEffect, useMemo, useState } from "react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
createGuardrailCall,
getGuardrailProviderSpecificParams,
@@ -214,7 +214,7 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
populateGuardrailProviderMap(providerParamsResp);
} catch (error) {
console.error("Error fetching guardrail data:", error);
- NotificationsManager.fromBackend("Failed to load guardrail configuration");
+ toast.fromError("Failed to load guardrail configuration");
}
};
@@ -344,7 +344,7 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
// Validate configuration steps
if (currentStep === 1) {
if (shouldRenderPIIConfigSettings(selectedProvider) && selectedEntities.length === 0) {
- NotificationsManager.fromBackend("Please select at least one PII entity to continue");
+ toast.fromError("Please select at least one PII entity to continue");
return;
}
}
@@ -449,7 +449,7 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
const hasContentFilterSelections =
selectedPatterns.length > 0 || blockedWords.length > 0 || selectedContentCategories.length > 0;
if (!hasContentFilterSelections && !hasCompetitorIntent) {
- NotificationsManager.fromBackend(
+ toast.fromError(
"Please configure at least one content filter setting (category, pattern, keyword, or competitor intent)",
);
setLoading(false);
@@ -505,7 +505,7 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
// For some guardrails, the config values need to be in litellm_params
guardrailData.guardrail_info = configObj;
} catch (error) {
- NotificationsManager.fromBackend("Invalid JSON in configuration");
+ toast.fromError("Invalid JSON in configuration");
setLoading(false);
return;
}
@@ -514,13 +514,13 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
if (guardrailProvider === "llm_as_a_judge") {
const criteria: JudgeCriterion[] = values.criteria || [];
if (criteria.length === 0) {
- NotificationsManager.fromBackend("Add at least one evaluation criterion");
+ toast.fromError("Add at least one evaluation criterion");
setLoading(false);
return;
}
const weightTotal = criteria.reduce((sum, c) => sum + (Number(c?.weight) || 0), 0);
if (weightTotal !== 100) {
- NotificationsManager.fromBackend(`Criterion weights must sum to 100% (currently ${weightTotal}%)`);
+ toast.fromError(`Criterion weights must sum to 100% (currently ${weightTotal}%)`);
setLoading(false);
return;
}
@@ -536,7 +536,7 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
if (guardrailProvider === "tool_permission") {
if (toolPermissionConfig.rules.length === 0) {
- NotificationsManager.fromBackend("Add at least one tool permission rule");
+ toast.fromError("Add at least one tool permission rule");
setLoading(false);
return;
}
@@ -611,7 +611,7 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
await createGuardrailCall(accessToken, guardrailData);
- NotificationsManager.success("Guardrail created successfully");
+ toast.success("Guardrail created successfully");
// Reset form and close modal
resetForm();
@@ -619,9 +619,7 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
onClose();
} catch (error) {
console.error("Failed to create guardrail:", error);
- NotificationsManager.fromBackend(
- "Failed to create guardrail: " + (error instanceof Error ? error.message : String(error)),
- );
+ toast.fromError("Failed to create guardrail: " + (error instanceof Error ? error.message : String(error)));
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/ContentFilterConfiguration.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/ContentFilterConfiguration.test.tsx
index 37a3d40128e..b7e20b7651e 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/ContentFilterConfiguration.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/ContentFilterConfiguration.test.tsx
@@ -8,10 +8,6 @@ vi.mock("@/components/networking", () => ({
getCategoryYaml: vi.fn(),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), error: vi.fn(), fromBackend: vi.fn() },
-}));
-
const PREBUILT = [
{ name: "us_ssn", display_name: "US Social Security Number", category: "PII Patterns", description: "d" },
];
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/ContentFilterConfiguration.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/ContentFilterConfiguration.tsx
index a8c4ca3b2e7..7a9c381fd09 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/ContentFilterConfiguration.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/content_filter/ContentFilterConfiguration.tsx
@@ -1,7 +1,7 @@
import React, { useRef, useState } from "react";
import { Plus, Upload } from "lucide-react";
import { validateBlockedWordsFile } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { UiLoadingSpinner } from "@/components/ui/ui-loading-spinner";
@@ -119,7 +119,7 @@ const ContentFilterConfiguration: React.FC<ContentFilterConfigurationProps> = ({
const handleAddPrebuiltPattern = () => {
if (!selectedPatternName) {
- NotificationsManager.error("Please select a pattern");
+ toast.error("Please select a pattern");
return;
}
@@ -140,7 +140,7 @@ const ContentFilterConfiguration: React.FC<ContentFilterConfigurationProps> = ({
const handleAddCustomPattern = () => {
if (!customPatternName || !customPatternRegex) {
- NotificationsManager.error("Please provide pattern name and regex");
+ toast.error("Please provide pattern name and regex");
return;
}
@@ -160,7 +160,7 @@ const ContentFilterConfiguration: React.FC<ContentFilterConfigurationProps> = ({
const handleAddKeyword = () => {
if (!newKeyword) {
- NotificationsManager.error("Please enter a keyword");
+ toast.error("Please enter a keyword");
return;
}
@@ -188,14 +188,14 @@ const ContentFilterConfiguration: React.FC<ContentFilterConfigurationProps> = ({
if (onFileUpload) {
onFileUpload(content);
}
- NotificationsManager.success(result.message || "File uploaded successfully");
+ toast.success(result.message || "File uploaded successfully");
} else {
const errorMessage = result.error || (result.errors && result.errors.join(", ")) || "Invalid file";
- NotificationsManager.error(`Validation failed: ${errorMessage}`);
+ toast.error(`Validation failed: ${errorMessage}`);
}
}
} catch (error) {
- NotificationsManager.error(`Failed to upload file: ${error}`);
+ toast.error(`Failed to upload file: ${error}`);
} finally {
setUploadValidating(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/custom_code/CustomCodeModal.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/custom_code/CustomCodeModal.test.tsx
index 865e72ffa86..fc19ca2a88b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/custom_code/CustomCodeModal.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/custom_code/CustomCodeModal.test.tsx
@@ -10,10 +10,6 @@ vi.mock("@/components/networking", () => ({
testCustomCodeGuardrail: vi.fn(),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), error: vi.fn(), fromBackend: vi.fn() },
-}));
-
const mockCreate = vi.mocked(createGuardrailCall);
const mockUpdate = vi.mocked(updateGuardrailCall);
const mockTest = vi.mocked(testCustomCodeGuardrail);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/custom_code/CustomCodeModal.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/custom_code/CustomCodeModal.tsx
index 5015884de31..2312b6029fc 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/custom_code/CustomCodeModal.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/custom_code/CustomCodeModal.tsx
@@ -1,7 +1,7 @@
import React, { useState, useRef, useEffect } from "react";
import { CheckCircle2, ChevronRight, Code, ExternalLink, PlayCircle, Save, Users, XCircle } from "lucide-react";
import { createGuardrailCall, updateGuardrailCall, testCustomCodeGuardrail } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
import {
@@ -364,15 +364,15 @@ const CustomCodeModal: React.FC<CustomCodeModalProps> = ({ visible, onClose, onS
// Save guardrail (create or update)
const handleSave = async () => {
if (!guardrailName.trim()) {
- NotificationsManager.fromBackend("Please enter a guardrail name");
+ toast.fromError("Please enter a guardrail name");
return;
}
if (!code.trim()) {
- NotificationsManager.fromBackend("Please enter custom code");
+ toast.fromError("Please enter custom code");
return;
}
if (!accessToken) {
- NotificationsManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
@@ -400,7 +400,7 @@ const CustomCodeModal: React.FC<CustomCodeModalProps> = ({ visible, onClose, onS
}
await updateGuardrailCall(accessToken, editData.guardrail_id, updateData);
- NotificationsManager.success("Custom code guardrail updated successfully");
+ toast.success("Custom code guardrail updated successfully");
} else {
// Create new guardrail
const guardrailData = {
@@ -415,13 +415,13 @@ const CustomCodeModal: React.FC<CustomCodeModalProps> = ({ visible, onClose, onS
};
await createGuardrailCall(accessToken, guardrailData);
- NotificationsManager.success("Custom code guardrail created successfully");
+ toast.success("Custom code guardrail created successfully");
}
onSuccess();
onClose();
} catch (error) {
console.error("Failed to save guardrail:", error);
- NotificationsManager.fromBackend(
+ toast.fromError(
`Failed to ${isEditMode ? "update" : "create"} guardrail: ` +
(error instanceof Error ? error.message : String(error)),
);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/guardrail_info.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/guardrail_info.tsx
index 54cac4bbe5c..0e9f6b97b3e 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/guardrail_info.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/guardrail_info.tsx
@@ -11,7 +11,7 @@ import { Badge, Card, Grid, Tab, TabGroup, TabList, TabPanel, TabPanels, Text, T
import { Button, Divider, Form, Input, Select, Tooltip } from "antd";
import { CheckIcon, CopyIcon } from "lucide-react";
import React, { useCallback, useEffect, useState } from "react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Logo } from "@/components/molecules/logo/Logo";
import ContentFilterManager, { formatContentFilterDataForAPI } from "./content_filter/ContentFilterManager";
import CustomCodeModal, { EditGuardrailData } from "./custom_code/CustomCodeModal";
@@ -147,7 +147,7 @@ const GuardrailInfoView: React.FC<GuardrailInfoProps> = ({ guardrailId, onClose,
setSelectedPiiActions({});
}
} catch (error) {
- NotificationsManager.fromBackend("Failed to load guardrail information");
+ toast.fromError("Failed to load guardrail information");
console.error("Error fetching guardrail info:", error);
} finally {
setLoading(false);
@@ -421,19 +421,19 @@ const GuardrailInfoView: React.FC<GuardrailInfoProps> = ({ guardrailId, onClose,
// Only proceed with update if there are actual changes
if (Object.keys(updateData).length === 0) {
- NotificationsManager.info("No changes detected");
+ toast.info("No changes detected");
setIsEditing(false);
return;
}
await updateGuardrailCall(accessToken, guardrailId, updateData);
- NotificationsManager.success("Guardrail updated successfully");
+ toast.success("Guardrail updated successfully");
setHasUnsavedContentFilterChanges(false);
fetchGuardrailInfo();
setIsEditing(false);
} catch (error) {
console.error("Error updating guardrail:", error);
- NotificationsManager.fromBackend("Failed to update guardrail");
+ toast.fromError("Failed to update guardrail");
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/CreateMCPServer.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/CreateMCPServer.tsx
index 476e43e49aa..33887c250ca 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/CreateMCPServer.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/CreateMCPServer.tsx
@@ -44,7 +44,7 @@ import MCPLogoSelector from "./MCPLogoSelector";
import EnvVarsSection from "./EnvVarsSection";
import { isAdminRole } from "@/utils/roles";
import { validateMCPServerUrl, validateMCPServerName } from "./utils";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { useMcpOAuthFlow } from "@/hooks/useMcpOAuthFlow";
import { useTestMCPConnection } from "@/hooks/useTestMCPConnection";
import mcpLogo from "../../../../../public/assets/logos/mcp_logo.png";
@@ -222,7 +222,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
// which would persist it as server-level credentials on the created server row. Mirrors the
// edit form's onTokenReceived early return.
setAuthorizedIdentity(getOAuthAuthorizationIdentity(form.getFieldsValue(true)));
- NotificationsManager.success(
+ toast.success(
"Token held for this browser session. Tools can now be previewed and configured; the token is not saved to LiteLLM.",
);
return;
@@ -255,9 +255,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
// its own credential write.
setAuthorizedIdentity(getOAuthAuthorizationIdentity(form.getFieldsValue(true)));
- NotificationsManager.success(
- "OAuth authorization successful! Please click 'Create MCP Server' to save the configuration.",
- );
+ toast.success("OAuth authorization successful! Please click 'Create MCP Server' to save the configuration.");
},
onBeforeRedirect: persistCreateUiState,
flowSource: "create",
@@ -398,7 +396,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
dcrClient: dcrClientRef.current,
});
if (built.kind !== "ok") {
- NotificationsManager.fromBackend(payloadErrorMessage(built));
+ toast.fromError(payloadErrorMessage(built));
return;
}
const payload = built.payload;
@@ -439,14 +437,13 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
}
}
- NotificationsManager.success(
- isAdmin
- ? "MCP Server created successfully"
- : {
- message: "MCP Server submitted for admin review",
- description: "Once an admin approves it, the server will appear in your MCP Servers list.",
- },
- );
+ if (isAdmin) {
+ toast.success("MCP Server created successfully");
+ } else {
+ toast.success("MCP Server submitted for admin review", {
+ description: "Once an admin approves it, the server will appear in your MCP Servers list.",
+ });
+ }
form.resetFields();
setCostConfig({});
clearTools();
@@ -459,9 +456,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
}
} catch (error) {
const reason = error instanceof Error ? error.message : String(error);
- NotificationsManager.fromBackend(
- isAdmin ? `Error creating MCP Server: ${reason}` : `Error submitting MCP Server: ${reason}`,
- );
+ toast.fromError(isAdmin ? `Error creating MCP Server: ${reason}` : `Error submitting MCP Server: ${reason}`);
} finally {
setIsLoading(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/MCPSubmissionsTab.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/MCPSubmissionsTab.tsx
index de030420bc3..521fb93d801 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/MCPSubmissionsTab.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/MCPSubmissionsTab.tsx
@@ -20,7 +20,7 @@ import {
} from "@/components/networking";
import { MCPServer, MCPSubmissionsSummary } from "@/components/mcp_tools/types";
import { FIELD_GROUPS, MCP_REQUIRED_FIELD_DEFS, SETTINGS_KEY } from "./MCPStandardsSettings";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
type MCPStatus = "active" | "pending_review" | "rejected";
@@ -496,9 +496,9 @@ export function MCPSubmissionsTab({ accessToken }: MCPSubmissionsTabProps) {
setIsSavingRules(true);
try {
await updateConfigFieldSetting(accessToken, SETTINGS_KEY, requiredFields);
- NotificationsManager.success("Submission rules saved");
+ toast.success("Submission rules saved");
} catch {
- NotificationsManager.fromBackend("Failed to save submission rules");
+ toast.fromError("Failed to save submission rules");
} finally {
setIsSavingRules(false);
}
@@ -520,9 +520,9 @@ export function MCPSubmissionsTab({ accessToken }: MCPSubmissionsTabProps) {
try {
await approveMCPServer(accessToken, serverId);
await fetchData();
- NotificationsManager.success(`MCP server "${serverName}" approved`);
+ toast.success(`MCP server "${serverName}" approved`);
} catch {
- NotificationsManager.fromBackend("Failed to approve MCP server");
+ toast.fromError("Failed to approve MCP server");
} finally {
setConfirmAction(null);
}
@@ -533,9 +533,9 @@ export function MCPSubmissionsTab({ accessToken }: MCPSubmissionsTabProps) {
try {
await rejectMCPServer(accessToken, serverId, reviewNotes);
await fetchData();
- NotificationsManager.success(`MCP server "${serverName}" rejected`);
+ toast.success(`MCP server "${serverName}" rejected`);
} catch {
- NotificationsManager.fromBackend("Failed to reject MCP server");
+ toast.fromError("Failed to reject MCP server");
} finally {
setConfirmAction(null);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/ToolTestPanel.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/ToolTestPanel.test.tsx
index 0613e84feed..7718bc27324 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/ToolTestPanel.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/ToolTestPanel.test.tsx
@@ -5,16 +5,6 @@ import { describe, expect, it, vi } from "vitest";
import { ToolTestPanel } from "./ToolTestPanel";
import { InputSchema, MCPTool } from "@/components/mcp_tools/types";
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- info: vi.fn(),
- warning: vi.fn(),
- error: vi.fn(),
- },
-}));
-
const buildTool = (schema: InputSchema | string): MCPTool => ({
name: "demo-tool",
description: "demo",
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/ToolTestPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/ToolTestPanel.tsx
index 8f042445c01..fde98f54523 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/ToolTestPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/ToolTestPanel.tsx
@@ -4,7 +4,7 @@ import { MCPTool, InputSchema, InputSchemaProperty } from "@/components/mcp_tool
import { resolveLogoSrc } from "@/lib/assetPaths";
import { Form, Select, Tooltip } from "antd";
import { InfoCircleOutlined } from "@ant-design/icons";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
const isPlainObject = (value: unknown): value is Record<string, any> =>
typeof value === "object" && value !== null && !Array.isArray(value);
@@ -279,18 +279,18 @@ export function ToolTestPanel({
const handleCopyResult = async () => {
const success = await copyToClipboard(JSON.stringify(result, null, 2));
if (success) {
- NotificationsManager.success("Result copied to clipboard");
+ toast.success("Result copied to clipboard");
} else {
- NotificationsManager.fromBackend("Failed to copy result");
+ toast.fromError("Failed to copy result");
}
};
const handleCopyToolName = async () => {
const success = await copyToClipboard(tool.name);
if (success) {
- NotificationsManager.success("Tool name copied to clipboard");
+ toast.success("Tool name copied to clipboard");
} else {
- NotificationsManager.fromBackend("Failed to copy tool name");
+ toast.fromError("Failed to copy tool name");
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/UserEnvVarsModal.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/UserEnvVarsModal.tsx
index f76aef365f7..e92567c3974 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/UserEnvVarsModal.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/UserEnvVarsModal.tsx
@@ -3,7 +3,7 @@ import { Modal, Form, Input, Button, Alert, Spin, Tag, Typography } from "antd";
import { useMutation, useQuery } from "@tanstack/react-query";
import { MCPServer, MCPUserEnvVarsStatus } from "@/components/mcp_tools/types";
import { getMCPUserEnvVars, storeMCPUserEnvVars } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
const { Text, Title } = Typography;
@@ -38,12 +38,12 @@ const UserEnvVarsModal: React.FC<UserEnvVarsModalProps> = ({ server, open, acces
const saveMutation = useMutation({
mutationFn: (values: Record<string, string>) => storeMCPUserEnvVars(accessToken!, server!.server_id, values),
onSuccess: (saved) => {
- NotificationsManager.success("Credentials saved");
+ toast.success("Credentials saved");
onSaved?.(saved);
onClose();
},
onError: (err) => {
- NotificationsManager.fromBackend(`Failed to save env vars: ${err instanceof Error ? err.message : String(err)}`);
+ toast.fromError(`Failed to save env vars: ${err instanceof Error ? err.message : String(err)}`);
},
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_server_edit.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_server_edit.test.tsx
index 6972c33ea1b..0aab19cb131 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_server_edit.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_server_edit.test.tsx
@@ -5,7 +5,7 @@ import userEvent from "@testing-library/user-event";
import MCPServerEdit, { EDIT_OAUTH_UI_STATE_KEY } from "./mcp_server_edit";
import { setSecureItem } from "@/utils/secureStorage";
import * as networking from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { selectAntOption } from "./testUtils";
vi.mock("@/components/networking", () => ({
@@ -15,13 +15,6 @@ vi.mock("@/components/networking", () => ({
testMCPToolsListRequest: vi.fn().mockResolvedValue({ tools: [], error: null }),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
const mockOauth: {
tokenResponse: any;
getTemporaryPayload: (() => Record<string, unknown> | null) | null;
@@ -1390,10 +1383,8 @@ describe("MCPServerEdit (OAuth token persistence on save)", () => {
await waitFor(() => {
expect(networking.storeMCPOAuthUserCredential).toHaveBeenCalled();
});
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(
- "MCP Server updated, but failed to persist OAuth token: write failed",
- );
- expect(NotificationsManager.success).not.toHaveBeenCalledWith("MCP Server updated successfully");
+ expect(toast.fromError).toHaveBeenCalledWith("MCP Server updated, but failed to persist OAuth token: write failed");
+ expect(toast.success).not.toHaveBeenCalledWith("MCP Server updated successfully");
expect(onSuccess).not.toHaveBeenCalled();
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_server_edit.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_server_edit.tsx
index 1e96a414859..2bae6a7bfcc 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_server_edit.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_server_edit.tsx
@@ -47,7 +47,7 @@ import {
normalizeToolOverrideMap,
TOOL_DISPLAY_NAME_PATTERN,
} from "./utils";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { useMcpOAuthFlow } from "@/hooks/useMcpOAuthFlow";
import { getSecureItem, setSecureItem } from "@/utils/secureStorage";
@@ -221,7 +221,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
token_type: token.token_type,
};
setToken(mcpServer.server_id, browserHeldToken, userID);
- NotificationsManager.success(
+ toast.success(
"Token held for this browser session. Tools can now be loaded and configured; the token is not saved to LiteLLM.",
);
return;
@@ -242,9 +242,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
// Re-capture after writing credentials so the token is not invalidated by its own credential write.
authorizedIdentityRef.current = getOAuthAuthorizationIdentity(form.getFieldsValue(true));
- NotificationsManager.success(
- "OAuth authorization successful! Please click 'Update MCP Server' to save the credentials.",
- );
+ toast.success("OAuth authorization successful! Please click 'Update MCP Server' to save the credentials.");
},
onBeforeRedirect: persistEditUiState,
flowSource: "edit",
@@ -677,7 +675,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
([, displayName]) => displayName && !TOOL_DISPLAY_NAME_PATTERN.test(displayName),
);
if (invalidDisplayName) {
- NotificationsManager.fromBackend(
+ toast.fromError(
`Tool display name "${invalidDisplayName[1]}" is invalid. Only letters, digits, underscores, and hyphens are allowed (no spaces).`,
);
return;
@@ -777,11 +775,11 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
};
if (!stdioFields.command) {
- NotificationsManager.fromBackend("Stdio configuration must include a command");
+ toast.fromError("Stdio configuration must include a command");
return;
}
} catch {
- NotificationsManager.fromBackend("Invalid JSON in stdio configuration");
+ toast.fromError("Invalid JSON in stdio configuration");
return;
}
} else {
@@ -798,7 +796,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
}, {});
}
} catch {
- NotificationsManager.fromBackend("Invalid JSON in stdio env configuration");
+ toast.fromError("Invalid JSON in stdio env configuration");
return;
}
}
@@ -808,7 +806,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
const parsedCommand = rawCommand ? String(rawCommand).trim() : "";
if (!parsedCommand) {
- NotificationsManager.fromBackend("Stdio transport requires a command");
+ toast.fromError("Stdio transport requires a command");
return;
}
@@ -831,7 +829,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
try {
tokenValidation = JSON.parse(rawTokenValidationJson);
} catch {
- NotificationsManager.fromBackend("Invalid JSON in Token Validation Rules");
+ toast.fromError("Invalid JSON in Token Validation Rules");
return;
}
}
@@ -982,18 +980,16 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
}
} catch (error: unknown) {
const message = error instanceof Error ? error.message : "";
- NotificationsManager.fromBackend(
- "MCP Server updated, but failed to persist OAuth token" + (message ? `: ${message}` : ""),
- );
+ toast.fromError("MCP Server updated, but failed to persist OAuth token" + (message ? `: ${message}` : ""));
return;
}
}
- NotificationsManager.success("MCP Server updated successfully");
+ toast.success("MCP Server updated successfully");
setAppMayNotMatchUpstream(false);
onSuccess(updated);
} catch (error: any) {
- NotificationsManager.fromBackend("Failed to update MCP Server" + (error?.message ? `: ${error.message}` : ""));
+ toast.fromError("Failed to update MCP Server" + (error?.message ? `: ${error.message}` : ""));
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_servers.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_servers.test.tsx
index f9f3d20ca15..8dca87e24ef 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_servers.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_servers.test.tsx
@@ -19,14 +19,6 @@ vi.mock("@/components/networking", () => ({
listMCPUserEnvVarStatus: vi.fn().mockResolvedValue([]),
}));
-// Mock NotificationsManager
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
const createQueryClient = () =>
new QueryClient({
defaultOptions: {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_servers.tsx b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_servers.tsx
index 193246aab3c..970fb56799d 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_servers.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/mcp-servers/_components/mcp_servers.tsx
@@ -20,7 +20,7 @@ import React, { useEffect, useState, useMemo, useCallback } from "react";
import { useQuery } from "@tanstack/react-query";
import { useMCPServers } from "@/app/(dashboard)/hooks/mcpServers/useMCPServers";
import { useMCPServerHealth } from "@/app/(dashboard)/hooks/mcpServers/useMCPServerHealth";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { deleteMCPServer } from "@/components/networking";
import { MCPSubmissionsTab } from "./MCPSubmissionsTab";
import { MCPToolsetsTab } from "./MCPToolsetsTab";
@@ -350,7 +350,7 @@ const MCPServers: React.FC<MCPServerProps> = ({ accessToken, userRole, userID })
try {
setIsDeletingServer(true);
await deleteMCPServer(accessToken, serverIdToDelete);
- NotificationsManager.success("Deleted MCP Server successfully");
+ toast.success("Deleted MCP Server successfully");
// If the user is currently viewing the detail page of the server they
// just deleted, return them to the All Servers list. Otherwise the
// detail view would stay mounted, fall back to an empty stub server,
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/memory/_components/MemoryView.tsx b/ui/litellm-dashboard/src/app/(dashboard)/memory/_components/MemoryView.tsx
index a91110cf780..1d2e5150a62 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/memory/_components/MemoryView.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/memory/_components/MemoryView.tsx
@@ -8,7 +8,7 @@ import React, { useCallback, useMemo, useState } from "react";
import { MemoryRow, createMemory, deleteMemory, fetchMemoryList, updateMemory } from "@/components/networking";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { DEBOUNCE_WAIT_MS } from "@/utils/debounceConstants";
@@ -61,7 +61,7 @@ export const MemoryView: React.FC<MemoryViewProps> = ({ accessToken }) => {
// All three write endpoints share the same success/error plumbing:
// - on success: invalidate the list query so every cached page
// refetches from scratch (pagination + filter-aware).
- // - on error: surface the message via `MessageManager.error`.
+ // - on error: surface the message via `toast.error`.
const invalidateList = useCallback(
() => queryClient.invalidateQueries({ queryKey: [MEMORY_LIST_KEY] }),
@@ -74,11 +74,11 @@ export const MemoryView: React.FC<MemoryViewProps> = ({ accessToken }) => {
return createMemory(accessToken, args);
},
onSuccess: (row) => {
- MessageManager.success(`Created ${row.key}`);
+ toast.success(`Created ${row.key}`);
invalidateList();
},
onError: (err: Error) => {
- MessageManager.error(`Save failed: ${err.message}`);
+ toast.error(`Save failed: ${err.message}`);
},
});
@@ -89,11 +89,11 @@ export const MemoryView: React.FC<MemoryViewProps> = ({ accessToken }) => {
return updateMemory(accessToken, key, payload);
},
onSuccess: (row) => {
- MessageManager.success(`Updated ${row.key}`);
+ toast.success(`Updated ${row.key}`);
invalidateList();
},
onError: (err: Error) => {
- MessageManager.error(`Save failed: ${err.message}`);
+ toast.error(`Save failed: ${err.message}`);
},
});
@@ -103,11 +103,11 @@ export const MemoryView: React.FC<MemoryViewProps> = ({ accessToken }) => {
return deleteMemory(accessToken, key).then(() => key);
},
onSuccess: (key) => {
- MessageManager.success(`Deleted ${key}`);
+ toast.success(`Deleted ${key}`);
invalidateList();
},
onError: (err: Error) => {
- MessageManager.error(`Delete failed: ${err.message}`);
+ toast.error(`Delete failed: ${err.message}`);
},
});
@@ -149,7 +149,7 @@ export const MemoryView: React.FC<MemoryViewProps> = ({ accessToken }) => {
try {
metadataPayload = JSON.parse(metadataText);
} catch {
- MessageManager.error("Metadata must be valid JSON (or leave empty).");
+ toast.error("Metadata must be valid JSON (or leave empty).");
return false;
}
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTab.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTab.test.tsx
index b98fbf33d24..d65763aaeaf 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTab.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTab.test.tsx
@@ -13,10 +13,6 @@ vi.mock("@/components/networking", () => ({
modelPatchUpdateCall: (...args: unknown[]) => mockModelPatchUpdateCall(...args),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
vi.mock("@/components/model_dashboard/ModelSettingsModal/ModelSettingsModal", () => ({
default: function ModelSettingsModalMock({ isVisible }: { isVisible: boolean }) {
return isVisible ? <div data-testid="model-settings-modal" /> : null;
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTab.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTab.tsx
index 1d206f81030..ac9143a09d7 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTab.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTab.tsx
@@ -6,7 +6,7 @@ import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
import ModelSettingsModal from "@/components/model_dashboard/ModelSettingsModal/ModelSettingsModal";
import { ModelData } from "@/components/model_dashboard/types";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { modelDeleteCall, modelPatchUpdateCall } from "@/components/networking";
import { useQueryClient } from "@tanstack/react-query";
import { useDebouncedCallback } from "@tanstack/react-pacer/debouncer";
@@ -213,12 +213,12 @@ const AllModelsTab = ({
try {
setDeleteLoading(true);
await modelDeleteCall(accessToken, deleteModalModelId);
- NotificationsManager.success("Model deleted successfully");
+ toast.success("Model deleted successfully");
queryClient.invalidateQueries({ queryKey: ["models", "list"] });
refetchModels();
} catch (error) {
console.error("Error deleting model:", error);
- NotificationsManager.fromBackend(error);
+ toast.fromError(error);
} finally {
setDeleteLoading(false);
setDeleteModalModelId(null);
@@ -231,13 +231,13 @@ const AllModelsTab = ({
try {
setPausingModelId(modelId);
await modelPatchUpdateCall(accessToken, { blocked }, modelId);
- NotificationsManager.success(blocked ? "Model paused" : "Model resumed");
+ toast.success(blocked ? "Model paused" : "Model resumed");
// invalidateQueries already schedules a refetch for active observers
// on this key — no need to also call refetchModels() (would double-fetch).
queryClient.invalidateQueries({ queryKey: ["models", "list"] });
} catch (error) {
console.error("Error toggling model pause state:", error);
- NotificationsManager.fromBackend(error);
+ toast.fromError(error);
} finally {
setPausingModelId(null);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTable.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTable.test.tsx
index fa8dd2e5840..8a9b6847fd2 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTable.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTable.test.tsx
@@ -6,10 +6,6 @@ import { ModelData } from "@/components/model_dashboard/types";
import { AllModelsTable } from "./AllModelsTable";
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
const makeModel = (overrides: Partial<ModelData> = {}): ModelData =>
({
model_name: "gpt-4-public",
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AutoRouters/AutoRoutersPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AutoRouters/AutoRoutersPanel.tsx
index f09aa1a0c84..db5120cebce 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AutoRouters/AutoRoutersPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AutoRouters/AutoRoutersPanel.tsx
@@ -7,7 +7,7 @@ import { useAutoRouters, useInvalidateAutoRouters } from "@/app/(dashboard)/hook
import { useModelDetailRouting } from "@/app/(dashboard)/models-and-endpoints/detailNavigation";
import AddAutoRouterTab from "@/components/add_model/add_auto_router_tab";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { modelDeleteCall } from "@/components/networking";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
@@ -53,11 +53,11 @@ export function AutoRoutersPanel({ accessToken, userRole, userID, teams, createS
setIsDeleting(true);
try {
await modelDeleteCall(accessToken, deletingRouter.id);
- NotificationsManager.success(`Deleted auto router: ${deletingRouter.name}`);
+ toast.success(`Deleted auto router: ${deletingRouter.name}`);
setDeletingRouter(null);
await invalidateAutoRouters();
} catch (error) {
- NotificationsManager.fromBackend(`Failed to delete auto router: ${error}`);
+ toast.fromError(`Failed to delete auto router: ${error}`);
} finally {
setIsDeleting(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/AddModelPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/AddModelPanel.tsx
index 4d7bcc921af..35be19531d5 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/AddModelPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/AddModelPanel.tsx
@@ -6,7 +6,7 @@ import { useQueryClient } from "@tanstack/react-query";
import AddModelForm from "@/components/add_model/AddModelForm";
import { handleAddModelSubmit } from "@/components/add_model/handle_add_model_submit";
import { Providers, getPlaceholder, getProviderModels } from "@/components/provider_info_helpers";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { useModelCostMap } from "@/app/(dashboard)/hooks/models/useModelCostMap";
import { useCredentials } from "@/app/(dashboard)/hooks/credentials/useCredentials";
import { useTeams } from "@/app/(dashboard)/hooks/teams/useTeams";
@@ -34,7 +34,7 @@ export default function AddModelPanel() {
const errorMessages =
error.errorFields?.map((field: any) => `${field.name.join(".")}: ${field.errors.join(", ")}`).join(" | ") ||
"Unknown validation error";
- NotificationsManager.fromBackend(`Please fill in the following required fields: ${errorMessages}`);
+ toast.fromError(`Please fill in the following required fields: ${errorMessages}`);
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/ModelRetrySettingsPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/ModelRetrySettingsPanel.tsx
index 57e32b5624c..a5c10ca8a8b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/ModelRetrySettingsPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/ModelRetrySettingsPanel.tsx
@@ -6,7 +6,7 @@ import { getCallbacksCall } from "@/components/networking";
import { useUpdateRetryPolicy } from "@/app/(dashboard)/hooks/routerSettings/useUpdateRetryPolicy";
import { useModelDashboardData } from "@/app/(dashboard)/models-and-endpoints/useModelDashboardData";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface RetryPolicyObject {
[key: string]: { [retryPolicyKey: string]: number } | undefined;
@@ -69,7 +69,7 @@ export default function ModelRetrySettingsPanel() {
{ retry_policy: globalRetryPolicy, model_group_retry_policy: modelGroupRetryPolicy },
{
onSuccess: () => {
- NotificationsManager.success("Retry settings saved successfully");
+ toast.success("Retry settings saved successfully");
void fetchRetrySettings().then((routerSettings) => {
if (routerSettings) {
applyRetrySettings(routerSettings);
@@ -77,7 +77,7 @@ export default function ModelRetrySettingsPanel() {
});
},
onError: () => {
- NotificationsManager.fromBackend("Failed to save retry settings");
+ toast.fromError("Failed to save retry settings");
},
},
);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/vertexCredentialsUpload.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/vertexCredentialsUpload.test.ts
index a1225ea84b0..e02e4974353 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/vertexCredentialsUpload.test.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/vertexCredentialsUpload.test.ts
@@ -1,14 +1,10 @@
import { waitFor } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { vertexCredentialsUploadProps } from "./vertexCredentialsUpload";
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
const makeForm = () => ({ setFieldsValue: vi.fn() });
describe("vertexCredentialsUploadProps", () => {
@@ -45,7 +41,7 @@ describe("vertexCredentialsUploadProps", () => {
props.onChange?.({ file: { name: "vertex.json", status: "done" } } as never);
props.onChange?.({ file: { name: "vertex.json", status: "error" } } as never);
- expect(NotificationsManager.success).toHaveBeenCalledWith("vertex.json file uploaded successfully");
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith("vertex.json file upload failed.");
+ expect(toast.success).toHaveBeenCalledWith("vertex.json file uploaded successfully");
+ expect(toast.fromError).toHaveBeenCalledWith("vertex.json file upload failed.");
});
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/vertexCredentialsUpload.ts b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/vertexCredentialsUpload.ts
index 1ec9807e6d5..f658ec88c1c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/vertexCredentialsUpload.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/vertexCredentialsUpload.ts
@@ -1,6 +1,6 @@
import type { ComponentProps } from "react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import type CredentialsPanel from "@/components/model_add/CredentialsPanel";
interface VertexCredentialsForm {
@@ -28,9 +28,9 @@ export function vertexCredentialsUploadProps(form: VertexCredentialsForm): Uploa
},
onChange(info) {
if (info.file.status === "done") {
- NotificationsManager.success(`${info.file.name} file uploaded successfully`);
+ toast.success(`${info.file.name} file uploaded successfully`);
} else if (info.file.status === "error") {
- NotificationsManager.fromBackend(`${info.file.name} file upload failed.`);
+ toast.fromError(`${info.file.name} file upload failed.`);
}
},
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsPanel.tsx
index 65be15294f6..4fe4cf47b9c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsPanel.tsx
@@ -5,7 +5,7 @@ import { useQueryClient } from "@tanstack/react-query";
import { parseAsString, useQueryState } from "nuqs";
import React, { useState } from "react";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { organizationDeleteCall } from "@/components/networking";
import { OrgCreateDialog } from "@/components/organization/org-create/OrgCreateDialog";
import OrganizationInfoView from "@/components/organization/organization_view";
@@ -61,7 +61,7 @@ const OrganizationsPanel: React.FC<OrganizationsPanelProps> = ({ userRole, acces
try {
setIsDeleting(true);
await organizationDeleteCall(accessToken, orgToDelete);
- NotificationsManager.success("Organization deleted successfully");
+ toast.success("Organization deleted successfully");
setIsDeleteModalOpen(false);
setOrgToDelete(null);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.test.tsx
index f2c2c3d2c8c..dbf2251168b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.test.tsx
@@ -34,10 +34,6 @@ vi.mock("@/components/CodeBlock", () => ({
default: ({ code }: { code: string }) => <pre data-testid="code-block">{code}</pre>,
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
const StatefulPanel = ({ label }: { label: string }) => {
const [draft, setDraft] = useState("");
return <input aria-label={label} value={draft} onChange={(event) => setDraft(event.target.value)} />;
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.tsx
index 5a86b2d27f4..c5732b49372 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.tsx
@@ -20,7 +20,7 @@ import { UiLoadingSpinner } from "@/components/ui/ui-loading-spinner";
import { MultiSelect } from "@/components/shared/MultiSelect";
import { useVisitedTabs } from "@/hooks/useVisitedTabs";
import CodeBlock from "@/components/CodeBlock";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
keyCreateCall,
modelCreateCall,
@@ -240,7 +240,7 @@ export default function AgentBuilderView({
return list;
} catch (e) {
console.error(e);
- NotificationsManager.fromBackend("Failed to load agents");
+ toast.fromError("Failed to load agents");
return [];
} finally {
setLoadingAgents(false);
@@ -333,7 +333,7 @@ export default function AgentBuilderView({
const handleSaveAgent = async () => {
if (!accessToken || !draftName?.trim() || !draftUnderlyingModel) {
- NotificationsManager.fromBackend("Name and underlying model are required");
+ toast.fromError("Name and underlying model are required");
return;
}
setSaving(true);
@@ -360,7 +360,7 @@ export default function AgentBuilderView({
setSelectedId(created ? getAgentSelectionKey(created) : list[0] ? getAgentSelectionKey(list[0]) : null);
goToTab("chat");
} catch (e) {
- NotificationsManager.fromBackend("Failed to save agent");
+ toast.fromError("Failed to save agent");
} finally {
setSaving(false);
}
@@ -368,7 +368,7 @@ export default function AgentBuilderView({
const handleUpdateAgent = async () => {
if (!accessToken || !selectedAgent || !selectedAgentModelId || !draftName?.trim() || !draftUnderlyingModel) {
- NotificationsManager.fromBackend("Name and underlying model are required");
+ toast.fromError("Name and underlying model are required");
return;
}
setSaving(true);
@@ -388,13 +388,13 @@ export default function AgentBuilderView({
},
selectedAgentModelId,
);
- NotificationsManager.success("Agent updated successfully");
+ toast.success("Agent updated successfully");
const list = await loadAgents();
const stillSelected = list.find((a) => getAgentModelId(a) === selectedAgentModelId);
const target = stillSelected ?? list[0];
setSelectedId(target ? getAgentSelectionKey(target) : null);
} catch (e) {
- NotificationsManager.fromBackend("Failed to update agent");
+ toast.fromError("Failed to update agent");
} finally {
setSaving(false);
}
@@ -412,12 +412,12 @@ export default function AgentBuilderView({
const keyValue = response?.key ?? null;
if (keyValue) {
setCreatedKeyValue(keyValue);
- NotificationsManager.success("Virtual key created. Use it in the curl example below.");
+ toast.success("Virtual key created. Use it in the curl example below.");
} else {
- NotificationsManager.fromBackend("Key created but value not returned");
+ toast.fromError("Key created but value not returned");
}
} catch (e) {
- NotificationsManager.fromBackend("Failed to create key for agent");
+ toast.fromError("Failed to create key for agent");
} finally {
setCreatingKey(false);
}
@@ -433,12 +433,12 @@ export default function AgentBuilderView({
setDeleting(true);
try {
await modelDeleteCall(accessToken, selectedAgentModelId);
- NotificationsManager.success("Agent deleted");
+ toast.success("Agent deleted");
const list = await loadAgents();
const remaining = list.filter((a) => getAgentModelId(a) !== selectedAgentModelId);
setSelectedId(remaining.length > 0 ? getAgentSelectionKey(remaining[0]) : null);
} catch (e) {
- NotificationsManager.fromBackend("Failed to delete agent");
+ toast.fromError("Failed to delete agent");
} finally {
setDeleting(false);
setConfirmingDelete(false);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatImageUpload.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatImageUpload.tsx
index 6f210118281..f47a6b42d6e 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatImageUpload.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatImageUpload.tsx
@@ -1,6 +1,6 @@
import React, { useId, useRef } from "react";
import { Paperclip } from "lucide-react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { CHAT_ATTACHMENT_ACCEPT, validateChatAttachment } from "./uploadValidation";
@@ -29,7 +29,7 @@ const ChatImageUpload: React.FC<ChatImageUploadProps> = ({ chatUploadedImage, on
}
const result = validateChatAttachment(file);
if (!result.ok) {
- NotificationsManager.error(result.error);
+ toast.error(result.error);
return;
}
onImageUpload(file);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx
index e81b86d4b8b..ba42b139dbd 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx
@@ -28,7 +28,7 @@ import PolicySelector from "@/components/policies/PolicySelector";
import MCPToolArgumentsForm, { MCPToolArgumentsFormRef } from "@/components/mcp_tools/MCPToolArgumentsForm";
import { MCPServer } from "@/components/mcp_tools/types";
import { ByokCredentialModal } from "@/components/mcp_tools/ByokCredentialModal";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { callMCPTool, fetchMCPServers, fetchMCPToolsets, listMCPTools } from "@/components/networking";
import { MCPTool, MCPToolset } from "@/components/mcp_tools/types";
import TagSelector from "@/components/tag_management/TagSelector";
@@ -512,7 +512,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
abortControllerRef.current.abort();
abortControllerRef.current = null;
setIsLoading(false);
- NotificationsManager.info("Request cancelled");
+ toast.info("Request cancelled");
}
};
@@ -528,7 +528,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
for (const file of files) {
const result = validateImageEditFile(file, nextCount);
if (!result.ok) {
- NotificationsManager.error(result.error);
+ toast.error(result.error);
continue;
}
accepted.push(file);
@@ -565,7 +565,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
const handleResponsesImageUpload = (file: File): void => {
const result = validateChatAttachment(file);
if (!result.ok) {
- NotificationsManager.error(result.error);
+ toast.error(result.error);
return;
}
setResponsesUploadedImage(file);
@@ -583,7 +583,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
const handleChatImageUpload = (file: File): void => {
const result = validateChatAttachment(file);
if (!result.ok) {
- NotificationsManager.error(result.error);
+ toast.error(result.error);
return;
}
setChatUploadedImage(file);
@@ -601,7 +601,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
const handleAudioUpload = (file: File): void => {
const result = validateAudioFile(file);
if (!result.ok) {
- NotificationsManager.error(result.error);
+ toast.error(result.error);
return;
}
setUploadedAudio(file);
@@ -706,19 +706,19 @@ const ChatUI: React.FC<ChatUIProps> = ({
// For image edits, require both image and prompt
if (endpointType === EndpointType.IMAGE_EDITS && uploadedImages.length === 0) {
- NotificationsManager.fromBackend("Please upload at least one image for editing");
+ toast.fromError("Please upload at least one image for editing");
return;
}
// For audio transcriptions, require audio file
if (endpointType === EndpointType.TRANSCRIPTION && !uploadedAudio) {
- NotificationsManager.fromBackend("Please upload an audio file for transcription");
+ toast.fromError("Please upload an audio file for transcription");
return;
}
// For A2A agents, require agent selection
if (endpointType === EndpointType.A2A_AGENTS && !selectedAgent) {
- NotificationsManager.fromBackend("Please select an agent to send a message");
+ toast.fromError("Please select an agent to send a message");
return;
}
@@ -728,11 +728,11 @@ const ChatUI: React.FC<ChatUIProps> = ({
const rawSelected =
selectedMCPServers.length === 1 && selectedMCPServers[0] !== "__all__" ? selectedMCPServers[0] : null;
if (!rawSelected) {
- NotificationsManager.fromBackend("Please select an MCP server to test");
+ toast.fromError("Please select an MCP server to test");
return;
}
if (!selectedMCPDirectTool) {
- NotificationsManager.fromBackend("Please select an MCP tool to call");
+ toast.fromError("Please select an MCP tool to call");
return;
}
// For toolsets, find the tool in the servers that back this toolset
@@ -750,13 +750,13 @@ const ChatUI: React.FC<ChatUIProps> = ({
}
const mcpTool = searchPool.find((t: any) => t.name === selectedMCPDirectTool);
if (!mcpTool) {
- NotificationsManager.fromBackend("Please wait for tool schema to load");
+ toast.fromError("Please wait for tool schema to load");
return;
}
try {
mcpToolArguments = (await mcpToolArgsFormRef.current?.getSubmitValues()) ?? {};
} catch (err) {
- NotificationsManager.fromBackend(err instanceof Error ? err.message : "Please fill in all required parameters");
+ toast.fromError(err instanceof Error ? err.message : "Please fill in all required parameters");
return;
}
}
@@ -775,7 +775,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
];
if (modelRequiredEndpoints.includes(endpointType as EndpointType) && !selectedModel) {
- NotificationsManager.fromBackend("Please select a model before sending a request");
+ toast.fromError("Please select a model before sending a request");
return;
}
@@ -786,7 +786,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
const effectiveApiKey = simplified ? accessToken : apiKeySource === "session" ? accessToken : apiKey;
if (!effectiveApiKey) {
- NotificationsManager.fromBackend("Please provide a Virtual Key or select Current UI Session");
+ toast.fromError("Please provide a Virtual Key or select Current UI Session");
return;
}
@@ -802,7 +802,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
try {
newUserMessage = await createMultimodalMessage(inputMessage, responsesUploadedImage);
} catch (error) {
- NotificationsManager.fromBackend("Failed to process image. Please try again.");
+ toast.fromError("Failed to process image. Please try again.");
return;
}
}
@@ -811,7 +811,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
try {
newUserMessage = await createChatMultimodalMessage(inputMessage, chatUploadedImage);
} catch (error) {
- NotificationsManager.fromBackend("Failed to process image. Please try again.");
+ toast.fromError("Failed to process image. Please try again.");
return;
}
} else {
@@ -1139,7 +1139,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
handleRemoveResponsesImage();
handleRemoveChatImage();
handleRemoveAudio();
- NotificationsManager.success("Chat history cleared.");
+ toast.success("Chat history cleared.");
};
const onModelChange = (value: string) => {
@@ -2028,7 +2028,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
onToggle={() => {
codeInterpreter.toggle();
if (!codeInterpreter.enabled) {
- NotificationsManager.success("Code Interpreter enabled!");
+ toast.success("Code Interpreter enabled!");
}
}}
/>
@@ -2098,8 +2098,8 @@ const ChatUI: React.FC<ChatUIProps> = ({
size="sm"
onClick={() => {
void navigator.clipboard.writeText(generatedCode).then(
- () => NotificationsManager.success("Copied to clipboard!"),
- () => NotificationsManager.error("Unable to copy to clipboard"),
+ () => toast.success("Copied to clipboard!"),
+ () => toast.error("Unable to copy to clipboard"),
);
}}
>
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/CodeInterpreterTool.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/CodeInterpreterTool.tsx
index e5744ac8e38..87a61d17407 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/CodeInterpreterTool.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/CodeInterpreterTool.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { Code, Info, TriangleAlert } from "lucide-react";
import { Switch } from "@/components/ui/switch";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
@@ -39,7 +39,7 @@ const CodeInterpreterTool: React.FC<CodeInterpreterToolProps> = ({
const handleToggle = (checked: boolean) => {
if (checked && !isOpenAI) {
- MessageManager.warning("Code Interpreter is only available for OpenAI models");
+ toast.warning("Code Interpreter is only available for OpenAI models");
return;
}
onEnabledChange(checked);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ResponsesImageUpload.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ResponsesImageUpload.tsx
index 97346c34a12..b24fa13f293 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ResponsesImageUpload.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ResponsesImageUpload.tsx
@@ -1,6 +1,6 @@
import React, { useId, useRef } from "react";
import { Paperclip } from "lucide-react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { CHAT_ATTACHMENT_ACCEPT, validateChatAttachment } from "./uploadValidation";
@@ -33,7 +33,7 @@ const ResponsesImageUpload: React.FC<ResponsesImageUploadProps> = ({
}
const result = validateChatAttachment(file);
if (!result.ok) {
- NotificationsManager.error(result.error);
+ toast.error(result.error);
return;
}
onImageUpload(file);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/SessionManagement.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/SessionManagement.tsx
index 193ccce9174..a27b4f0893b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/SessionManagement.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/SessionManagement.tsx
@@ -1,7 +1,7 @@
import React from "react";
import { Copy, Info } from "lucide-react";
import { EndpointType } from "@/components/chat_ui/mode_endpoint_mapping";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
@@ -27,9 +27,9 @@ const SessionManagement: React.FC<SessionManagementProps> = ({
if (responsesSessionId) {
try {
await navigator.clipboard.writeText(responsesSessionId);
- NotificationsManager.success("Response ID copied to clipboard!");
+ toast.success("Response ID copied to clipboard!");
} catch {
- NotificationsManager.error("Unable to copy response ID");
+ toast.error("Unable to copy response ID");
}
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/compareUI/CompareUI.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/compareUI/CompareUI.tsx
index 984e04e93f1..83d84adca40 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/compareUI/CompareUI.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/compareUI/CompareUI.tsx
@@ -1,6 +1,6 @@
"use client";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { DEBOUNCE_WAIT_MS } from "@/utils/debounceConstants";
import { Eraser, FileText, Plus, Trash2 } from "lucide-react";
import { useDebouncedValue } from "@tanstack/react-pacer/debouncer";
@@ -482,7 +482,7 @@ export default function CompareUI({ accessToken, disabledPersonalKeyCreation }:
return;
}
if (!effectiveApiKey) {
- NotificationsManager.fromBackend("Please provide a Virtual Key or select Current UI Session");
+ toast.fromError("Please provide a Virtual Key or select Current UI Session");
return;
}
const targetComparisons = comparisons;
@@ -491,7 +491,7 @@ export default function CompareUI({ accessToken, disabledPersonalKeyCreation }:
}
// Validate selection based on endpoint type
if (targetComparisons.some((comparison) => !hasValidSelection(comparison, selectedEndpoint))) {
- NotificationsManager.fromBackend(endpointConfig.validationMessage);
+ toast.fromError(endpointConfig.validationMessage);
return;
}
@@ -628,7 +628,7 @@ export default function CompareUI({ accessToken, disabledPersonalKeyCreation }:
.catch((error) => {
const errorMessage = error instanceof Error ? error.message : String(error);
console.error("CompareUI: failed to fetch response", error);
- NotificationsManager.fromBackend(errorMessage);
+ toast.fromError(errorMessage);
setComparisons((prev) =>
prev.map((comparison) => {
if (comparison.id !== prepared.id) {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/anthropic_messages.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/anthropic_messages.tsx
index 4facf8a2046..14afa013768 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/anthropic_messages.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/anthropic_messages.tsx
@@ -4,7 +4,7 @@ import { TokenUsage } from "@/components/chat_ui/ResponseMetrics";
import { buildMcpToolBlocks } from "@/components/llm_calls/mcp_tool_blocks";
import { MCPServer, MCPToolset } from "@/components/mcp_tools/types";
import { getProxyBaseUrl } from "@/components/networking";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { extractPromptCacheTokens } from "@/utils/promptCacheUsage";
export async function makeAnthropicMessagesRequest(
@@ -118,9 +118,7 @@ export async function makeAnthropicMessagesRequest(
} catch (error) {
if (signal?.aborted) {
} else {
- NotificationManager.fromBackend(
- `Error occurred while generating model response. Please try again. Error: ${error}`,
- );
+ toast.fromError(`Error occurred while generating model response. Please try again. Error: ${error}`);
}
throw error;
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_speech.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_speech.tsx
index 0bdb62f48a0..d9361bd0777 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_speech.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_speech.tsx
@@ -1,6 +1,6 @@
import openai from "openai";
import { getProxyBaseUrl } from "@/components/networking";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import type { OpenAIVoice } from "../components/chat_ui/chatConstants";
export async function makeOpenAIAudioSpeechRequest(
@@ -49,7 +49,7 @@ export async function makeOpenAIAudioSpeechRequest(
} catch (error) {
if (signal?.aborted) {
} else {
- NotificationManager.fromBackend(`Error occurred while generating speech. Please try again. Error: ${error}`);
+ toast.fromError(`Error occurred while generating speech. Please try again. Error: ${error}`);
}
throw error; // Re-throw to allow the caller to handle the error
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_transcriptions.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_transcriptions.tsx
index 33f4faa1f29..50d5fb19990 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_transcriptions.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_transcriptions.tsx
@@ -1,6 +1,6 @@
import openai from "openai";
import { getProxyBaseUrl } from "@/components/networking";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
export async function makeOpenAIAudioTranscriptionRequest(
audioFile: File,
@@ -45,7 +45,7 @@ export async function makeOpenAIAudioTranscriptionRequest(
// The response is a transcription object with a text field
if (response && response.text) {
updateUI(response.text, selectedModel);
- NotificationManager.success(`Audio transcribed successfully`);
+ toast.success(`Audio transcribed successfully`);
} else {
throw new Error("No transcription text in response");
}
@@ -62,7 +62,7 @@ export async function makeOpenAIAudioTranscriptionRequest(
errorMessage = error.message;
}
- NotificationManager.fromBackend(`Audio transcription failed: ${errorMessage}`);
+ toast.fromError(`Audio transcription failed: ${errorMessage}`);
}
throw error; // Re-throw to allow the caller to handle the error
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/embeddings_api.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/embeddings_api.tsx
index cc3c0f81dc5..b43955b711d 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/embeddings_api.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/embeddings_api.tsx
@@ -1,4 +1,4 @@
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getProxyBaseUrl, getGlobalLitellmHeaderName } from "@/components/networking";
export async function makeOpenAIEmbeddingsRequest(
@@ -57,9 +57,7 @@ export async function makeOpenAIEmbeddingsRequest(
updateEmbeddingsUI(JSON.stringify(embedding), responseData?.model ?? selectedModel);
} catch (error: unknown) {
- NotificationManager.fromBackend(
- `Error occurred while making embeddings request. Please try again. Error: ${error}`,
- );
+ toast.fromError(`Error occurred while making embeddings request. Please try again. Error: ${error}`);
throw error; // Re-throw to allow the caller to handle the error
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/image_edits.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/image_edits.tsx
index 8f332c5a905..f66be10897d 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/image_edits.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/image_edits.tsx
@@ -1,6 +1,6 @@
import openai from "openai";
import { getProxyBaseUrl } from "@/components/networking";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
export async function makeOpenAIImageEditsRequest(
imageFiles: File | File[],
@@ -63,7 +63,7 @@ export async function makeOpenAIImageEditsRequest(
}
if (results.length > 1) {
- NotificationManager.success(`Successfully processed ${results.length} images`);
+ toast.success(`Successfully processed ${results.length} images`);
}
} catch (error: any) {
console.error("Error making image edit request:", error);
@@ -78,7 +78,7 @@ export async function makeOpenAIImageEditsRequest(
errorMessage = error.message;
}
- NotificationManager.fromBackend(`Image edit failed: ${errorMessage}`);
+ toast.fromError(`Image edit failed: ${errorMessage}`);
}
throw error; // Re-throw to allow the caller to handle the error
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/image_generation.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/image_generation.tsx
index 7f2b3c7b7e3..7d3fb098257 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/image_generation.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/image_generation.tsx
@@ -1,6 +1,6 @@
import openai from "openai";
import { getProxyBaseUrl } from "@/components/networking";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
export async function makeOpenAIImageGenerationRequest(
prompt: string,
@@ -51,7 +51,7 @@ export async function makeOpenAIImageGenerationRequest(
} catch (error) {
if (signal?.aborted) {
} else {
- NotificationManager.fromBackend(`Error occurred while generating image. Please try again. Error: ${error}`);
+ toast.fromError(`Error occurred while generating image. Please try again. Error: ${error}`);
}
throw error; // Re-throw to allow the caller to handle the error
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/interactions_api.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/interactions_api.tsx
index 39d998fe7eb..f1f925ca4e3 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/interactions_api.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/interactions_api.tsx
@@ -1,4 +1,4 @@
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getGlobalLitellmHeaderName, getProxyBaseUrl } from "@/components/networking";
export async function makeInteractionsRequest(
@@ -115,7 +115,7 @@ export async function makeInteractionsRequest(
if (signal?.aborted) {
throw error;
}
- NotificationManager.fromBackend(`Error occurred while making Interactions API request. Error: ${error}`);
+ toast.fromError(`Error occurred while making Interactions API request. Error: ${error}`);
throw error;
}
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
index 9b599f55eee..aec1b61f45b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
@@ -9,10 +9,6 @@ import { Policy } from "@/components/policies/types";
vi.mock("@/components/networking");
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn(), error: vi.fn(), info: vi.fn() },
-}));
-
vi.mock("./impact_preview_alert", () => ({
default: ({ impactResult }: { impactResult: any }) =>
React.createElement("div", { "data-testid": "impact-preview" }, `${impactResult.affected_keys_count} keys`),
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.tsx
index 635d734555d..73b58be1179 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.tsx
@@ -3,7 +3,7 @@ import { Modal, Form, Select, Radio, Divider, Typography } from "antd";
import { Button } from "@tremor/react";
import { Policy } from "@/components/policies/types";
import { teamListCall, keyListCall, modelAvailableCall, estimateAttachmentImpactCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { buildAttachmentData } from "./build_attachment_data";
import { getInvalidTeamEntries } from "./scope_validation";
@@ -162,11 +162,11 @@ const AddAttachmentForm: React.FC<AddAttachmentFormProps> = ({
const failed = results.filter((r) => r.status === "rejected") as PromiseRejectedResult[];
if (successCount > 0 && failed.length === 0) {
- NotificationsManager.success(
+ toast.success(
successCount === 1 ? "Attachment created successfully" : `${successCount} attachments created successfully`,
);
} else if (successCount > 0 && failed.length > 0) {
- NotificationsManager.fromBackend(`${successCount} attachments created, ${failed.length} failed`);
+ toast.fromError(`${successCount} attachments created, ${failed.length} failed`);
} else {
throw new Error(failed[0]?.reason instanceof Error ? failed[0].reason.message : "Failed to create attachments");
}
@@ -176,9 +176,7 @@ const AddAttachmentForm: React.FC<AddAttachmentFormProps> = ({
onClose();
} catch (error) {
console.error("Failed to create attachment:", error);
- NotificationsManager.fromBackend(
- "Failed to create attachment: " + (error instanceof Error ? error.message : String(error)),
- );
+ toast.fromError("Failed to create attachment: " + (error instanceof Error ? error.message : String(error)));
} finally {
setIsSubmitting(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_policy_form.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_policy_form.tsx
index 74e8bd3c6d9..9424dfdad75 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_policy_form.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_policy_form.tsx
@@ -4,7 +4,7 @@ import { Button, TextInput, Textarea } from "@tremor/react";
import { Policy, PolicyCreateRequest, PolicyUpdateRequest } from "@/components/policies/types";
import { Guardrail } from "@/components/guardrails/types";
import { getResolvedGuardrails, modelAvailableCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
const { Text } = Typography;
@@ -322,10 +322,10 @@ const AddPolicyForm: React.FC<AddPolicyFormProps> = ({
if (isEditing && editingPolicy) {
await updatePolicy(accessToken, editingPolicy.policy_id, data as PolicyUpdateRequest);
- NotificationsManager.success("Policy updated successfully");
+ toast.success("Policy updated successfully");
} else {
await createPolicy(accessToken, data as PolicyCreateRequest);
- NotificationsManager.success("Policy created successfully");
+ toast.success("Policy created successfully");
}
resetForm();
@@ -333,9 +333,7 @@ const AddPolicyForm: React.FC<AddPolicyFormProps> = ({
onClose();
} catch (error) {
console.error("Failed to save policy:", error);
- NotificationsManager.fromBackend(
- "Failed to save policy: " + (error instanceof Error ? error.message : String(error)),
- );
+ toast.fromError("Failed to save policy: " + (error instanceof Error ? error.message : String(error)));
} finally {
setIsSubmitting(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx
index 57373b3c4b8..6b8d7c053f2 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx
@@ -3,7 +3,7 @@ import { Alert, AlertDescription, AlertTitle, AlertAction } from "@/components/s
import { Button } from "@/components/ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { Info, TriangleAlert, X } from "lucide-react";
import { isAdminRole } from "@/utils/roles";
import PolicyTable from "./PolicyTable";
@@ -126,7 +126,7 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({ accessToken, userRole })
setPoliciesList(response.policies || []);
} catch (error) {
console.error("Error fetching policies:", error);
- MessageManager.error("Failed to fetch policies");
+ toast.error("Failed to fetch policies");
} finally {
setIsLoading(false);
}
@@ -141,7 +141,7 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({ accessToken, userRole })
setAttachmentsList(response.attachments || []);
} catch (error) {
console.error("Error fetching attachments:", error);
- MessageManager.error("Failed to fetch attachments");
+ toast.error("Failed to fetch attachments");
} finally {
setIsAttachmentsLoading(false);
}
@@ -194,11 +194,11 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({ accessToken, userRole })
setIsDeleting(true);
try {
await deletePolicyCall(accessToken, policyToDelete.policy_id);
- MessageManager.success(`Policy "${policyToDelete.policy_name}" deleted successfully`);
+ toast.success(`Policy "${policyToDelete.policy_name}" deleted successfully`);
await fetchPolicies();
} catch (error) {
console.error("Error deleting policy:", error);
- MessageManager.error("Failed to delete policy");
+ toast.error("Failed to delete policy");
} finally {
setIsDeleting(false);
setIsDeleteModalOpen(false);
@@ -243,7 +243,7 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({ accessToken, userRole })
const handleUseTemplate = async (template: any) => {
if (!accessToken) {
- MessageManager.error("Authentication required");
+ toast.error("Authentication required");
return;
}
@@ -271,7 +271,7 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({ accessToken, userRole })
setIsGuardrailSelectionModalOpen(true);
} catch (error) {
console.error("Error fetching guardrails:", error);
- MessageManager.error("Failed to load guardrails. Please try again.");
+ toast.error("Failed to load guardrails. Please try again.");
}
};
@@ -321,7 +321,7 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({ accessToken, userRole })
await proceedWithTemplate(enrichedTemplate);
} catch (error) {
console.error("Error enriching template:", error);
- MessageManager.error("Failed to configure template. Please try again.");
+ toast.error("Failed to configure template. Please try again.");
setIsEnrichingTemplate(false);
}
};
@@ -367,15 +367,15 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({ accessToken, userRole })
// Show success message
if (createdGuardrails.length > 0) {
- MessageManager.success(
+ toast.success(
`Created ${createdGuardrails.length} guardrail${createdGuardrails.length > 1 ? "s" : ""}! Complete the policy form to save.`,
);
} else {
- MessageManager.success("Template ready! Complete the policy form to save.");
+ toast.success("Template ready! Complete the policy form to save.");
}
if (failedGuardrails.length > 0) {
- MessageManager.warning(
+ toast.warning(
`Failed to create ${failedGuardrails.length} guardrail(s): ${failedGuardrails.join(", ")}. You may need to create them manually.`,
);
}
@@ -395,7 +395,7 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({ accessToken, userRole })
setTemplateQueue([]);
setTemplateQueueProgress(null);
console.error("Error creating guardrails:", error);
- MessageManager.error("Failed to create guardrails. Please try again.");
+ toast.error("Failed to create guardrails. Please try again.");
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/pipeline_flow_builder.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/pipeline_flow_builder.tsx
index c104781a07e..4bb87b62243 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/pipeline_flow_builder.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/pipeline_flow_builder.tsx
@@ -1,5 +1,5 @@
import React, { useState } from "react";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
@@ -21,7 +21,6 @@ import {
createPolicyVersion,
updatePolicyVersionStatus,
} from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
import { getComplianceDatasetPrompts, getFrameworks } from "@/data/compliancePrompts";
import type { CompliancePrompt } from "@/data/compliancePrompts";
@@ -1412,14 +1411,12 @@ export const FlowBuilderPage: React.FC<FlowBuilderPageProps> = ({
setIsCreatingVersion(true);
try {
const newPolicy = await createPolicyVersion(accessToken, editingPolicy.policy_name);
- NotificationsManager.success("New draft version created");
+ toast.success("New draft version created");
onVersionCreated?.(newPolicy);
const list = await listPolicyVersions(accessToken, editingPolicy.policy_name);
setVersions(list.versions ?? []);
} catch (error) {
- NotificationsManager.fromBackend(
- "Failed to create version: " + (error instanceof Error ? error.message : String(error)),
- );
+ toast.fromError("Failed to create version: " + (error instanceof Error ? error.message : String(error)));
} finally {
setIsCreatingVersion(false);
}
@@ -1434,16 +1431,14 @@ export const FlowBuilderPage: React.FC<FlowBuilderPageProps> = ({
setIsUpdatingStatus(true);
try {
const updated = await updatePolicyVersionStatus(accessToken, editingPolicy.policy_id, "published");
- NotificationsManager.success(
+ toast.success(
"Version published. You can test it in the Playground by selecting this version in the Policies dropdown.",
);
const list = await listPolicyVersions(accessToken, editingPolicy.policy_name ?? "");
setVersions(list.versions ?? []);
onVersionStatusUpdated?.(updated);
} catch (error) {
- NotificationsManager.fromBackend(
- "Failed to publish: " + (error instanceof Error ? error.message : String(error)),
- );
+ toast.fromError("Failed to publish: " + (error instanceof Error ? error.message : String(error)));
} finally {
setIsUpdatingStatus(false);
}
@@ -1454,14 +1449,12 @@ export const FlowBuilderPage: React.FC<FlowBuilderPageProps> = ({
setIsUpdatingStatus(true);
try {
const updated = await updatePolicyVersionStatus(accessToken, editingPolicy.policy_id, "production");
- NotificationsManager.success("Version promoted to production");
+ toast.success("Version promoted to production");
const list = await listPolicyVersions(accessToken, editingPolicy.policy_name ?? "");
setVersions(list.versions ?? []);
onVersionStatusUpdated?.(updated);
} catch (error) {
- NotificationsManager.fromBackend(
- "Failed to promote to production: " + (error instanceof Error ? error.message : String(error)),
- );
+ toast.fromError("Failed to promote to production: " + (error instanceof Error ? error.message : String(error)));
} finally {
setIsUpdatingStatus(false);
}
@@ -1469,17 +1462,17 @@ export const FlowBuilderPage: React.FC<FlowBuilderPageProps> = ({
const handleSave = async () => {
if (!policyName.trim()) {
- MessageManager.error("Please enter a policy name");
+ toast.error("Please enter a policy name");
return;
}
if (!accessToken) {
- MessageManager.error("No access token available");
+ toast.error("No access token available");
return;
}
const emptySteps = pipeline.steps.filter((s) => !s.guardrail);
if (emptySteps.length > 0) {
- MessageManager.error("Please select a guardrail for all steps");
+ toast.error("Please select a guardrail for all steps");
return;
}
@@ -1497,19 +1490,17 @@ export const FlowBuilderPage: React.FC<FlowBuilderPageProps> = ({
if (isEditing && editingPolicy) {
await updatePolicy(accessToken, editingPolicy.policy_id, data as PolicyUpdateRequest);
- NotificationsManager.success("Policy updated successfully");
+ toast.success("Policy updated successfully");
onSuccess();
} else {
await createPolicy(accessToken, data as PolicyCreateRequest);
- NotificationsManager.success("Policy created successfully");
+ toast.success("Policy created successfully");
onSuccess();
onBack();
}
} catch (error) {
console.error("Failed to save policy:", error);
- NotificationsManager.fromBackend(
- "Failed to save policy: " + (error instanceof Error ? error.message : String(error)),
- );
+ toast.fromError("Failed to save policy: " + (error instanceof Error ? error.message : String(error)));
} finally {
setIsSubmitting(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/policy_templates.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/policy_templates.tsx
index 0ff21b30347..46dda1dd11c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/policy_templates.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/policy_templates.tsx
@@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
import { Skeleton } from "@/components/ui/skeleton";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { ShieldCheck, ShieldAlert, FlaskConical, CircleDollarSign, CheckCircle2 } from "lucide-react";
import { getPolicyTemplates } from "@/components/networking";
@@ -159,7 +159,7 @@ const PolicyTemplates: React.FC<PolicyTemplatesProps> = ({
onTemplatesLoaded?.(data);
} catch (error) {
console.error("Error fetching policy templates:", error);
- MessageManager.error("Failed to fetch policy templates");
+ toast.error("Failed to fetch policy templates");
} finally {
setIsLoading(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/projects/_components/ProjectModals/CreateProjectModal.tsx b/ui/litellm-dashboard/src/app/(dashboard)/projects/_components/ProjectModals/CreateProjectModal.tsx
index c7d1f54bd47..6c98a2f5b0b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/projects/_components/ProjectModals/CreateProjectModal.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/projects/_components/ProjectModals/CreateProjectModal.tsx
@@ -1,6 +1,6 @@
import { Modal, Form, Button, Typography } from "antd";
import { FolderAddOutlined } from "@ant-design/icons";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { useCreateProject, ProjectCreateParams } from "@/app/(dashboard)/hooks/projects/useCreateProject";
import { ProjectBaseForm, ProjectFormValues } from "./ProjectBaseForm";
import { buildProjectApiParams } from "./projectFormUtils";
@@ -24,12 +24,12 @@ export function CreateProjectModal({ isOpen, onClose }: CreateProjectModalProps)
createMutation.mutate(params, {
onSuccess: () => {
- MessageManager.success("Project created successfully");
+ toast.success("Project created successfully");
form.resetFields();
onClose();
},
onError: (error) => {
- MessageManager.error(error.message || "Failed to create project");
+ toast.error(error.message || "Failed to create project");
},
});
} catch (error) {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/projects/_components/ProjectModals/EditProjectModal.tsx b/ui/litellm-dashboard/src/app/(dashboard)/projects/_components/ProjectModals/EditProjectModal.tsx
index d8d9973d156..ad3254a773c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/projects/_components/ProjectModals/EditProjectModal.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/projects/_components/ProjectModals/EditProjectModal.tsx
@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { Modal, Form, Button, Typography } from "antd";
import { SaveOutlined } from "@ant-design/icons";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { ProjectResponse } from "@/app/(dashboard)/hooks/projects/useProjects";
import { useUpdateProject, ProjectUpdateParams } from "@/app/(dashboard)/hooks/projects/useUpdateProject";
import { ProjectBaseForm, ProjectFormValues } from "./ProjectBaseForm";
@@ -72,12 +72,12 @@ export function EditProjectModal({ isOpen, project, onClose, onSuccess }: EditPr
{ projectId: project.project_id, params },
{
onSuccess: () => {
- MessageManager.success("Project updated successfully");
+ toast.success("Project updated successfully");
onSuccess?.();
onClose();
},
onError: (error) => {
- MessageManager.error(error.message || "Failed to update project");
+ toast.error(error.message || "Failed to update project");
},
},
);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/add_prompt_form.tsx b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/add_prompt_form.tsx
index c02efa82499..0eae86cd68b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/add_prompt_form.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/add_prompt_form.tsx
@@ -4,7 +4,7 @@ import { TextInput } from "@tremor/react";
import { UploadOutlined } from "@ant-design/icons";
import type { UploadFile, UploadProps } from "antd";
import { convertPromptFileToJson, createPromptCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
const { Option } = Select;
@@ -33,12 +33,12 @@ const AddPromptForm: React.FC<AddPromptFormProps> = ({ visible, onClose, accessT
const values = await form.validateFields();
if (!accessToken) {
- NotificationsManager.fromBackend("Access token is required");
+ toast.fromError("Access token is required");
return;
}
if (promptIntegration === "dotprompt" && fileList.length === 0) {
- NotificationsManager.fromBackend("Please upload a .prompt file");
+ toast.fromError("Please upload a .prompt file");
return;
}
@@ -67,7 +67,7 @@ const AddPromptForm: React.FC<AddPromptFormProps> = ({ visible, onClose, accessT
};
} catch (conversionError) {
console.error("Error converting prompt file:", conversionError);
- NotificationsManager.fromBackend("Failed to convert prompt file to JSON");
+ toast.fromError("Failed to convert prompt file to JSON");
setLoading(false);
return;
}
@@ -76,12 +76,12 @@ const AddPromptForm: React.FC<AddPromptFormProps> = ({ visible, onClose, accessT
// Create the prompt
try {
await createPromptCall(accessToken, promptData);
- NotificationsManager.success("Prompt created successfully!");
+ toast.success("Prompt created successfully!");
handleCancel();
onSuccess();
} catch (createError) {
console.error("Error creating prompt:", createError);
- NotificationsManager.fromBackend("Failed to create prompt");
+ toast.fromError("Failed to create prompt");
}
} catch (error) {
console.error("Form validation error:", error);
@@ -93,7 +93,7 @@ const AddPromptForm: React.FC<AddPromptFormProps> = ({ visible, onClose, accessT
const uploadProps: UploadProps = {
beforeUpload: (file) => {
if (!file.name.endsWith(".prompt")) {
- NotificationsManager.fromBackend("Please upload a .prompt file");
+ toast.fromError("Please upload a .prompt file");
return false;
}
return false; // Prevent automatic upload
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/index.tsx
index f9bba3ce661..3594e933704 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/index.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/index.tsx
@@ -6,7 +6,7 @@ import PromptTable from "./PromptTable";
import PromptInfoView from "./prompt_info";
import AddPromptForm from "./add_prompt_form";
import PromptEditorView from "./prompt_editor_view";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { isProxyAdminRole } from "@/utils/roles";
import { Button } from "@/components/ui/button";
import {
@@ -121,11 +121,11 @@ const PromptsPanel: React.FC<PromptsProps> = ({ accessToken, userRole }) => {
setIsDeleting(true);
try {
await deletePromptCall(accessToken, promptToDelete.id);
- NotificationsManager.success(`Prompt "${promptToDelete.name}" deleted successfully`);
+ toast.success(`Prompt "${promptToDelete.name}" deleted successfully`);
fetchPrompts(); // Refresh the list
} catch (error) {
console.error("Error deleting prompt:", error);
- NotificationsManager.fromBackend("Failed to delete prompt");
+ toast.fromError("Failed to delete prompt");
} finally {
setIsDeleting(false);
setPromptToDelete(null);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/PromptCodeSnippets.tsx b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/PromptCodeSnippets.tsx
index 4dd983d659b..f84f872dc9b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/PromptCodeSnippets.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/PromptCodeSnippets.tsx
@@ -2,7 +2,7 @@ import React, { useState } from "react";
import { CodeIcon, CopyIcon } from "lucide-react";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { coy } from "react-syntax-highlighter/dist/esm/styles/prism";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
@@ -269,7 +269,7 @@ main();`;
variant="outline"
onClick={() => {
navigator.clipboard.writeText(generatedCode);
- NotificationsManager.success("Copied to clipboard!");
+ toast.success("Copied to clipboard!");
}}
>
<CopyIcon />
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/conversation_panel/useConversation.ts b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/conversation_panel/useConversation.ts
index d7852ca8bb4..c9634fd7338 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/conversation_panel/useConversation.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/conversation_panel/useConversation.ts
@@ -1,5 +1,5 @@
import { useState, useRef, useEffect } from "react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { TokenUsage } from "@/components/chat_ui/ResponseMetrics";
import { Message } from "./types";
import { convertToDotPrompt, extractVariables } from "../utils";
@@ -37,12 +37,12 @@ export const useConversation = (prompt: any, accessToken: string | null) => {
const handleSendMessage = async () => {
if (!accessToken) {
- NotificationsManager.fromBackend("Access token is required");
+ toast.fromError("Access token is required");
return;
}
if (extractedVariables.length > 0 && !allVariablesFilled) {
- NotificationsManager.fromBackend("Please fill in all template variables");
+ toast.fromError("Please fill in all template variables");
return;
}
@@ -198,14 +198,14 @@ export const useConversation = (prompt: any, accessToken: string | null) => {
abortController.abort();
setAbortController(null);
setIsLoading(false);
- NotificationsManager.info("Request cancelled");
+ toast.info("Request cancelled");
}
};
const handleClearConversation = () => {
setMessages([]);
setVariablesFilled(false);
- NotificationsManager.success("Chat history cleared.");
+ toast.success("Chat history cleared.");
};
const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/index.tsx
index e09ca787a69..bc75d172cf0 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/index.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_editor_view/index.tsx
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import ToolModal from "../tool_modal";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { createPromptCall, updatePromptCall, getPromptInfo } from "@/components/networking";
import { PromptType, PromptEditorViewProps, Tool } from "./types";
import { convertToDotPrompt, parseExistingPrompt } from "./utils";
@@ -21,7 +21,7 @@ const PromptEditorView: React.FC<PromptEditorViewProps> = ({ onClose, onSuccess,
return parseExistingPrompt(initialPromptData);
} catch (error) {
console.error("Error parsing existing prompt:", error);
- NotificationsManager.fromBackend("Failed to parse prompt data");
+ toast.fromError("Failed to parse prompt data");
}
}
return {
@@ -142,7 +142,7 @@ const PromptEditorView: React.FC<PromptEditorViewProps> = ({ onClose, onSuccess,
setShowToolModal(false);
setEditingToolIndex(null);
} catch (error) {
- NotificationsManager.fromBackend("Invalid JSON format");
+ toast.fromError("Invalid JSON format");
}
};
@@ -169,10 +169,9 @@ const PromptEditorView: React.FC<PromptEditorViewProps> = ({ onClose, onSuccess,
// Store the version number or construct versioned ID for tracking
const versionNum = versionData.version || 1;
setActiveVersionId(`${versionData.prompt_id}.v${versionNum}`);
- // NotificationsManager.success(`Loaded version v${versionNum}`);
} catch (error) {
console.error("Error loading version:", error);
- NotificationsManager.fromBackend("Failed to load prompt version");
+ toast.fromError("Failed to load prompt version");
}
};
@@ -186,12 +185,12 @@ const PromptEditorView: React.FC<PromptEditorViewProps> = ({ onClose, onSuccess,
const handleSave = async () => {
if (!accessToken) {
- NotificationsManager.fromBackend("Access token is required");
+ toast.fromError("Access token is required");
return;
}
if (!prompt.name || prompt.name.trim() === "") {
- NotificationsManager.fromBackend("Please enter a valid prompt name");
+ toast.fromError("Please enter a valid prompt name");
return;
}
@@ -215,16 +214,16 @@ const PromptEditorView: React.FC<PromptEditorViewProps> = ({ onClose, onSuccess,
if (editMode && initialPromptData?.prompt_spec?.prompt_id) {
await updatePromptCall(accessToken, initialPromptData.prompt_spec.prompt_id, promptData);
- NotificationsManager.success("Prompt updated successfully!");
+ toast.success("Prompt updated successfully!");
} else {
await createPromptCall(accessToken, promptData);
- NotificationsManager.success("Prompt created successfully!");
+ toast.success("Prompt created successfully!");
}
onSuccess();
onClose();
} catch (error) {
console.error("Error saving prompt:", error);
- NotificationsManager.fromBackend(editMode ? "Failed to update prompt" : "Failed to save prompt");
+ toast.fromError(editMode ? "Failed to update prompt" : "Failed to save prompt");
} finally {
setIsSaving(false);
setShowNameModal(false);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_info.tsx b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_info.tsx
index a3ea5a54cda..5335ba06060 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_info.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/prompts/_components/prompt_info.tsx
@@ -29,7 +29,7 @@ import {
} from "@/components/networking";
import { copyToClipboard as utilCopyToClipboard } from "@/utils/dataUtils";
import { CheckIcon, CopyIcon } from "lucide-react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import PromptCodeSnippets from "./prompt_editor_view/PromptCodeSnippets";
import { extractModel, extractTemplateVariables, getBasePromptId, getCurrentVersion } from "./prompt_utils";
@@ -77,7 +77,7 @@ const PromptInfoView: React.FC<PromptInfoProps> = ({ promptId, onClose, accessTo
}
setSelectedVersion(response.prompt_spec.version || null);
} catch (error) {
- NotificationsManager.fromBackend("Failed to load prompt information");
+ toast.fromError("Failed to load prompt information");
console.error("Error fetching prompt info:", error);
} finally {
setLoading(false);
@@ -156,12 +156,12 @@ const PromptInfoView: React.FC<PromptInfoProps> = ({ promptId, onClose, accessTo
setIsDeleting(true);
try {
await deletePromptCall(accessToken, basePromptId);
- NotificationsManager.success(`Prompt "${basePromptId}" deleted successfully`);
+ toast.success(`Prompt "${basePromptId}" deleted successfully`);
onDelete?.();
onClose();
} catch (error) {
console.error("Error deleting prompt:", error);
- NotificationsManager.fromBackend("Failed to delete prompt");
+ toast.fromError("Failed to delete prompt");
} finally {
setIsDeleting(false);
setShowDeleteConfirm(false);
@@ -184,7 +184,7 @@ const PromptInfoView: React.FC<PromptInfoProps> = ({ promptId, onClose, accessTo
setPromptTemplate(response.raw_prompt_template);
setRawApiResponse(response);
} catch {
- NotificationsManager.fromBackend(`Failed to load version v${versionNum}`);
+ toast.fromError(`Failed to load version v${versionNum}`);
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/CreateSearchTools.tsx b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/CreateSearchTools.tsx
index 6c8cef0b1a1..2af09bebb2e 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/CreateSearchTools.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/CreateSearchTools.tsx
@@ -5,7 +5,7 @@ import { Button, TextInput } from "@tremor/react";
import { Form, Input, Modal, Select, Tooltip, Typography } from "antd";
import React, { useState } from "react";
import { Logo } from "@/components/molecules/logo/Logo";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { createSearchTool, fetchAvailableSearchProviders } from "@/components/networking";
import SearchConnectionTest from "./SearchConnectionTest";
import { AvailableSearchProvider, SearchTool } from "./types";
@@ -98,14 +98,14 @@ const CreateSearchTool: React.FC<CreateSearchToolProps> = ({
if (accessToken != null) {
const response = await createSearchTool(accessToken, payload);
- NotificationsManager.success("Search tool created successfully");
+ toast.success("Search tool created successfully");
form.resetFields();
setFormValues({});
setModalVisible(false);
onCreateSuccess(response);
}
} catch (error) {
- NotificationsManager.error("Error creating search tool: " + error);
+ toast.error("Error creating search tool: " + error);
} finally {
setIsLoading(false);
}
@@ -128,7 +128,7 @@ const CreateSearchTool: React.FC<CreateSearchToolProps> = ({
// Show the modal with the fresh test
setIsTestModalVisible(true);
} catch (error) {
- NotificationsManager.error("Please fill in Search Provider and API Key before testing");
+ toast.error("Please fill in Search Provider and API Key before testing");
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchConnectionTest.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchConnectionTest.test.tsx
index cfe5d4d843e..59d8af5ec01 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchConnectionTest.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchConnectionTest.test.tsx
@@ -3,7 +3,7 @@ import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
import SearchConnectionTest from "./SearchConnectionTest";
import * as networking from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
testSearchToolConnection: vi.fn(),
@@ -68,7 +68,7 @@ describe("SearchConnectionTest", () => {
render(<SearchConnectionTest {...defaultProps} onTestComplete={onTestComplete} />);
await waitFor(() => {
- expect(NotificationsManager.success).toHaveBeenCalledWith("Connection test successful!");
+ expect(toast.success).toHaveBeenCalledWith("Connection test successful!");
});
expect(onTestComplete).toHaveBeenCalledTimes(1);
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchConnectionTest.tsx b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchConnectionTest.tsx
index 446d9a71517..339d51823f6 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchConnectionTest.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchConnectionTest.tsx
@@ -1,6 +1,6 @@
import { AlertTriangle, CheckCircle2, Info } from "lucide-react";
import React, { useEffect, useState } from "react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { testSearchToolConnection } from "@/components/networking";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
@@ -30,7 +30,7 @@ const SearchConnectionTest: React.FC<SearchConnectionTestProps> = ({ litellmPara
const result = await testSearchToolConnection(accessToken, litellmParams);
setTestResult(result);
if (result.status === "success") {
- NotificationsManager.success("Connection test successful!");
+ toast.success("Connection test successful!");
}
} catch (error) {
setTestResult({
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchToolTester.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchToolTester.test.tsx
index 196eb6c88b0..4a1fe1eafe7 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchToolTester.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchToolTester.test.tsx
@@ -3,7 +3,7 @@ import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { SearchToolTester } from "./SearchToolTester";
import * as networking from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
searchToolQueryCall: vi.fn(),
@@ -293,7 +293,7 @@ describe("SearchToolTester", () => {
const searchButton = screen.getByRole("button", { name: /search/i });
await user.click(searchButton);
await waitFor(() => {
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith("Failed to query search tool");
+ expect(toast.fromError).toHaveBeenCalledWith("Failed to query search tool");
});
consoleSpy.mockRestore();
});
@@ -360,7 +360,7 @@ describe("SearchToolTester", () => {
});
const clearButton = screen.getByRole("button", { name: /clear all/i });
await user.click(clearButton);
- expect(NotificationsManager.success).toHaveBeenCalledWith("Search history cleared");
+ expect(toast.success).toHaveBeenCalledWith("Search history cleared");
expect(screen.queryByText("Previous Searches")).not.toBeInTheDocument();
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchToolTester.tsx b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchToolTester.tsx
index 95772608235..8142daf1e2a 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchToolTester.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchToolTester.tsx
@@ -1,8 +1,7 @@
import React, { useState } from "react";
import { ExternalLink, Search } from "lucide-react";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { searchToolQueryCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
@@ -39,7 +38,7 @@ export const SearchToolTester: React.FC<SearchToolTesterProps> = ({ searchToolNa
const handleSearch = async () => {
if (!query.trim()) {
- MessageManager.warning("Please enter a search query");
+ toast.warning("Please enter a search query");
return;
}
@@ -61,7 +60,7 @@ export const SearchToolTester: React.FC<SearchToolTesterProps> = ({ searchToolNa
setSearchHistory((prev) => [historyEntry, ...prev]);
} catch (error) {
console.error("Error querying search tool:", error);
- NotificationsManager.fromBackend("Failed to query search tool");
+ toast.fromError("Failed to query search tool");
} finally {
setIsLoading(false);
}
@@ -74,7 +73,7 @@ export const SearchToolTester: React.FC<SearchToolTesterProps> = ({ searchToolNa
const clearHistory = () => {
setSearchHistory([]);
setExpandedResults({});
- NotificationsManager.success("Search history cleared");
+ toast.success("Search history cleared");
};
const toggleResultExpansion = (historyIndex: number, resultIndex: number) => {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchTools.tsx b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchTools.tsx
index c9e2a46a861..0ef78f2496a 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchTools.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/search-tools/_components/SearchTools.tsx
@@ -4,7 +4,7 @@ import { Button, Text, Title } from "@tremor/react";
import { Form, Input, Modal, Select } from "antd";
import React, { useState } from "react";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
deleteSearchTool,
fetchAvailableSearchProviders,
@@ -93,13 +93,13 @@ const SearchTools: React.FC<SearchToolsProps> = ({ accessToken, userRole, userID
setIsDeleting(true);
try {
await deleteSearchTool(accessToken, toolIdToDelete);
- NotificationsManager.success("Deleted search tool successfully");
+ toast.success("Deleted search tool successfully");
setIsDeleteModalOpen(false);
setToolToDelete(null);
refetch();
} catch (error) {
console.error("Error deleting the search tool:", error);
- NotificationsManager.error("Failed to delete search tool");
+ toast.error("Failed to delete search tool");
} finally {
setIsDeleting(false);
}
@@ -142,14 +142,14 @@ const SearchTools: React.FC<SearchToolsProps> = ({ accessToken, userRole, userID
};
await updateSearchTool(accessToken, selectedToolId, searchToolData);
- NotificationsManager.success("Search tool updated successfully");
+ toast.success("Search tool updated successfully");
setEditModalVisible(false);
form.resetFields();
setSelectedToolId(null);
refetch();
} catch (error) {
console.error("Failed to update search tool:", error);
- NotificationsManager.error("Failed to update search tool");
+ toast.error("Failed to update search tool");
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.tsx
index 47fc8f41307..93834937872 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/ClaudeCodePluginsPanel.tsx
@@ -14,7 +14,7 @@ import AddPluginForm from "./add_plugin_form";
import PluginTable from "./PluginTable";
import SkillDetail from "@/components/claude_code_plugins/skill_detail";
import { isAdminRole } from "@/utils/roles";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Plugin, ListPluginsResponse } from "@/components/claude_code_plugins/types";
interface ClaudeCodePluginsPanelProps {
@@ -66,11 +66,11 @@ const ClaudeCodePluginsPanel: React.FC<ClaudeCodePluginsPanelProps> = ({ accessT
setIsDeleting(true);
try {
await deleteClaudeCodePlugin(accessToken, pluginToDelete.name);
- NotificationsManager.success(`Skill "${pluginToDelete.displayName}" deleted successfully`);
+ toast.success(`Skill "${pluginToDelete.displayName}" deleted successfully`);
fetchPlugins();
} catch (error) {
console.error("Error deleting skill:", error);
- NotificationsManager.error("Failed to delete skill");
+ toast.error("Failed to delete skill");
} finally {
setIsDeleting(false);
setPluginToDelete(null);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.test.tsx
index 713cee7682c..1058d4d0466 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.test.tsx
@@ -4,18 +4,14 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
import { renderWithProviders } from "@/../tests/test-utils";
import AddPluginForm from "./add_plugin_form";
import { registerClaudeCodePlugin } from "@/components/networking";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
registerClaudeCodePlugin: vi.fn().mockResolvedValue({ status: "success" }),
}));
-vi.mock("@/components/molecules/message_manager", () => ({
- default: { error: vi.fn(), success: vi.fn() },
-}));
-
const mockRegister = vi.mocked(registerClaudeCodePlugin);
-const mockMessageError = vi.mocked(MessageManager.error);
+const mockMessageError = vi.mocked(toast.error);
const DEFAULT_PROPS = {
visible: true,
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.tsx b/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.tsx
index 3be4a0fa085..0496d916171 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/skills/_components/add_plugin_form.tsx
@@ -2,7 +2,7 @@ import React, { useState } from "react";
import { Modal } from "antd";
import { CircleHelp } from "lucide-react";
import { z } from "zod/v4";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { registerClaudeCodePlugin } from "@/components/networking";
import { FieldGroup } from "@/components/shared/form/field";
import { FormField } from "@/components/shared/form/FormField";
@@ -146,34 +146,34 @@ const AddPluginForm: React.FC<AddPluginFormProps> = ({ visible, onClose, accessT
const handleSubmit = async (values: AddPluginFormValues) => {
if (!accessToken) {
- MessageManager.error("No access token available");
+ toast.error("No access token available");
return;
}
if (!urlPreview) {
- MessageManager.error("Please enter a valid repository URL");
+ toast.error("Please enter a valid repository URL");
return;
}
if (!validatePluginName(values.name)) {
- MessageManager.error("Skill name must be kebab-case (lowercase letters, numbers, and hyphens only)");
+ toast.error("Skill name must be kebab-case (lowercase letters, numbers, and hyphens only)");
return;
}
if (values.version && !isValidSemanticVersion(values.version)) {
- MessageManager.error("Version must be in semantic versioning format (e.g., 1.0.0)");
+ toast.error("Version must be in semantic versioning format (e.g., 1.0.0)");
return;
}
if (values.authorEmail && !isValidEmail(values.authorEmail)) {
- MessageManager.error("Invalid email format");
+ toast.error("Invalid email format");
return;
}
setIsSubmitting(true);
try {
await registerClaudeCodePlugin(accessToken, buildRegisterRequest(values, urlPreview.parsed));
- MessageManager.success("Skill registered successfully");
+ toast.success("Skill registered successfully");
form.reset(EMPTY_VALUES);
setUrlPreview(null);
setUrlEncodesSubdir(false);
@@ -181,7 +181,7 @@ const AddPluginForm: React.FC<AddPluginFormProps> = ({ visible, onClose, accessT
onClose();
} catch (error) {
console.error("Error registering skill:", error);
- MessageManager.error(error instanceof Error && error.message ? error.message : "Failed to register skill");
+ toast.error(error instanceof Error && error.message ? error.message : "Failed to register skill");
} finally {
setIsSubmitting(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/index.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/index.test.tsx
index e5740a89822..e5016edd6fc 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/index.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/index.test.tsx
@@ -13,14 +13,6 @@ vi.mock("@/components/networking", () => ({
modelInfoCall: vi.fn(),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- __esModule: true,
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
vi.mock("./TagTable", () => ({
__esModule: true,
default: ({ isLoading, onDelete }: { isLoading?: boolean; onDelete: (tagName: string) => void }) => (
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/index.tsx
index 42b51a499cb..a04afcd6d45 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/index.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/index.tsx
@@ -6,7 +6,7 @@ import { modelInfoCall } from "@/components/networking";
import { tagCreateCall, tagListCall, tagDeleteCall } from "@/components/networking";
import { Tag } from "@/components/tag_management/types";
import TagTable from "./TagTable";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
import CreateTagModal from "./components/CreateTagModal";
@@ -48,7 +48,7 @@ const TagManagement: React.FC<TagProps> = ({ accessToken, userID, userRole }) =>
setTags(Object.values(response));
} catch (error) {
console.error("Error fetching tags:", error);
- NotificationsManager.fromBackend("Error fetching tags: " + error);
+ toast.fromError("Error fetching tags: " + error);
} finally {
setIsLoadingTags(false);
}
@@ -73,12 +73,12 @@ const TagManagement: React.FC<TagProps> = ({ accessToken, userID, userRole }) =>
rpm_limit: formValues.rpm_limit,
budget_duration: formValues.budget_duration,
});
- NotificationsManager.success("Tag created successfully");
+ toast.success("Tag created successfully");
setIsCreateModalVisible(false);
fetchTags();
} catch (error) {
console.error("Error creating tag:", error);
- NotificationsManager.fromBackend("Error creating tag: " + error);
+ toast.fromError("Error creating tag: " + error);
}
};
@@ -92,11 +92,11 @@ const TagManagement: React.FC<TagProps> = ({ accessToken, userID, userRole }) =>
setIsDeleting(true);
try {
await tagDeleteCall(accessToken, tagToDelete);
- NotificationsManager.success("Tag deleted successfully");
+ toast.success("Tag deleted successfully");
fetchTags();
} catch (error) {
console.error("Error deleting tag:", error);
- NotificationsManager.fromBackend("Error deleting tag: " + error);
+ toast.fromError("Error deleting tag: " + error);
} finally {
setIsDeleting(false);
setIsDeleteModalOpen(false);
@@ -114,7 +114,7 @@ const TagManagement: React.FC<TagProps> = ({ accessToken, userID, userRole }) =>
}
} catch (error) {
console.error("Error fetching models:", error);
- NotificationsManager.fromBackend("Error fetching models: " + error);
+ toast.fromError("Error fetching models: " + error);
}
};
fetchModels();
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/tag_info.integration.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/tag_info.integration.test.tsx
index 126626057a0..d502b5f074b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/tag_info.integration.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/tag_info.integration.test.tsx
@@ -21,11 +21,6 @@ vi.mock("@/components/organisms/create_key_button", () => ({
),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- __esModule: true,
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
const mockTagInfoCall = vi.mocked(tagInfoCall);
const mockTagUpdateCall = vi.mocked(tagUpdateCall);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/tag_info.tsx b/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/tag_info.tsx
index 724c8e24afe..353dd720811 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/tag_info.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/tag-management/_components/tag_info.tsx
@@ -8,7 +8,7 @@ import { fetchUserModels } from "@/components/organisms/create_key_button";
import { getModelDisplayName } from "@/components/key_team_helpers/fetch_available_models_team_key";
import { tagInfoCall, tagUpdateCall } from "@/components/networking";
import { Tag, TagUpdateRequest } from "@/components/tag_management/types";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import NumericalInput from "@/components/shared/numerical_input";
import BudgetDurationDropdown from "@/components/common_components/budget_duration_dropdown";
import { FieldGroup } from "@/components/shared/form/field";
@@ -175,7 +175,7 @@ const TagInfoView: React.FC<TagInfoViewProps> = ({ tagId, onClose, accessToken,
}
} catch (error) {
console.error("Error fetching tag details:", error);
- NotificationsManager.fromBackend("Error fetching tag details: " + error);
+ toast.fromError("Error fetching tag details: " + error);
}
};
@@ -203,12 +203,12 @@ const TagInfoView: React.FC<TagInfoViewProps> = ({ tagId, onClose, accessToken,
rpm_limit: undefined,
budget_duration: values.budget_duration,
});
- NotificationsManager.success("Tag updated successfully");
+ toast.success("Tag updated successfully");
setIsEditing(false);
fetchTagDetails();
} catch (error) {
console.error("Error updating tag:", error);
- NotificationsManager.fromBackend("Error updating tag: " + error);
+ toast.fromError("Error updating tag: " + error);
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.test.tsx
index d8d46c361a2..0d90aaa995c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.test.tsx
@@ -3,22 +3,14 @@ import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import TransformRequestPanel from "./TransformRequestPanel";
import { transformRequestCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
transformRequestCall: vi.fn(),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- info: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
const transformRequestCallMock = vi.mocked(transformRequestCall);
-const notify = vi.mocked(NotificationsManager);
+const notify = vi.mocked(toast);
const ACCESS_TOKEN = "sk-test-token";
@@ -109,7 +101,7 @@ describe("TransformRequestPanel", () => {
await user.type(textarea, "not json");
await user.click(getTransformButton());
- await waitFor(() => expect(notify.fromBackend).toHaveBeenCalledWith("Invalid JSON in request body"));
+ await waitFor(() => expect(notify.fromError).toHaveBeenCalledWith("Invalid JSON in request body"));
expect(transformRequestCallMock).not.toHaveBeenCalled();
});
@@ -120,7 +112,7 @@ describe("TransformRequestPanel", () => {
await user.click(getTransformButton());
- await waitFor(() => expect(notify.fromBackend).toHaveBeenCalledWith("No access token found"));
+ await waitFor(() => expect(notify.fromError).toHaveBeenCalledWith("No access token found"));
expect(transformRequestCallMock).not.toHaveBeenCalled();
});
@@ -133,7 +125,7 @@ describe("TransformRequestPanel", () => {
await user.click(getTransformButton());
- await waitFor(() => expect(notify.fromBackend).toHaveBeenCalledWith("Failed to transform request"));
+ await waitFor(() => expect(notify.fromError).toHaveBeenCalledWith("Failed to transform request"));
expect(screen.getByText(/https:\/\/api\.openai\.com\/v1\/chat\/completions/)).toBeInTheDocument();
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.tsx b/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.tsx
index 0c7f10eab0e..cf1eecdb03f 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/transform-request/TransformRequestPanel.tsx
@@ -5,7 +5,7 @@ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }
import { Textarea } from "@/components/ui/textarea";
import { UiLoadingSpinner } from "@/components/ui/ui-loading-spinner";
import { transformRequestCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface TransformRequestPanelProps {
accessToken: string | null;
@@ -69,7 +69,7 @@ ${formattedBody}
try {
requestBody = JSON.parse(originalRequestJSON);
} catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in request body");
+ toast.fromError("Invalid JSON in request body");
setIsLoading(false);
return;
}
@@ -82,7 +82,7 @@ ${formattedBody}
// Make the API call using fetch
if (!accessToken) {
- NotificationsManager.fromBackend("No access token found");
+ toast.fromError("No access token found");
setIsLoading(false);
return;
}
@@ -100,17 +100,17 @@ ${formattedBody}
// Update state with the formatted curl command
setTransformedResponse(formattedCurl);
- NotificationsManager.success("Request transformed successfully");
+ toast.success("Request transformed successfully");
} else {
// Handle the case where the API returns a different format
// Try to extract the parts from a string response if needed
const rawText = typeof data === "string" ? data : JSON.stringify(data);
setTransformedResponse(rawText);
- NotificationsManager.info("Transformed request received in unexpected format");
+ toast.info("Transformed request received in unexpected format");
}
} catch (err) {
console.error("Error transforming request:", err);
- NotificationsManager.fromBackend("Failed to transform request");
+ toast.fromError("Failed to transform request");
} finally {
setIsLoading(false);
}
@@ -191,7 +191,7 @@ ${formattedBody}
className="absolute top-2 right-2"
onClick={() => {
navigator.clipboard.writeText(transformedResponse || "");
- NotificationsManager.success("Copied to clipboard");
+ toast.success("Copied to clipboard");
}}
>
<Copy />
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/ui-theme/UIThemeSettings.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/ui-theme/UIThemeSettings.test.tsx
index 20f8960ae3a..e8ea6a8fad2 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/ui-theme/UIThemeSettings.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/ui-theme/UIThemeSettings.test.tsx
@@ -2,7 +2,7 @@ import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import UIThemeSettings from "./UIThemeSettings";
@@ -18,11 +18,6 @@ vi.mock("@/components/networking", () => ({
getGlobalLitellmHeaderName: () => "Authorization",
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- __esModule: true,
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
const LOGO_PLACEHOLDER = "https://example.com/logo.png";
const FAVICON_PLACEHOLDER = "https://example.com/favicon.ico";
@@ -83,9 +78,7 @@ describe("UIThemeSettings", () => {
logo_url: "https://a.test/logo.png",
favicon_url: "https://a.test/fav.ico",
});
- await waitFor(() =>
- expect(NotificationsManager.success).toHaveBeenCalledWith("Theme settings updated successfully!"),
- );
+ await waitFor(() => expect(toast.success).toHaveBeenCalledWith("Theme settings updated successfully!"));
});
it("should surface a backend failure when saving fails", async () => {
@@ -97,10 +90,8 @@ describe("UIThemeSettings", () => {
await user.click(screen.getByRole("button", { name: "Save Changes" }));
- await waitFor(() =>
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith("Failed to update theme settings"),
- );
- expect(NotificationsManager.success).not.toHaveBeenCalled();
+ await waitFor(() => expect(toast.fromError).toHaveBeenCalledWith("Failed to update theme settings"));
+ expect(toast.success).not.toHaveBeenCalled();
});
it("should clear both inputs and persist nulls when resetting to default", async () => {
@@ -123,6 +114,6 @@ describe("UIThemeSettings", () => {
expect(screen.getByPlaceholderText(FAVICON_PLACEHOLDER)).toHaveValue("");
expect(setLogoUrl).toHaveBeenLastCalledWith(null);
expect(setFaviconUrl).toHaveBeenLastCalledWith(null);
- await waitFor(() => expect(NotificationsManager.success).toHaveBeenCalledWith("Theme settings reset to default!"));
+ await waitFor(() => expect(toast.success).toHaveBeenCalledWith("Theme settings reset to default!"));
});
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/ui-theme/UIThemeSettings.tsx b/ui/litellm-dashboard/src/app/(dashboard)/ui-theme/UIThemeSettings.tsx
index 4da93d8e0b9..8d7a0fa3de2 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/ui-theme/UIThemeSettings.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/ui-theme/UIThemeSettings.tsx
@@ -6,7 +6,7 @@ import { Label } from "@/components/ui/label";
import { UiLoadingSpinner } from "@/components/ui/ui-loading-spinner";
import { useTheme } from "@/contexts/ThemeContext";
import { getProxyBaseUrl, getGlobalLitellmHeaderName } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface UIThemeSettingsProps {
userID: string | null;
@@ -66,7 +66,7 @@ const UIThemeSettings: React.FC<UIThemeSettingsProps> = ({ userID, userRole, acc
}),
});
if (response.ok) {
- NotificationsManager.success("Theme settings updated successfully!");
+ toast.success("Theme settings updated successfully!");
setLogoUrl(logoUrlInput || null);
setFaviconUrl(faviconUrlInput || null);
} else {
@@ -74,7 +74,7 @@ const UIThemeSettings: React.FC<UIThemeSettingsProps> = ({ userID, userRole, acc
}
} catch (error) {
console.error("Error updating theme settings:", error);
- NotificationsManager.fromBackend("Failed to update theme settings");
+ toast.fromError("Failed to update theme settings");
} finally {
setLoading(false);
}
@@ -98,13 +98,13 @@ const UIThemeSettings: React.FC<UIThemeSettingsProps> = ({ userID, userRole, acc
body: JSON.stringify({ logo_url: null, favicon_url: null }),
});
if (response.ok) {
- NotificationsManager.success("Theme settings reset to default!");
+ toast.success("Theme settings reset to default!");
} else {
throw new Error("Failed to reset");
}
} catch (error) {
console.error("Error resetting theme settings:", error);
- NotificationsManager.fromBackend("Failed to reset theme settings");
+ toast.fromError("Failed to reset theme settings");
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/BulkEditUsers.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/BulkEditUsers.test.tsx
index e49ac854e6d..f0a8873a67c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/BulkEditUsers.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/BulkEditUsers.test.tsx
@@ -3,7 +3,7 @@ import { describe, expect, it, vi, beforeEach } from "vitest";
import { renderWithProviders, screen, waitFor } from "../../../../../tests/test-utils";
import BulkEditUserModal from "./BulkEditUsers";
import { userBulkUpdateUserCall, teamBulkMemberAddCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
userBulkUpdateUserCall: vi.fn(),
@@ -185,7 +185,7 @@ describe("BulkEditUserModal", () => {
await user.click(submitButton);
await waitFor(() => {
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith("Access token not found");
+ expect(toast.fromError).toHaveBeenCalledWith("Access token not found");
});
});
@@ -239,7 +239,7 @@ describe("BulkEditUserModal", () => {
await user.click(submitButton);
await waitFor(() => {
- expect(NotificationsManager.success).toHaveBeenCalledWith("Updated 2 user(s)");
+ expect(toast.success).toHaveBeenCalledWith("Updated 2 user(s)");
});
});
@@ -261,7 +261,7 @@ describe("BulkEditUserModal", () => {
await user.click(submitButton);
await waitFor(() => {
- expect(NotificationsManager.success).toHaveBeenCalledWith("Updated all users (100 total)");
+ expect(toast.success).toHaveBeenCalledWith("Updated all users (100 total)");
});
});
@@ -275,7 +275,7 @@ describe("BulkEditUserModal", () => {
await user.click(submitButton);
await waitFor(() => {
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith("Failed to perform bulk operations");
+ expect(toast.fromError).toHaveBeenCalledWith("Failed to perform bulk operations");
});
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/BulkEditUsers.tsx b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/BulkEditUsers.tsx
index 7ea53352807..207cee4bc1b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/BulkEditUsers.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/BulkEditUsers.tsx
@@ -2,8 +2,7 @@ import React, { useState } from "react";
import { Modal, Typography, Divider, Table, Select, InputNumber, Card, Space, Checkbox } from "antd";
import { userBulkUpdateUserCall, teamBulkMemberAddCall, Member } from "@/components/networking";
import { UserEditView } from "./user_edit_view";
-import NotificationsManager from "@/components/molecules/notifications_manager";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { MoneyCell } from "@/components/shared/table_cells";
const { Text, Title } = Typography;
@@ -71,7 +70,7 @@ const BulkEditUserModal: React.FC<BulkEditUserModalProps> = ({
const handleSubmit = async (formValues: any) => {
if (!accessToken) {
- NotificationsManager.fromBackend("Access token not found");
+ toast.fromError("Access token not found");
return;
}
@@ -107,7 +106,7 @@ const BulkEditUserModal: React.FC<BulkEditUserModalProps> = ({
const hasTeamAdditions = addToTeams && selectedTeams.length > 0;
if (!hasUserUpdates && !hasTeamAdditions) {
- NotificationsManager.fromBackend("Please modify at least one field or select teams to add users to");
+ toast.fromError("Please modify at least one field or select teams to add users to");
return;
}
@@ -176,12 +175,12 @@ const BulkEditUserModal: React.FC<BulkEditUserModalProps> = ({
}
if (failedTeams.length > 0) {
- MessageManager.warning(`Failed to add users to ${failedTeams.length} team(s)`);
+ toast.warning(`Failed to add users to ${failedTeams.length} team(s)`);
}
}
if (successMessages.length > 0) {
- NotificationsManager.success(successMessages.join(". "));
+ toast.success(successMessages.join(". "));
}
// Reset team management state
@@ -194,7 +193,7 @@ const BulkEditUserModal: React.FC<BulkEditUserModalProps> = ({
onCancel();
} catch (error) {
console.error("Bulk operation failed:", error);
- NotificationsManager.fromBackend("Failed to perform bulk operations");
+ toast.fromError("Failed to perform bulk operations");
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/default-user-settings/DefaultUserSettingsForm.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/default-user-settings/DefaultUserSettingsForm.test.tsx
index cc24931b2b3..15ab243b868 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/default-user-settings/DefaultUserSettingsForm.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/default-user-settings/DefaultUserSettingsForm.test.tsx
@@ -35,7 +35,7 @@ vi.mock("@/components/ModelSelect/ModelSelect", async (importOriginal) => {
};
});
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { DefaultUserSettingsForm } from "./DefaultUserSettingsForm";
import type { InternalUserSettings } from "./mapper";
@@ -278,7 +278,7 @@ describe("DefaultUserSettingsForm", () => {
expect(await screen.findByRole("button", { name: "Edit Settings" })).toBeInTheDocument();
expect(await screen.findByText("250")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Save Changes" })).not.toBeInTheDocument();
- expect(NotificationsManager.success).toHaveBeenCalledWith("Default user settings updated successfully");
+ expect(toast.success).toHaveBeenCalledWith("Default user settings updated successfully");
await enterEditMode(user);
expect(await saveButton()).toBeDisabled();
@@ -296,9 +296,7 @@ describe("DefaultUserSettingsForm", () => {
await user.click(await saveButton());
await waitFor(() => expect(updateSettings).toHaveBeenCalledTimes(1));
- await waitFor(() =>
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith("Team(s) not found: team-alhpa."),
- );
+ await waitFor(() => expect(toast.fromError).toHaveBeenCalledWith("Team(s) not found: team-alhpa."));
expect(await saveButton()).toBeEnabled();
expect(screen.getByLabelText("Max Budget (USD)")).toHaveValue(250);
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/default-user-settings/DefaultUserSettingsForm.tsx b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/default-user-settings/DefaultUserSettingsForm.tsx
index 1e0ec6b6998..d3eef4dcbbf 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/default-user-settings/DefaultUserSettingsForm.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/default-user-settings/DefaultUserSettingsForm.tsx
@@ -6,7 +6,7 @@ import { useFieldArray, type Control } from "react-hook-form";
import { useInfiniteTeams } from "@/app/(dashboard)/hooks/teams/useTeams";
import { ModelSelect, MODEL_SENTINEL_OPTIONS } from "@/components/ModelSelect/ModelSelect";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { PaginatedSearchSelect } from "@/components/shared/PaginatedSearchSelect";
import { FieldGroup } from "@/components/shared/form/field";
import { FormField } from "@/components/shared/form/FormField";
@@ -235,15 +235,13 @@ const SettingsForm = ({ initialValues, roleOptions, updateSettings, onCancel, on
const mutation = useMutation({
mutationFn: (values: DefaultUserSettingsFormValues) => updateSettings(buildBody(values)),
onSuccess: (_result, values) => {
- NotificationsManager.success("Default user settings updated successfully");
+ toast.success("Default user settings updated successfully");
queryClient.invalidateQueries({ queryKey: SETTINGS_QUERY_KEY });
form.reset(values);
onSaved();
},
onError: (error: unknown) =>
- NotificationsManager.fromBackend(
- error instanceof Error ? error.message : "Failed to update default user settings",
- ),
+ toast.fromError(error instanceof Error ? error.message : "Failed to update default user settings"),
});
const onSubmit = form.handleSubmit((values) => mutation.mutate(values));
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users.test.tsx
index 57a50f6cfc2..6c7718141ca 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users.test.tsx
@@ -51,14 +51,6 @@ vi.mock("./default-user-settings/DefaultUserSettingsForm", () => ({
},
}));
-// Mock NotificationsManager
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
const makeUser = (userId: string, email: string) => ({
user_id: userId,
user_email: email,
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users.tsx b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users.tsx
index df2345b0af4..05e02dc12c4 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users.tsx
@@ -31,7 +31,7 @@ import {
SortingState,
} from "@tanstack/react-table";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { modelAvailableCall, userDeleteCall } from "@/components/networking";
import { DefaultUserSettingsForm } from "./default-user-settings/DefaultUserSettingsForm";
import { UsersTable } from "./view_users/UsersTable";
@@ -162,16 +162,16 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
const handleResetPassword = useCallback(
async (userId: string) => {
if (!accessToken) {
- NotificationsManager.fromBackend("Access token not found");
+ toast.fromError("Access token not found");
return;
}
try {
- NotificationsManager.success("Generating password reset link...");
+ toast.success("Generating password reset link...");
const data = await invitationCreateCall(accessToken, userId);
setInvitationLinkData(data);
setIsInvitationLinkModalVisible(true);
} catch (error) {
- NotificationsManager.fromBackend("Failed to generate password reset link");
+ toast.fromError("Failed to generate password reset link");
}
},
[accessToken],
@@ -190,10 +190,10 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
return { ...previousData, users: updatedUsers };
});
- NotificationsManager.success("User deleted successfully");
+ toast.success("User deleted successfully");
} catch (error) {
console.error("Error deleting user:", error);
- NotificationsManager.fromBackend("Failed to delete user");
+ toast.fromError("Failed to delete user");
} finally {
setIsDeleteModalOpen(false);
setUserToDelete(null);
@@ -231,7 +231,7 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
return { ...previousData, users: updatedUsers };
});
- NotificationsManager.success(`User ${editedUser.user_id} updated successfully`);
+ toast.success(`User ${editedUser.user_id} updated successfully`);
} catch (error) {
console.error("There was an error updating the user", error);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users/user_info_view.tsx b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users/user_info_view.tsx
index 853dc570796..c4b09f7fffd 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users/user_info_view.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/users/_components/view_users/user_info_view.tsx
@@ -40,7 +40,7 @@ import { UserEditView } from "../user_edit_view";
import OnboardingModal, { InvitationLink } from "@/components/onboarding_link";
import { formatNumberWithCommas, copyToClipboard as utilCopyToClipboard } from "@/utils/dataUtils";
import { CopyIcon, CheckIcon } from "lucide-react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getBudgetDurationLabel } from "@/components/common_components/budget_duration_dropdown";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
import MCPServerPermissions from "@/components/permissions/MCPServerPermissions";
@@ -139,7 +139,7 @@ export default function UserInfoView({
setUserModels(availableModels);
} catch (error) {
console.error("Error fetching user data:", error);
- NotificationsManager.fromBackend("Failed to fetch user data");
+ toast.fromError("Failed to fetch user data");
} finally {
setIsLoading(false);
}
@@ -184,7 +184,7 @@ export default function UserInfoView({
user_id: userId,
};
await teamMemberAddCall(accessToken, selectedTeamId, member);
- NotificationsManager.success("User added to team successfully");
+ toast.success("User added to team successfully");
setIsAddTeamModalOpen(false);
// Re-fetch user data to refresh teams
const data = await userGetInfoV2(accessToken, userId);
@@ -204,7 +204,7 @@ export default function UserInfoView({
}
} catch (error: any) {
console.error("Error adding user to team:", error);
- NotificationsManager.fromBackend(error?.message || "Failed to add user to team");
+ toast.fromError(error?.message || "Failed to add user to team");
} finally {
setIsAddingTeam(false);
}
@@ -224,7 +224,7 @@ export default function UserInfoView({
user_id: userId,
};
await teamMemberDeleteCall(accessToken, teamToRemove.team_id, member);
- NotificationsManager.success("User removed from team successfully");
+ toast.success("User removed from team successfully");
setIsRemoveTeamModalOpen(false);
setTeamToRemove(null);
// Re-fetch user data to refresh teams
@@ -245,7 +245,7 @@ export default function UserInfoView({
}
} catch (error: any) {
console.error("Error removing user from team:", error);
- NotificationsManager.fromBackend(error?.message || "Failed to remove user from team");
+ toast.fromError(error?.message || "Failed to remove user from team");
} finally {
setIsRemovingTeam(false);
}
@@ -260,16 +260,16 @@ export default function UserInfoView({
const handleResetPassword = async () => {
if (!accessToken) {
- NotificationsManager.fromBackend("Access token not found");
+ toast.fromError("Access token not found");
return;
}
try {
- NotificationsManager.success("Generating password reset link...");
+ toast.success("Generating password reset link...");
const data = await invitationCreateCall(accessToken, userId);
setInvitationLinkData(data);
setIsInvitationLinkModalVisible(true);
} catch (error) {
- NotificationsManager.fromBackend("Failed to generate password reset link");
+ toast.fromError("Failed to generate password reset link");
}
};
@@ -278,14 +278,14 @@ export default function UserInfoView({
if (!accessToken) return;
setIsDeletingUser(true);
await userDeleteCall(accessToken, [userId]);
- NotificationsManager.success("User deleted successfully");
+ toast.success("User deleted successfully");
if (onDelete) {
onDelete();
}
onClose();
} catch (error) {
console.error("Error deleting user:", error);
- NotificationsManager.fromBackend("Failed to delete user");
+ toast.fromError("Failed to delete user");
} finally {
setIsDeleteModalOpen(false);
setIsDeletingUser(false);
@@ -327,11 +327,11 @@ export default function UserInfoView({
: userData.object_permission,
});
- NotificationsManager.success("User updated successfully");
+ toast.success("User updated successfully");
setIsEditing(false);
} catch (error) {
console.error("Error updating user:", error);
- NotificationsManager.fromBackend("Failed to update user");
+ toast.fromError("Failed to update user");
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/CreateVectorStore.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/CreateVectorStore.test.tsx
index 048b2d05f1d..7405fa5c2fc 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/CreateVectorStore.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/CreateVectorStore.test.tsx
@@ -8,14 +8,6 @@ vi.mock("@/components/networking", () => ({
ragIngestCall: vi.fn(),
}));
-// Mock NotificationsManager
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
// Mock vector_store_providers
vi.mock("@/components/vector_store_providers", () => ({
VectorStoreProviders: {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/CreateVectorStore.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/CreateVectorStore.tsx
index 79ba9b77c14..a0a2759eccb 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/CreateVectorStore.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/CreateVectorStore.tsx
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import { Card, Title, Text } from "@tremor/react";
import { Upload, Button, Select, Form, Alert, Tooltip, Input } from "antd";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { InboxOutlined, InfoCircleOutlined } from "@ant-design/icons";
import type { UploadProps } from "antd";
import { ragIngestCall } from "@/components/networking";
@@ -15,7 +15,6 @@ import {
VectorStoreFieldConfig,
} from "@/components/vector_store_providers";
import { Logo } from "@/components/molecules/logo/Logo";
-import NotificationsManager from "@/components/molecules/notifications_manager";
import S3VectorsConfig from "./S3VectorsConfig";
const { Dragger } = Upload;
@@ -49,13 +48,13 @@ const CreateVectorStore: React.FC<CreateVectorStoreProps> = ({ accessToken, onSu
].includes(file.type);
if (!isValidType) {
- MessageManager.error(`${file.name} is not a supported file type. Please upload PDF, TXT, DOCX, or MD files.`);
+ toast.error(`${file.name} is not a supported file type. Please upload PDF, TXT, DOCX, or MD files.`);
return Upload.LIST_IGNORE;
}
const isLt50M = file.size / 1024 / 1024 < 50;
if (!isLt50M) {
- MessageManager.error(`${file.name} must be smaller than 50MB!`);
+ toast.error(`${file.name} must be smaller than 50MB!`);
return Upload.LIST_IGNORE;
}
@@ -89,12 +88,12 @@ const CreateVectorStore: React.FC<CreateVectorStoreProps> = ({ accessToken, onSu
const handleCreateVectorStore = async () => {
if (documents.length === 0) {
- MessageManager.warning("Please upload at least one document");
+ toast.warning("Please upload at least one document");
return;
}
if (!selectedProvider) {
- MessageManager.warning("Please select a provider");
+ toast.warning("Please select a provider");
return;
}
@@ -102,7 +101,7 @@ const CreateVectorStore: React.FC<CreateVectorStoreProps> = ({ accessToken, onSu
const requiredFields = getProviderSpecificFields(selectedProvider).filter((field) => field.required);
for (const field of requiredFields) {
if (!providerParams[field.name]) {
- MessageManager.warning(`Please provide ${field.label}`);
+ toast.warning(`Please provide ${field.label}`);
return;
}
}
@@ -110,17 +109,17 @@ const CreateVectorStore: React.FC<CreateVectorStoreProps> = ({ accessToken, onSu
// S3 Vectors specific validation
if (selectedProvider === "s3_vectors") {
if (providerParams.vector_bucket_name && providerParams.vector_bucket_name.length < 3) {
- MessageManager.warning("Vector bucket name must be at least 3 characters");
+ toast.warning("Vector bucket name must be at least 3 characters");
return;
}
if (providerParams.index_name && providerParams.index_name.length > 0 && providerParams.index_name.length < 3) {
- MessageManager.warning("Index name must be at least 3 characters if provided");
+ toast.warning("Index name must be at least 3 characters if provided");
return;
}
}
if (!accessToken) {
- MessageManager.error("No access token available");
+ toast.error("No access token available");
return;
}
@@ -165,7 +164,7 @@ const CreateVectorStore: React.FC<CreateVectorStoreProps> = ({ accessToken, onSu
}
setIngestResults(results);
- NotificationsManager.success(
+ toast.success(
`Successfully created vector store with ${results.length} document(s). Vector Store ID: ${vectorStoreId}`,
);
@@ -180,7 +179,7 @@ const CreateVectorStore: React.FC<CreateVectorStoreProps> = ({ accessToken, onSu
}, 3000);
} catch (error) {
console.error("Error creating vector store:", error);
- NotificationsManager.fromBackend(`Failed to create vector store: ${error}`);
+ toast.fromError(`Failed to create vector store: ${error}`);
} finally {
setIsCreating(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/IndexesTab.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/IndexesTab.tsx
index bf53433adea..fc7a0f69d1c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/IndexesTab.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/IndexesTab.tsx
@@ -2,7 +2,7 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { indexesListCall } from "@/components/networking";
import { VectorStore } from "@/components/vector_store_management/types";
@@ -55,7 +55,7 @@ const IndexesTab: React.FC<IndexesTabProps> = ({ accessToken, vectorStores, onVi
setIndexes(response.data || []);
} catch (error) {
console.error("Error fetching indexes:", error);
- NotificationsManager.fromBackend("Error fetching indexes: " + error);
+ toast.fromError("Error fetching indexes: " + error);
} finally {
setIsLoading(false);
}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreForm.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreForm.tsx
index 67ba469f68d..321ff62b1df 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreForm.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreForm.tsx
@@ -12,7 +12,7 @@ import {
} from "@/components/vector_store_providers";
import { Logo } from "@/components/molecules/logo/Logo";
import { fetchAvailableModels, ModelGroup } from "@/components/llm_calls/fetch_models";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface VectorStoreFormProps {
isVisible: boolean;
@@ -60,7 +60,7 @@ const VectorStoreForm: React.FC<VectorStoreFormProps> = ({
try {
metadata = metadataJson.trim() ? JSON.parse(metadataJson) : {};
} catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in metadata field");
+ toast.fromError("Invalid JSON in metadata field");
return;
}
@@ -92,13 +92,13 @@ const VectorStoreForm: React.FC<VectorStoreFormProps> = ({
payload["litellm_params"] = litellmParams;
await vectorStoreCreateCall(accessToken, payload);
- NotificationsManager.success("Vector store created successfully");
+ toast.success("Vector store created successfully");
form.resetFields();
setMetadataJson("{}");
onSuccess();
} catch (error) {
console.error("Error creating vector store:", error);
- NotificationsManager.fromBackend("Error creating vector store: " + error);
+ toast.fromError("Error creating vector store: " + error);
}
};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreTester.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreTester.test.tsx
index cbabcc6dca5..34643811e29 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreTester.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreTester.test.tsx
@@ -5,26 +5,14 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import { vectorStoreSearchCall } from "@/components/networking";
import { VectorStoreTester } from "./VectorStoreTester";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
vectorStoreSearchCall: vi.fn(),
}));
-const mockWarning = vi.fn();
-vi.mock("@/components/molecules/message_manager", () => ({
- __esModule: true,
- default: { warning: (...args: unknown[]) => mockWarning(...args) },
-}));
-
-const mockFromBackend = vi.fn();
-const mockSuccess = vi.fn();
-vi.mock("@/components/molecules/notifications_manager", () => ({
- __esModule: true,
- default: {
- fromBackend: (...args: unknown[]) => mockFromBackend(...args),
- success: (...args: unknown[]) => mockSuccess(...args),
- },
-}));
+const mockWarning = vi.mocked(toast.warning);
+const mockFromBackend = vi.mocked(toast.fromError);
const mockSearch = vi.mocked(vectorStoreSearchCall);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreTester.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreTester.tsx
index 015d58e8649..6d12880319b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreTester.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/VectorStoreTester.tsx
@@ -1,8 +1,7 @@
import React, { useState } from "react";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { ChevronDown, ChevronRight, Database, Send } from "lucide-react";
import { vectorStoreSearchCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
@@ -48,7 +47,7 @@ export const VectorStoreTester: React.FC<VectorStoreTesterProps> = ({ vectorStor
const handleSearch = async () => {
if (!query.trim()) {
- MessageManager.warning("Please enter a search query");
+ toast.warning("Please enter a search query");
return;
}
@@ -67,7 +66,7 @@ export const VectorStoreTester: React.FC<VectorStoreTesterProps> = ({ vectorStor
setQuery("");
} catch (error) {
console.error("Error searching vector store:", error);
- NotificationsManager.fromBackend("Failed to search vector store");
+ toast.fromError("Failed to search vector store");
} finally {
setIsLoading(false);
}
@@ -87,7 +86,7 @@ export const VectorStoreTester: React.FC<VectorStoreTesterProps> = ({ vectorStor
const clearHistory = () => {
setSearchHistory([]);
setExpandedResults({});
- NotificationsManager.success("Search history cleared");
+ toast.success("Search history cleared");
};
const toggleResultExpansion = (historyIndex: number, resultIndex: number) => {
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/index.tsx
index b19c5f4694c..f74f444ce26 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/index.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/index.tsx
@@ -15,7 +15,7 @@ import CreateVectorStore from "./CreateVectorStore";
import TestVectorStoreTab from "./TestVectorStoreTab";
import IndexesTab from "./IndexesTab";
import { isAdminRole, isProxyAdminRole } from "@/utils/roles";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { useVisitedTabs } from "@/hooks/useVisitedTabs";
@@ -49,7 +49,7 @@ const VectorStoreManagement: React.FC<VectorStoreProps> = ({ accessToken, userID
setVectorStores(response.data || []);
} catch (error) {
console.error("Error fetching vector stores:", error);
- NotificationsManager.fromBackend("Error fetching vector stores: " + error);
+ toast.fromError("Error fetching vector stores: " + error);
} finally {
setIsLoadingVectorStores(false);
}
@@ -62,7 +62,7 @@ const VectorStoreManagement: React.FC<VectorStoreProps> = ({ accessToken, userID
setCredentials(response.credentials || []);
} catch (error) {
console.error("Error fetching credentials:", error);
- NotificationsManager.fromBackend("Error fetching credentials: " + error);
+ toast.fromError("Error fetching credentials: " + error);
}
};
@@ -99,11 +99,11 @@ const VectorStoreManagement: React.FC<VectorStoreProps> = ({ accessToken, userID
setIsDeleting(true);
try {
await vectorStoreDeleteCall(accessToken, vectorStoreToDelete);
- NotificationsManager.success("Vector store deleted successfully");
+ toast.success("Vector store deleted successfully");
fetchVectorStores();
} catch (error) {
console.error("Error deleting vector store:", error);
- NotificationsManager.fromBackend("Error deleting vector store: " + error);
+ toast.fromError("Error deleting vector store: " + error);
} finally {
setIsDeleting(false);
setIsDeleteModalOpen(false);
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/vector_store_info.tsx b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/vector_store_info.tsx
index 4f94a7d56f6..517496a6e19 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/vector_store_info.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/vector-stores/_components/vector_store_info.tsx
@@ -14,7 +14,7 @@ import { Providers, provider_map } from "@/components/provider_info_helpers";
import { getVectorStoreProviderLogoAndName } from "@/components/vector_store_providers";
import { Logo } from "@/components/molecules/logo/Logo";
import VectorStoreTester from "./VectorStoreTester";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface VectorStoreInfoViewProps {
vectorStoreId: string;
@@ -68,7 +68,7 @@ const VectorStoreInfoView: React.FC<VectorStoreInfoViewProps> = ({
}
} catch (error) {
console.error("Error fetching vector store details:", error);
- NotificationsManager.fromBackend("Error fetching vector store details: " + error);
+ toast.fromError("Error fetching vector store details: " + error);
setLoadFailed(true);
}
};
@@ -96,7 +96,7 @@ const VectorStoreInfoView: React.FC<VectorStoreInfoViewProps> = ({
try {
metadata = metadataString ? JSON.parse(metadataString) : {};
} catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in metadata field");
+ toast.fromError("Invalid JSON in metadata field");
return;
}
@@ -109,12 +109,12 @@ const VectorStoreInfoView: React.FC<VectorStoreInfoViewProps> = ({
};
await vectorStoreUpdateCall(accessToken, updateData);
- NotificationsManager.success("Vector store updated successfully");
+ toast.success("Vector store updated successfully");
setIsEditing(false);
fetchVectorStoreDetails();
} catch (error) {
console.error("Error updating vector store:", error);
- NotificationsManager.fromBackend("Error updating vector store: " + error);
+ toast.fromError("Error updating vector store: " + error);
}
};
diff --git a/ui/litellm-dashboard/src/app/chat/page.tsx b/ui/litellm-dashboard/src/app/chat/page.tsx
index 0391bafcfd9..0303cdb62c4 100644
--- a/ui/litellm-dashboard/src/app/chat/page.tsx
+++ b/ui/litellm-dashboard/src/app/chat/page.tsx
@@ -7,7 +7,7 @@ import { Skeleton } from "@/components/ui/skeleton";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { useRouter } from "next/navigation";
import { useChatShell } from "@/contexts/ChatShellContext";
import { getChatRoutes } from "@/components/chat/ChatShell";
@@ -111,7 +111,7 @@ export default function ChatConversationPage() {
localStorage.setItem(LOCALSTORAGE_MODEL_KEY, names[0]);
}
})
- .catch(() => MessageManager.error("Could not load models"))
+ .catch(() => toast.error("Could not load models"))
.finally(() => setIsLoadingModels(false));
}, [accessToken]);
diff --git a/ui/litellm-dashboard/src/components/AIHub/UsefulLinksManagement.test.tsx b/ui/litellm-dashboard/src/components/AIHub/UsefulLinksManagement.test.tsx
index 3a66efd9fe1..95b292227a7 100644
--- a/ui/litellm-dashboard/src/components/AIHub/UsefulLinksManagement.test.tsx
+++ b/ui/litellm-dashboard/src/components/AIHub/UsefulLinksManagement.test.tsx
@@ -1,4 +1,4 @@
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getProxyBaseUrl, getPublicModelHubInfo, updateUsefulLinksCall } from "@/components/networking";
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
@@ -11,18 +11,10 @@ vi.mock("@/components/networking", () => ({
getProxyBaseUrl: vi.fn(),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- __esModule: true,
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
const mockedGetPublicModelHubInfo = vi.mocked(getPublicModelHubInfo);
const mockedUpdateUsefulLinksCall = vi.mocked(updateUsefulLinksCall);
const mockedGetProxyBaseUrl = vi.mocked(getProxyBaseUrl);
-const mockedNotifications = vi.mocked(NotificationsManager);
+const mockedNotifications = vi.mocked(toast);
describe("UsefulLinksManagement", () => {
beforeEach(() => {
diff --git a/ui/litellm-dashboard/src/components/AIHub/UsefulLinksManagement.tsx b/ui/litellm-dashboard/src/components/AIHub/UsefulLinksManagement.tsx
index 81c6d9c465f..5af7fb9688f 100644
--- a/ui/litellm-dashboard/src/components/AIHub/UsefulLinksManagement.tsx
+++ b/ui/litellm-dashboard/src/components/AIHub/UsefulLinksManagement.tsx
@@ -1,5 +1,5 @@
import TableIconActionButton from "@/components/common_components/IconActionButton/TableIconActionButtons/TableIconActionButton";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { isAdminRole } from "@/utils/roles";
import { ChevronDownIcon, ChevronRightIcon, ExternalLinkIcon, PlusCircleIcon } from "@heroicons/react/outline";
import { Card } from "@/components/ui/card";
@@ -103,7 +103,7 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
return true;
} catch (error) {
console.error("Error saving links:", error);
- NotificationsManager.fromBackend(`Failed to save links - ${error}`);
+ toast.fromError(`Failed to save links - ${error}`);
return false;
}
};
@@ -115,13 +115,13 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
try {
new URL(newLink.url);
} catch {
- NotificationsManager.fromBackend("Please enter a valid URL");
+ toast.fromError("Please enter a valid URL");
return;
}
// Check for duplicate display names
if (links.some((link) => link.displayName === newLink.displayName)) {
- NotificationsManager.fromBackend("A link with this display name already exists");
+ toast.fromError("A link with this display name already exists");
return;
}
@@ -136,7 +136,7 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
if (await saveLinksToBackend(updatedLinks)) {
setLinks(updatedLinks);
setNewLink({ url: "", displayName: "" });
- NotificationsManager.success("Link added successfully");
+ toast.success("Link added successfully");
}
};
@@ -151,13 +151,13 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
try {
new URL(editingLink.url);
} catch {
- NotificationsManager.fromBackend("Please enter a valid URL");
+ toast.fromError("Please enter a valid URL");
return;
}
// Check for duplicate display names (excluding current link)
if (links.some((link) => link.id !== editingLink.id && link.displayName === editingLink.displayName)) {
- NotificationsManager.fromBackend("A link with this display name already exists");
+ toast.fromError("A link with this display name already exists");
return;
}
@@ -166,7 +166,7 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
if (await saveLinksToBackend(updatedLinks)) {
setLinks(updatedLinks);
setEditingLink(null);
- NotificationsManager.success("Link updated successfully");
+ toast.success("Link updated successfully");
}
};
@@ -179,7 +179,7 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
if (await saveLinksToBackend(updatedLinks)) {
setLinks(updatedLinks);
- NotificationsManager.success("Link deleted successfully");
+ toast.success("Link deleted successfully");
}
};
@@ -205,7 +205,7 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
if (await saveLinksToBackend(links)) {
setIsRearranging(false);
setOriginalLinksOrder([]);
- NotificationsManager.success("Link order saved successfully");
+ toast.success("Link order saved successfully");
}
};
diff --git a/ui/litellm-dashboard/src/components/AIHub/forms/MakeAgentPublicForm.tsx b/ui/litellm-dashboard/src/components/AIHub/forms/MakeAgentPublicForm.tsx
index 82336206858..da61777f341 100644
--- a/ui/litellm-dashboard/src/components/AIHub/forms/MakeAgentPublicForm.tsx
+++ b/ui/litellm-dashboard/src/components/AIHub/forms/MakeAgentPublicForm.tsx
@@ -6,7 +6,7 @@ import { Checkbox } from "@/components/ui/checkbox";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { cn } from "@/lib/cva.config";
import { makeAgentsPublicCall } from "../../networking";
-import NotificationsManager from "../../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { AgentHubData } from "@/components/AIHub/AgentHubTableColumns";
const STEP_TITLES = ["Select Agents", "Confirm"];
@@ -39,7 +39,7 @@ const MakeAgentPublicForm: React.FC<MakeAgentPublicFormProps> = ({
const handleNext = () => {
if (currentStep === 0) {
if (selectedAgents.size === 0) {
- NotificationsManager.fromBackend("Please select at least one agent to make public");
+ toast.fromError("Please select at least one agent to make public");
return;
}
setCurrentStep(1);
@@ -85,7 +85,7 @@ const MakeAgentPublicForm: React.FC<MakeAgentPublicFormProps> = ({
const handleSubmit = async () => {
if (selectedAgents.size === 0) {
- NotificationsManager.fromBackend("Please select at least one agent to make public");
+ toast.fromError("Please select at least one agent to make public");
return;
}
@@ -96,12 +96,12 @@ const MakeAgentPublicForm: React.FC<MakeAgentPublicFormProps> = ({
// Make batch API call for all agents
await makeAgentsPublicCall(accessToken, agentIdsToMakePublic);
- NotificationsManager.success(`Successfully made ${agentIdsToMakePublic.length} agent(s) public!`);
+ toast.success(`Successfully made ${agentIdsToMakePublic.length} agent(s) public!`);
handleClose();
onSuccess();
} catch (error) {
console.error("Error making agents public:", error);
- NotificationsManager.fromBackend("Failed to make agents public. Please try again.");
+ toast.fromError("Failed to make agents public. Please try again.");
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/AIHub/forms/MakeMCPPublicForm.tsx b/ui/litellm-dashboard/src/components/AIHub/forms/MakeMCPPublicForm.tsx
index 7ef42883400..c60fed1747b 100644
--- a/ui/litellm-dashboard/src/components/AIHub/forms/MakeMCPPublicForm.tsx
+++ b/ui/litellm-dashboard/src/components/AIHub/forms/MakeMCPPublicForm.tsx
@@ -6,7 +6,7 @@ import { Checkbox } from "@/components/ui/checkbox";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { cn } from "@/lib/cva.config";
import { makeMCPPublicCall } from "../../networking";
-import NotificationsManager from "../../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { MCPServerData } from "@/components/AIHub/MCPHubTableColumns";
const STEP_TITLES = ["Select Servers", "Confirm"];
@@ -49,7 +49,7 @@ const MakeMCPPublicForm: React.FC<MakeMCPPublicFormProps> = ({
const handleNext = () => {
if (currentStep === 0) {
if (selectedServers.size === 0) {
- NotificationsManager.fromBackend("Please select at least one MCP server to make public");
+ toast.fromError("Please select at least one MCP server to make public");
return;
}
setCurrentStep(1);
@@ -96,7 +96,7 @@ const MakeMCPPublicForm: React.FC<MakeMCPPublicFormProps> = ({
const handleSubmit = async () => {
if (selectedServers.size === 0) {
- NotificationsManager.fromBackend("Please select at least one MCP server to make public");
+ toast.fromError("Please select at least one MCP server to make public");
return;
}
@@ -107,12 +107,12 @@ const MakeMCPPublicForm: React.FC<MakeMCPPublicFormProps> = ({
// Make batch API call for all servers
await makeMCPPublicCall(accessToken, serverIdsToMakePublic);
- NotificationsManager.success(`Successfully made ${serverIdsToMakePublic.length} MCP server(s) public!`);
+ toast.success(`Successfully made ${serverIdsToMakePublic.length} MCP server(s) public!`);
handleClose();
onSuccess();
} catch (error) {
console.error("Error making MCP servers public:", error);
- NotificationsManager.fromBackend("Failed to make MCP servers public. Please try again.");
+ toast.fromError("Failed to make MCP servers public. Please try again.");
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/AIHub/forms/MakeModelPublicForm.test.tsx b/ui/litellm-dashboard/src/components/AIHub/forms/MakeModelPublicForm.test.tsx
index 013d92ea463..bbeee883b1a 100644
--- a/ui/litellm-dashboard/src/components/AIHub/forms/MakeModelPublicForm.test.tsx
+++ b/ui/litellm-dashboard/src/components/AIHub/forms/MakeModelPublicForm.test.tsx
@@ -43,14 +43,6 @@ vi.mock("../../model_filters", () => ({
),
}));
-// Mock NotificationsManager
-vi.mock("../../molecules/notifications_manager", () => ({
- default: {
- fromBackend: vi.fn(),
- success: vi.fn(),
- },
-}));
-
describe("MakeModelPublicForm", () => {
const mockProps = {
visible: true,
diff --git a/ui/litellm-dashboard/src/components/AIHub/forms/MakeModelPublicForm.tsx b/ui/litellm-dashboard/src/components/AIHub/forms/MakeModelPublicForm.tsx
index 28a34ee1f1a..0820c8ce28d 100644
--- a/ui/litellm-dashboard/src/components/AIHub/forms/MakeModelPublicForm.tsx
+++ b/ui/litellm-dashboard/src/components/AIHub/forms/MakeModelPublicForm.tsx
@@ -7,7 +7,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/u
import { cn } from "@/lib/cva.config";
import { makeModelGroupPublic } from "../../networking";
import ModelFilters from "../../model_filters";
-import NotificationsManager from "../../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
const STEP_TITLES = ["Select Models", "Confirm"];
@@ -59,7 +59,7 @@ const MakeModelPublicForm: React.FC<MakeModelPublicFormProps> = ({
const handleNext = () => {
if (currentStep === 0) {
if (selectedModels.size === 0) {
- NotificationsManager.fromBackend("Please select at least one model to make public");
+ toast.fromError("Please select at least one model to make public");
return;
}
setCurrentStep(1);
@@ -112,7 +112,7 @@ const MakeModelPublicForm: React.FC<MakeModelPublicFormProps> = ({
const handleSubmit = async () => {
if (selectedModels.size === 0) {
- NotificationsManager.fromBackend("Please select at least one model to make public");
+ toast.fromError("Please select at least one model to make public");
return;
}
@@ -121,12 +121,12 @@ const MakeModelPublicForm: React.FC<MakeModelPublicFormProps> = ({
const modelGroupsToMakePublic = Array.from(selectedModels);
await makeModelGroupPublic(accessToken, modelGroupsToMakePublic);
- NotificationsManager.success(`Successfully made ${modelGroupsToMakePublic.length} model group(s) public!`);
+ toast.success(`Successfully made ${modelGroupsToMakePublic.length} model group(s) public!`);
handleClose();
onSuccess();
} catch (error) {
console.error("Error making model groups public:", error);
- NotificationsManager.fromBackend("Failed to make model groups public. Please try again.");
+ toast.fromError("Failed to make model groups public. Please try again.");
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroCreateModal.tsx b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroCreateModal.tsx
index 5f460cb7cb6..bd08bf028ad 100644
--- a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroCreateModal.tsx
+++ b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroCreateModal.tsx
@@ -1,5 +1,5 @@
import { Form, Modal, Input } from "antd";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { useEffect } from "react";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { useCloudZeroCreate } from "@/app/(dashboard)/hooks/cloudzero/useCloudZeroCreate";
@@ -32,7 +32,7 @@ export default function CloudZeroCreationModal({ open, onOk, onCancel }: CloudZe
},
{
onSuccess: () => {
- MessageManager.success("CloudZero integration created successfully");
+ toast.success("CloudZero integration created successfully");
form.resetFields();
onOk();
},
@@ -40,7 +40,7 @@ export default function CloudZeroCreationModal({ open, onOk, onCancel }: CloudZe
if (error?.errorFields) {
return;
}
- MessageManager.error(error?.message || "Failed to create CloudZero integration");
+ toast.error(error?.message || "Failed to create CloudZero integration");
},
},
);
@@ -48,7 +48,7 @@ export default function CloudZeroCreationModal({ open, onOk, onCancel }: CloudZe
if (error?.errorFields) {
return;
}
- MessageManager.error(error?.message || "Failed to create CloudZero integration");
+ toast.error(error?.message || "Failed to create CloudZero integration");
}
};
diff --git a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroIntegrationSettings.tsx b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroIntegrationSettings.tsx
index ad9c00ce316..2baafa822e3 100644
--- a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroIntegrationSettings.tsx
+++ b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroIntegrationSettings.tsx
@@ -17,7 +17,7 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Separator } from "@/components/ui/separator";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { CheckCircle, Pencil, Play, Trash2, Upload } from "lucide-react";
import { useState } from "react";
import CloudZeroUpdateModal from "./CloudZeroUpdateModal";
@@ -59,10 +59,10 @@ export function CloudZeroIntegrationSettings({ settings, onSettingsUpdated }: Cl
{ limit: 10 },
{
onSuccess: (data) => {
- MessageManager.success("Dry run completed successfully");
+ toast.success("Dry run completed successfully");
},
onError: (error) => {
- MessageManager.error(error?.message || "Failed to perform dry run");
+ toast.error(error?.message || "Failed to perform dry run");
},
},
);
@@ -77,11 +77,11 @@ export function CloudZeroIntegrationSettings({ settings, onSettingsUpdated }: Cl
{ operation: "replace_hourly" },
{
onSuccess: () => {
- MessageManager.success("Data successfully exported to CloudZero");
+ toast.success("Data successfully exported to CloudZero");
setIsExportConfirmOpen(false);
},
onError: (error) => {
- MessageManager.error(error?.message || "Failed to export data");
+ toast.error(error?.message || "Failed to export data");
},
},
);
@@ -109,12 +109,12 @@ export function CloudZeroIntegrationSettings({ settings, onSettingsUpdated }: Cl
deleteMutation.mutate(undefined, {
onSuccess: () => {
- MessageManager.success("CloudZero integration deleted successfully");
+ toast.success("CloudZero integration deleted successfully");
setIsDeleteModalOpen(false);
onSettingsUpdated();
},
onError: (error) => {
- MessageManager.error(error?.message || "Failed to delete CloudZero integration");
+ toast.error(error?.message || "Failed to delete CloudZero integration");
},
});
};
diff --git a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroUpdateModal.tsx b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroUpdateModal.tsx
index a04007897c3..44049714c6c 100644
--- a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroUpdateModal.tsx
+++ b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroUpdateModal.tsx
@@ -1,7 +1,7 @@
import { useCloudZeroUpdateSettings } from "@/app/(dashboard)/hooks/cloudzero/useCloudZeroSettings";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { Form, Input, Modal } from "antd";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { useEffect } from "react";
import { CloudZeroSettings } from "./types";
@@ -40,7 +40,7 @@ export default function CloudZeroUpdateModal({ open, onOk, onCancel, settings }:
},
{
onSuccess: () => {
- MessageManager.success("CloudZero integration updated successfully");
+ toast.success("CloudZero integration updated successfully");
form.resetFields();
onOk();
},
@@ -48,7 +48,7 @@ export default function CloudZeroUpdateModal({ open, onOk, onCancel, settings }:
if (error?.errorFields) {
return;
}
- MessageManager.error(error?.message || "Failed to update CloudZero integration");
+ toast.error(error?.message || "Failed to update CloudZero integration");
},
},
);
@@ -56,7 +56,7 @@ export default function CloudZeroUpdateModal({ open, onOk, onCancel, settings }:
if (error?.errorFields) {
return;
}
- MessageManager.error(error?.message || "Failed to update CloudZero integration");
+ toast.error(error?.message || "Failed to update CloudZero integration");
}
};
diff --git a/ui/litellm-dashboard/src/components/CreateUserButton.test.tsx b/ui/litellm-dashboard/src/components/CreateUserButton.test.tsx
index de1c3508dac..d0330c27116 100644
--- a/ui/litellm-dashboard/src/components/CreateUserButton.test.tsx
+++ b/ui/litellm-dashboard/src/components/CreateUserButton.test.tsx
@@ -4,7 +4,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { CreateUserButton } from "./CreateUserButton";
import * as networking from "./networking";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("./networking", () => ({
userCreateCall: vi.fn(),
@@ -28,7 +28,7 @@ const mockUserCreateCall = vi.mocked(networking.userCreateCall);
const mockInvitationCreateCall = vi.mocked(networking.invitationCreateCall);
const mockGetProxyUISettings = vi.mocked(networking.getProxyUISettings);
const mockOrganizationMemberAddCall = vi.mocked(networking.organizationMemberAddCall);
-const mockNotificationsManager = vi.mocked(NotificationsManager);
+const mockToast = vi.mocked(toast);
const createQueryClient = () =>
new QueryClient({
@@ -199,7 +199,7 @@ describe("CreateUserButton", () => {
await user.click(screen.getByRole("button", { name: /create user/i }));
await waitFor(() => {
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith("Email already exists");
+ expect(mockToast.fromError).toHaveBeenCalledWith("Email already exists");
});
});
@@ -226,7 +226,7 @@ describe("CreateUserButton", () => {
await user.click(screen.getByRole("button", { name: /create user/i }));
await waitFor(() => {
- expect(mockNotificationsManager.info).toHaveBeenCalledWith("Making API Call");
+ expect(mockToast.info).toHaveBeenCalledWith("Making API Call");
});
});
});
@@ -257,7 +257,7 @@ describe("CreateUserButton", () => {
await user.click(within(dialog).getByRole("button", { name: /invite user/i }));
await waitFor(() => {
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("API user Created");
+ expect(mockToast.success).toHaveBeenCalledWith("API user Created");
});
});
@@ -289,7 +289,7 @@ describe("CreateUserButton", () => {
expect(mockInvitationCreateCall).toHaveBeenCalledWith("token", "sso-user");
});
await waitFor(() => {
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("API user Created");
+ expect(mockToast.success).toHaveBeenCalledWith("API user Created");
});
});
});
diff --git a/ui/litellm-dashboard/src/components/CreateUserButton.tsx b/ui/litellm-dashboard/src/components/CreateUserButton.tsx
index 8a9146d756f..499fa8ed143 100644
--- a/ui/litellm-dashboard/src/components/CreateUserButton.tsx
+++ b/ui/litellm-dashboard/src/components/CreateUserButton.tsx
@@ -8,7 +8,7 @@ import { UserPlus } from "lucide-react";
import React, { useEffect, useState } from "react";
import TeamDropdown from "./common_components/team_dropdown";
import { getModelDisplayName } from "./key_team_helpers/fetch_available_models_team_key";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
getProxyBaseUrl,
getProxyUISettings,
@@ -108,7 +108,7 @@ export const CreateUserButton: React.FC<CreateuserProps> = ({
send_invite_email?: boolean;
}) => {
try {
- NotificationsManager.info("Making API Call");
+ toast.info("Making API Call");
if (!isEmbedded) {
setIsModalVisible(true);
}
@@ -155,12 +155,12 @@ export const CreateUserButton: React.FC<CreateuserProps> = ({
setIsInvitationLinkModalVisible(true);
}
- NotificationsManager.success("API user Created");
+ toast.success("API user Created");
form.resetFields();
localStorage.removeItem("userData" + userID);
} catch (error: any) {
const errorMessage = error.response?.data?.detail || error?.message || "Error creating the user";
- NotificationsManager.fromBackend(errorMessage);
+ toast.fromError(errorMessage);
console.error("Error creating the user:", error);
}
};
diff --git a/ui/litellm-dashboard/src/components/EntityUsageExport/EntityUsageExportModal.test.tsx b/ui/litellm-dashboard/src/components/EntityUsageExport/EntityUsageExportModal.test.tsx
index 820adfcdd55..8edf2174eee 100644
--- a/ui/litellm-dashboard/src/components/EntityUsageExport/EntityUsageExportModal.test.tsx
+++ b/ui/litellm-dashboard/src/components/EntityUsageExport/EntityUsageExportModal.test.tsx
@@ -24,17 +24,6 @@ vi.mock("./utils", () => {
};
});
-// Mock notifications
-vi.mock("../molecules/notifications_manager", () => {
- return {
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- info: vi.fn(),
- },
- };
-});
-
// Mock useTeams hook
vi.mock("@/app/(dashboard)/hooks/teams/useTeams", () => ({
useTeams: vi.fn(() => ({
diff --git a/ui/litellm-dashboard/src/components/EntityUsageExport/EntityUsageExportModal.tsx b/ui/litellm-dashboard/src/components/EntityUsageExport/EntityUsageExportModal.tsx
index 6be06914493..ec688e9fc3d 100644
--- a/ui/litellm-dashboard/src/components/EntityUsageExport/EntityUsageExportModal.tsx
+++ b/ui/litellm-dashboard/src/components/EntityUsageExport/EntityUsageExportModal.tsx
@@ -5,7 +5,7 @@ import React, { useMemo, useState } from "react";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Skeleton } from "@/components/ui/skeleton";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import ExportFormatSelector from "./ExportFormatSelector";
import ExportSummary from "./ExportSummary";
import ExportTypeSelector from "./ExportTypeSelector";
@@ -37,15 +37,15 @@ const EntityUsageExportModal: React.FC<EntityUsageExportModalProps> = ({
try {
if (formatToUse === "csv") {
handleExportCSV(spendData, exportScope, entityLabel, entityType, teamAliasMap);
- NotificationsManager.success(`${entityLabel} usage data exported successfully as CSV`);
+ toast.success(`${entityLabel} usage data exported successfully as CSV`);
} else {
handleExportJSON(spendData, exportScope, entityLabel, entityType, dateRange, selectedFilters, teamAliasMap);
- NotificationsManager.success(`${entityLabel} usage data exported successfully as JSON`);
+ toast.success(`${entityLabel} usage data exported successfully as JSON`);
}
onClose();
} catch (error) {
console.error("Error exporting data:", error);
- NotificationsManager.fromBackend("Failed to export data");
+ toast.fromError("Failed to export data");
} finally {
setIsExporting(false);
}
diff --git a/ui/litellm-dashboard/src/components/PassThroughSettings/PassThroughSettings.test.tsx b/ui/litellm-dashboard/src/components/PassThroughSettings/PassThroughSettings.test.tsx
index 90269a916f7..d2b1ea3913b 100644
--- a/ui/litellm-dashboard/src/components/PassThroughSettings/PassThroughSettings.test.tsx
+++ b/ui/litellm-dashboard/src/components/PassThroughSettings/PassThroughSettings.test.tsx
@@ -21,11 +21,6 @@ vi.mock("../pass_through_info", () => ({
),
}));
-vi.mock("../molecules/notifications_manager", () => ({
- __esModule: true,
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
vi.mock("./PassThroughEndpointsTable", () => ({
PassThroughEndpointsTable: (props: React.ComponentProps<typeof PassThroughEndpointsTable>) => (
<div data-testid="endpoints-table" data-loading={props.isLoading}>
diff --git a/ui/litellm-dashboard/src/components/PassThroughSettings/PassThroughSettings.tsx b/ui/litellm-dashboard/src/components/PassThroughSettings/PassThroughSettings.tsx
index 975ba0b70e1..762bd02b6e0 100644
--- a/ui/litellm-dashboard/src/components/PassThroughSettings/PassThroughSettings.tsx
+++ b/ui/litellm-dashboard/src/components/PassThroughSettings/PassThroughSettings.tsx
@@ -3,7 +3,7 @@ import { Button } from "@/components/ui/button";
import { deletePassThroughEndpointsCall, getPassThroughEndpointsCall } from "../networking";
import AddPassThroughEndpoint from "../add_pass_through";
import PassThroughInfoView from "../pass_through_info";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { PassThroughEndpointsTable } from "./PassThroughEndpointsTable";
interface PassThroughSettingsProps {
@@ -74,10 +74,10 @@ const PassThroughSettings: React.FC<PassThroughSettingsProps> = ({ accessToken,
const updatedSettings = generalSettings.filter((setting) => setting.id !== endpointToDelete);
setGeneralSettings(updatedSettings);
- NotificationsManager.success("Endpoint deleted successfully.");
+ toast.success("Endpoint deleted successfully.");
} catch (error) {
console.error("Error deleting the endpoint:", error);
- NotificationsManager.fromBackend("Error deleting the endpoint: " + error);
+ toast.fromError("Error deleting the endpoint: " + error);
}
setIsDeleteModalOpen(false);
diff --git a/ui/litellm-dashboard/src/components/SCIM.tsx b/ui/litellm-dashboard/src/components/SCIM.tsx
index a8d91c343e0..6b8cd5ead97 100644
--- a/ui/litellm-dashboard/src/components/SCIM.tsx
+++ b/ui/litellm-dashboard/src/components/SCIM.tsx
@@ -11,7 +11,7 @@ import {
PlusCircleOutlined,
} from "@ant-design/icons";
import { parseErrorMessage } from "./shared/errorUtils";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface SCIMConfigProps {
accessToken: string | null;
@@ -42,7 +42,7 @@ const SCIMConfig: React.FC<SCIMConfigProps> = ({ accessToken, userID, proxySetti
const handleCreateSCIMToken = async (values: any) => {
if (!accessToken || !userID) {
- NotificationsManager.fromBackend("You need to be logged in to create a SCIM token");
+ toast.fromError("You need to be logged in to create a SCIM token");
return;
}
@@ -58,10 +58,10 @@ const SCIMConfig: React.FC<SCIMConfigProps> = ({ accessToken, userID, proxySetti
const response = await keyCreateCall(accessToken, userID, formData);
setTokenData(response);
- NotificationsManager.success("SCIM token created successfully");
+ toast.success("SCIM token created successfully");
} catch (error: any) {
console.error("Error creating SCIM token:", error);
- NotificationsManager.fromBackend("Failed to create SCIM token: " + parseErrorMessage(error));
+ toast.fromError("Failed to create SCIM token: " + parseErrorMessage(error));
} finally {
setIsCreatingToken(false);
}
@@ -97,10 +97,7 @@ const SCIMConfig: React.FC<SCIMConfigProps> = ({ accessToken, userID, proxySetti
</Text>
<div className="flex items-center">
<TextInput value={scimBaseUrl} disabled={true} className="grow" />
- <CopyToClipboard
- text={scimBaseUrl}
- onCopy={() => NotificationsManager.success("URL copied to clipboard")}
- >
+ <CopyToClipboard text={scimBaseUrl} onCopy={() => toast.success("URL copied to clipboard")}>
<TremorButton variant="primary" className="ml-2 flex items-center">
<CopyOutlined className="h-4 w-4 mr-1" />
Copy
@@ -160,10 +157,7 @@ const SCIMConfig: React.FC<SCIMConfigProps> = ({ accessToken, userID, proxySetti
</Text>
<div className="flex items-center">
<TextInput value={tokenData.key} className="grow mr-2 bg-white" type="password" disabled={true} />
- <CopyToClipboard
- text={tokenData.key}
- onCopy={() => NotificationsManager.success("Token copied to clipboard")}
- >
+ <CopyToClipboard text={tokenData.key} onCopy={() => toast.success("Token copied to clipboard")}>
<TremorButton variant="primary" className="flex items-center">
<CopyOutlined className="h-4 w-4 mr-1" />
Copy
diff --git a/ui/litellm-dashboard/src/components/SSOModals.test.tsx b/ui/litellm-dashboard/src/components/SSOModals.test.tsx
index 783fd58392a..47b1851459b 100644
--- a/ui/litellm-dashboard/src/components/SSOModals.test.tsx
+++ b/ui/litellm-dashboard/src/components/SSOModals.test.tsx
@@ -14,7 +14,7 @@ vi.mock("./shared/errorUtils", () => ({
parseErrorMessage: vi.fn((error) => error?.message || "An error occurred"),
}));
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getSSOSettings, updateSSOSettings } from "./networking";
describe("SSOModals", () => {
@@ -479,7 +479,7 @@ describe("SSOModals", () => {
it("should show Clear button and clear SSO settings when configured", async () => {
const mockHandleAddSSOOk = vi.fn();
(updateSSOSettings as any).mockResolvedValue({});
- (NotificationsManager.success as any).mockImplementation(() => {});
+ (toast.success as any).mockImplementation(() => {});
const TestWrapper = () => {
const [form] = Form.useForm();
@@ -538,7 +538,7 @@ describe("SSOModals", () => {
});
});
- expect(NotificationsManager.success).toHaveBeenCalledWith("SSO settings cleared successfully");
+ expect(toast.success).toHaveBeenCalledWith("SSO settings cleared successfully");
expect(mockHandleAddSSOOk).toHaveBeenCalled();
});
diff --git a/ui/litellm-dashboard/src/components/SSOModals.tsx b/ui/litellm-dashboard/src/components/SSOModals.tsx
index be57e14ff60..6c7c68e326f 100644
--- a/ui/litellm-dashboard/src/components/SSOModals.tsx
+++ b/ui/litellm-dashboard/src/components/SSOModals.tsx
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
import { Modal, Form, Button as Button2, Select, Checkbox } from "antd";
import { Text, TextInput } from "@tremor/react";
import { getSSOSettings, updateSSOSettings } from "./networking";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "./shared/errorUtils";
import { Logo } from "@/components/molecules/logo/Logo";
import { ssoProviderDisplayNames, ssoProviderLogoMap } from "./Settings/AdminSettings/SSOSettings/constants";
@@ -106,7 +106,7 @@ const SSOModals: React.FC<SSOModalsProps> = ({
// Enhanced form submission handler
const handleFormSubmit = async (formValues: Record<string, any>) => {
if (!accessToken) {
- NotificationsManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
@@ -168,14 +168,14 @@ const SSOModals: React.FC<SSOModalsProps> = ({
// Continue with the original flow (show instructions)
handleShowInstructions(formValues);
} catch (error: unknown) {
- NotificationsManager.fromBackend("Failed to save SSO settings: " + parseErrorMessage(error));
+ toast.fromError("Failed to save SSO settings: " + parseErrorMessage(error));
}
};
// Handle clearing SSO settings
const handleClearSSO = async () => {
if (!accessToken) {
- NotificationsManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
@@ -214,10 +214,10 @@ const SSOModals: React.FC<SSOModalsProps> = ({
// Close the main SSO modal and trigger refresh
handleAddSSOOk();
- NotificationsManager.success("SSO settings cleared successfully");
+ toast.success("SSO settings cleared successfully");
} catch (error) {
console.error("Failed to clear SSO settings:", error);
- NotificationsManager.fromBackend("Failed to clear SSO settings");
+ toast.fromError("Failed to clear SSO settings");
}
};
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/HashicorpVault/EditHashicorpVaultModal.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/HashicorpVault/EditHashicorpVaultModal.tsx
index 5fa344f3ec5..4904fa016a9 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/HashicorpVault/EditHashicorpVaultModal.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/HashicorpVault/EditHashicorpVaultModal.tsx
@@ -3,7 +3,7 @@
import { useHashicorpVaultConfig } from "@/app/(dashboard)/hooks/configOverrides/useHashicorpVaultConfig";
import { useUpdateHashicorpVaultConfig } from "@/app/(dashboard)/hooks/configOverrides/useUpdateHashicorpVaultConfig";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button, Divider, Form, Input, Modal, Space, Typography } from "antd";
import React, { useEffect } from "react";
import { SENSITIVE_FIELDS, FIELD_LABELS } from "./constants";
@@ -81,11 +81,11 @@ const EditHashicorpVaultModal: React.FC<EditHashicorpVaultModalProps> = ({ isVis
mutate(config, {
onSuccess: () => {
- NotificationManager.success("Hashicorp Vault configuration updated successfully");
+ toast.success("Hashicorp Vault configuration updated successfully");
onSuccess();
},
onError: (err) => {
- NotificationManager.fromBackend(err);
+ toast.fromError(err);
},
});
};
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/HashicorpVault/HashicorpVault.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/HashicorpVault/HashicorpVault.tsx
index 79a12c19571..187ece0213b 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/HashicorpVault/HashicorpVault.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/HashicorpVault/HashicorpVault.tsx
@@ -9,7 +9,7 @@ import { useHashicorpVaultConfig } from "@/app/(dashboard)/hooks/configOverrides
import { useUpdateHashicorpVaultConfig } from "@/app/(dashboard)/hooks/configOverrides/useUpdateHashicorpVaultConfig";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import DeleteResourceModal from "@/components/common_components/DeleteResourceModal";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Alert, AlertDescription, AlertTitle } from "@/components/shared/Alert";
import { Button } from "@/components/ui/button";
import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
@@ -52,9 +52,9 @@ export default function HashicorpVault() {
setIsTesting(true);
try {
const result = await testHashicorpVaultConnection(accessToken);
- NotificationManager.success(result.message || "Connection to Vault successful!");
+ toast.success(result.message || "Connection to Vault successful!");
} catch (err) {
- NotificationManager.fromBackend(err);
+ toast.fromError(err);
} finally {
setIsTesting(false);
}
@@ -63,10 +63,10 @@ export default function HashicorpVault() {
const handleDelete = () => {
deleteConfig(undefined, {
onSuccess: () => {
- NotificationManager.success("Hashicorp Vault configuration deleted");
+ toast.success("Hashicorp Vault configuration deleted");
setIsDeleteModalOpen(false);
},
- onError: (err) => NotificationManager.fromBackend(err),
+ onError: (err) => toast.fromError(err),
});
};
@@ -76,10 +76,10 @@ export default function HashicorpVault() {
{ [clearingField]: "" },
{
onSuccess: () => {
- NotificationManager.success(`${FIELD_LABELS[clearingField] ?? clearingField} cleared`);
+ toast.success(`${FIELD_LABELS[clearingField] ?? clearingField} cleared`);
setClearingField(null);
},
- onError: (err) => NotificationManager.fromBackend(err),
+ onError: (err) => toast.fromError(err),
},
);
};
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.test.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.test.tsx
index 7c01c579251..d4b2154767b 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.test.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.test.tsx
@@ -4,7 +4,7 @@ import {
useProxyConfig,
} from "@/app/(dashboard)/hooks/proxyConfig/useProxyConfig";
import { useStoreRequestInSpendLogs } from "@/app/(dashboard)/hooks/storeRequestInSpendLogs/useStoreRequestInSpendLogs";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "@/components/shared/errorUtils";
import { screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
@@ -23,12 +23,6 @@ vi.mock("@/app/(dashboard)/hooks/proxyConfig/useProxyConfig", async () => {
useDeleteProxyConfigField: vi.fn(),
};
});
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
vi.mock("@/components/shared/errorUtils", () => ({
parseErrorMessage: vi.fn(),
}));
@@ -36,7 +30,7 @@ vi.mock("@/components/shared/errorUtils", () => ({
const mockUseStoreRequestInSpendLogs = vi.mocked(useStoreRequestInSpendLogs);
const mockUseProxyConfig = vi.mocked(useProxyConfig);
const mockUseDeleteProxyConfigField = vi.mocked(useDeleteProxyConfigField);
-const mockNotificationsManager = vi.mocked(NotificationsManager);
+const mockToast = vi.mocked(toast);
const mockParseErrorMessage = vi.mocked(parseErrorMessage);
describe("LoggingSettings", () => {
@@ -330,7 +324,7 @@ describe("LoggingSettings", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Spend logs settings updated successfully");
+ expect(mockToast.success).toHaveBeenCalledWith("Spend logs settings updated successfully");
});
});
@@ -351,11 +345,9 @@ describe("LoggingSettings", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith(
- "Failed to save spend logs settings: Backend error",
- );
+ expect(mockToast.fromError).toHaveBeenCalledWith("Failed to save spend logs settings: Backend error");
});
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledTimes(1);
+ expect(mockToast.fromError).toHaveBeenCalledTimes(1);
});
it("should show loading state on save button when update pending", () => {
@@ -531,11 +523,11 @@ describe("LoggingSettings", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalled();
+ expect(mockToast.fromError).toHaveBeenCalled();
});
// the old value is still in force server side, so an unqualified success
// notification would tell the admin the opposite of what happened
- expect(mockNotificationsManager.success).not.toHaveBeenCalled();
+ expect(mockToast.success).not.toHaveBeenCalled();
});
it("should clear fields one at a time, never concurrently", async () => {
@@ -566,7 +558,7 @@ describe("LoggingSettings", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(mockNotificationsManager.success).toHaveBeenCalled();
+ expect(mockToast.success).toHaveBeenCalled();
});
// /config/field/delete rewrites the whole general_settings object, so two of
// them in flight at once means the later write restores what the earlier cleared
@@ -623,11 +615,11 @@ describe("LoggingSettings", () => {
await user.click(screen.getByRole("button", { name: "Save Settings" }));
await waitFor(() => {
- expect(mockNotificationsManager.success).toHaveBeenCalled();
+ expect(mockToast.success).toHaveBeenCalled();
});
expect(mockDeleteField).not.toHaveBeenCalled();
expect(mockMutate).toHaveBeenCalledWith({ store_prompts_in_spend_logs: true }, expect.any(Object));
- expect(mockNotificationsManager.fromBackend).not.toHaveBeenCalled();
+ expect(mockToast.fromError).not.toHaveBeenCalled();
});
it("should still clear a field that does have a stored value", async () => {
@@ -648,7 +640,7 @@ describe("LoggingSettings", () => {
await user.click(screen.getByRole("button", { name: "Save Settings" }));
await waitFor(() => {
- expect(mockNotificationsManager.success).toHaveBeenCalled();
+ expect(mockToast.success).toHaveBeenCalled();
});
expect(clearedFieldNames()).toContain("maximum_spend_logs_cleanup_run_budget");
});
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.tsx
index 07928768cd4..6402f3e238a 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.tsx
@@ -10,7 +10,7 @@ import {
StoreRequestInSpendLogsParams,
useStoreRequestInSpendLogs,
} from "@/app/(dashboard)/hooks/storeRequestInSpendLogs/useStoreRequestInSpendLogs";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "@/components/shared/errorUtils";
import { ClockCircleOutlined } from "@ant-design/icons";
import { Button, Card, Form, Input, InputNumber, Skeleton, Space, Switch, Typography } from "antd";
@@ -174,9 +174,8 @@ const LoggingSettings: React.FC = () => {
const updateParams = buildUpdateParams(formValues);
const submitUpdate = () =>
mutate(updateParams, {
- onSuccess: () => NotificationsManager.success("Spend logs settings updated successfully"),
- onError: (error) =>
- NotificationsManager.fromBackend("Failed to save spend logs settings: " + parseErrorMessage(error)),
+ onSuccess: () => toast.success("Spend logs settings updated successfully"),
+ onError: (error) => toast.fromError("Failed to save spend logs settings: " + parseErrorMessage(error)),
});
const fieldsToClear = omittedFieldNames(updateParams, isStored);
@@ -189,7 +188,7 @@ const LoggingSettings: React.FC = () => {
if (failed.length > 0) {
// Reporting an unqualified success here would tell the admin a setting
// was reset to its default while the old value is still in force.
- NotificationsManager.fromBackend(`Failed to clear saved value for: ${failed.join(", ")}`);
+ toast.fromError(`Failed to clear saved value for: ${failed.join(", ")}`);
return;
}
submitUpdate();
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/MCPSemanticFilterSettings.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/MCPSemanticFilterSettings.tsx
index 888ffa43261..b9dafd08f50 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/MCPSemanticFilterSettings.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/MCPSemanticFilterSettings.tsx
@@ -2,7 +2,7 @@
import { useMCPSemanticFilterSettings } from "@/app/(dashboard)/hooks/mcpSemanticFilterSettings/useMCPSemanticFilterSettings";
import { useUpdateMCPSemanticFilterSettings } from "@/app/(dashboard)/hooks/mcpSemanticFilterSettings/useUpdateMCPSemanticFilterSettings";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
Alert,
Button,
@@ -90,12 +90,10 @@ export default function MCPSemanticFilterSettings({ accessToken }: MCPSemanticFi
setIsDirty(false);
setSaveSuccess(true);
setTimeout(() => setSaveSuccess(false), 3000);
- NotificationManager.success(
- "Settings updated successfully. Changes will be applied across all pods within 10 seconds.",
- );
+ toast.success("Settings updated successfully. Changes will be applied across all pods within 10 seconds.");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
});
} catch (error) {
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/semanticFilterTestUtils.test.ts b/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/semanticFilterTestUtils.test.ts
index 5880cca3f8f..02d20358bc0 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/semanticFilterTestUtils.test.ts
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/semanticFilterTestUtils.test.ts
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { getCurlCommand, runSemanticFilterTest } from "./semanticFilterTestUtils";
import { testMCPSemanticFilter } from "@/components/networking";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/networking", () => ({
testMCPSemanticFilter: vi.fn(),
@@ -41,15 +41,15 @@ describe("runSemanticFilterTest", () => {
vi.clearAllMocks();
});
- it("should call NotificationManager.error and not set isTesting when testQuery is empty", async () => {
+ it("should call toast.error and not set isTesting when testQuery is empty", async () => {
await runSemanticFilterTest({ ...baseArgs, testQuery: "" });
- expect(NotificationManager.error).toHaveBeenCalledWith("Please enter a query and select a model");
+ expect(toast.error).toHaveBeenCalledWith("Please enter a query and select a model");
expect(mockSetIsTesting).not.toHaveBeenCalled();
});
- it("should call NotificationManager.error and not set isTesting when testModel is empty", async () => {
+ it("should call toast.error and not set isTesting when testModel is empty", async () => {
await runSemanticFilterTest({ ...baseArgs, testModel: "" });
- expect(NotificationManager.error).toHaveBeenCalledWith("Please enter a query and select a model");
+ expect(toast.error).toHaveBeenCalledWith("Please enter a query and select a model");
expect(mockSetIsTesting).not.toHaveBeenCalled();
});
@@ -89,7 +89,7 @@ describe("runSemanticFilterTest", () => {
selectedTools: 3,
tools: ["wiki", "github", "slack"],
});
- expect(NotificationManager.success).toHaveBeenCalledWith("Semantic filter test completed successfully");
+ expect(toast.success).toHaveBeenCalledWith("Semantic filter test completed successfully");
});
it("should show a warning when the filter header is missing", async () => {
@@ -100,9 +100,7 @@ describe("runSemanticFilterTest", () => {
await runSemanticFilterTest(baseArgs);
- expect(NotificationManager.warning).toHaveBeenCalledWith(
- "Semantic filter is not enabled or no tools were filtered",
- );
+ expect(toast.warning).toHaveBeenCalledWith("Semantic filter is not enabled or no tools were filtered");
expect(mockSetTestResult).not.toHaveBeenCalledWith(expect.objectContaining({ totalTools: expect.any(Number) }));
});
@@ -111,7 +109,7 @@ describe("runSemanticFilterTest", () => {
await runSemanticFilterTest(baseArgs);
- expect(NotificationManager.error).toHaveBeenCalledWith("Failed to test semantic filter");
+ expect(toast.error).toHaveBeenCalledWith("Failed to test semantic filter");
expect(mockSetIsTesting).toHaveBeenLastCalledWith(false);
});
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/semanticFilterTestUtils.ts b/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/semanticFilterTestUtils.ts
index 065014e2869..d3e585e8052 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/semanticFilterTestUtils.ts
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/MCPSemanticFilterSettings/semanticFilterTestUtils.ts
@@ -1,4 +1,4 @@
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { testMCPSemanticFilter } from "@/components/networking";
export interface TestResult {
@@ -39,7 +39,7 @@ export const runSemanticFilterTest = async ({
setTestError: (error: string | null) => void;
}) => {
if (!testQuery || !testModel || !accessToken) {
- NotificationManager.error("Please enter a query and select a model");
+ toast.error("Please enter a query and select a model");
return;
}
@@ -52,17 +52,17 @@ export const runSemanticFilterTest = async ({
const parsedResult = parseFilterHeaders(headers);
if (!parsedResult) {
- NotificationManager.warning("Semantic filter is not enabled or no tools were filtered");
+ toast.warning("Semantic filter is not enabled or no tools were filtered");
return;
}
setTestResult(parsedResult);
- NotificationManager.success("Semantic filter test completed successfully");
+ toast.success("Semantic filter test completed successfully");
} catch (error) {
console.error("Test failed:", error);
const message = error instanceof Error && error.message ? error.message : "Failed to test semantic filter";
setTestError(message);
- NotificationManager.error("Failed to test semantic filter");
+ toast.error("Failed to test semantic filter");
} finally {
setIsTesting(false);
}
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/AddSSOSettingsModal.test.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/AddSSOSettingsModal.test.tsx
index e5a5af6cba6..5f1f95b4b3e 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/AddSSOSettingsModal.test.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/AddSSOSettingsModal.test.tsx
@@ -23,14 +23,6 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
}),
}));
-// Mock NotificationsManager
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
describe("AddSSOSettingsModal", () => {
it("should render", () => {
const onCancel = vi.fn();
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/AddSSOSettingsModal.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/AddSSOSettingsModal.tsx
index 7af6240b19e..a1f62ea4939 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/AddSSOSettingsModal.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/AddSSOSettingsModal.tsx
@@ -1,6 +1,6 @@
"use client";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "@/components/shared/errorUtils";
import { Button, Form, Modal, Space } from "antd";
import React from "react";
@@ -24,11 +24,11 @@ const AddSSOSettingsModal: React.FC<AddSSOSettingsModalProps> = ({ isVisible, on
await mutateAsync(payload, {
onSuccess: () => {
- NotificationsManager.success("SSO settings added successfully");
+ toast.success("SSO settings added successfully");
onSuccess();
},
onError: (error) => {
- NotificationsManager.fromBackend("Failed to save SSO settings: " + parseErrorMessage(error));
+ toast.fromError("Failed to save SSO settings: " + parseErrorMessage(error));
},
});
};
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/DeleteSSOSettingsModal.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/DeleteSSOSettingsModal.tsx
index cbb55be6c1f..053dac499bd 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/DeleteSSOSettingsModal.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/DeleteSSOSettingsModal.tsx
@@ -2,7 +2,7 @@ import { useEditSSOSettings } from "@/app/(dashboard)/hooks/sso/useEditSSOSettin
import { useSSOSettings } from "@/app/(dashboard)/hooks/sso/useSSOSettings";
import React from "react";
import DeleteResourceModal from "../../../../common_components/DeleteResourceModal";
-import NotificationsManager from "../../../../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "../../../../shared/errorUtils";
import { detectSSOProvider } from "../utils";
@@ -42,12 +42,12 @@ const DeleteSSOSettingsModal: React.FC<DeleteSSOSettingsModalProps> = ({ isVisib
await editSSOSettings(clearSettings, {
onSuccess: () => {
- NotificationsManager.success("SSO settings cleared successfully");
+ toast.success("SSO settings cleared successfully");
onCancel();
onSuccess();
},
onError: (error) => {
- NotificationsManager.fromBackend("Failed to clear SSO settings: " + parseErrorMessage(error));
+ toast.fromError("Failed to clear SSO settings: " + parseErrorMessage(error));
},
});
};
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/EditSSOSettingsModal.test.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/EditSSOSettingsModal.test.tsx
index 7536286b404..664d7cc5373 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/EditSSOSettingsModal.test.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/EditSSOSettingsModal.test.tsx
@@ -3,7 +3,7 @@ import { describe, it, expect, vi, beforeEach, Mock } from "vitest";
import EditSSOSettingsModal from "./EditSSOSettingsModal";
import { useSSOSettings } from "@/app/(dashboard)/hooks/sso/useSSOSettings";
import { useEditSSOSettings } from "@/app/(dashboard)/hooks/sso/useEditSSOSettings";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "@/components/shared/errorUtils";
import { processSSOSettingsPayload } from "../utils";
@@ -170,13 +170,6 @@ vi.mock("@/app/(dashboard)/hooks/sso/useEditSSOSettings", () => ({
useEditSSOSettings: vi.fn(),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
vi.mock("@/components/shared/errorUtils", () => ({
parseErrorMessage: vi.fn(),
}));
@@ -348,7 +341,7 @@ describe("EditSSOSettingsModal", () => {
fireEvent.click(screen.getByTestId(TEST_IDS.TRIGGER_FORM_SUBMIT));
- expect(NotificationsManager.success).toHaveBeenCalledWith(TEST_DATA.SUCCESS_MESSAGE);
+ expect(toast.success).toHaveBeenCalledWith(TEST_DATA.SUCCESS_MESSAGE);
expect(mockOnSuccess).toHaveBeenCalled();
});
@@ -370,9 +363,7 @@ describe("EditSSOSettingsModal", () => {
fireEvent.click(screen.getByTestId(TEST_IDS.TRIGGER_FORM_SUBMIT));
expect(parseErrorMessage).toHaveBeenCalledWith(error);
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(
- `${TEST_DATA.ERROR_MESSAGE_PREFIX} Parsed error message`,
- );
+ expect(toast.fromError).toHaveBeenCalledWith(`${TEST_DATA.ERROR_MESSAGE_PREFIX} Parsed error message`);
});
});
@@ -530,7 +521,7 @@ describe("EditSSOSettingsModal", () => {
fireEvent.click(screen.getByTestId(TEST_IDS.TRIGGER_FORM_SUBMIT));
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(`${TEST_DATA.ERROR_MESSAGE_PREFIX} undefined`);
+ expect(toast.fromError).toHaveBeenCalledWith(`${TEST_DATA.ERROR_MESSAGE_PREFIX} undefined`);
});
it("handles form submission with malformed data", async () => {
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/EditSSOSettingsModal.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/EditSSOSettingsModal.tsx
index 97fbc31ce2f..3d968996037 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/EditSSOSettingsModal.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/EditSSOSettingsModal.tsx
@@ -3,7 +3,7 @@
import { Button, Form, Modal, Space } from "antd";
import React, { useEffect } from "react";
import BaseSSOSettingsForm from "./BaseSSOSettingsForm";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "@/components/shared/errorUtils";
import { detectSSOProvider, processSSOSettingsPayload } from "../utils";
import { useSSOSettings } from "@/app/(dashboard)/hooks/sso/useSSOSettings";
@@ -86,16 +86,16 @@ const EditSSOSettingsModal: React.FC<EditSSOSettingsModalProps> = ({ isVisible,
await mutateAsync(payload, {
onSuccess: () => {
- NotificationsManager.success("SSO settings updated successfully");
+ toast.success("SSO settings updated successfully");
onSuccess();
},
onError: (error) => {
- NotificationsManager.fromBackend("Failed to save SSO settings: " + parseErrorMessage(error));
+ toast.fromError("Failed to save SSO settings: " + parseErrorMessage(error));
},
});
} catch (error) {
// Handle processing errors gracefully
- NotificationsManager.fromBackend("Failed to process SSO settings: " + parseErrorMessage(error));
+ toast.fromError("Failed to process SSO settings: " + parseErrorMessage(error));
}
};
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/UISettings/UISettings.test.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/UISettings/UISettings.test.tsx
index 639564bbd35..c2834e65498 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/UISettings/UISettings.test.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/UISettings/UISettings.test.tsx
@@ -1,7 +1,7 @@
import { render, screen, fireEvent, act } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import UISettings from "./UISettings";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
const mockUseAuthorized = vi.hoisted(() => vi.fn());
const mockUseUISettings = vi.hoisted(() => vi.fn());
@@ -20,13 +20,6 @@ vi.mock("@/app/(dashboard)/hooks/uiSettings/useUpdateUISettings", () => ({
useUpdateUISettings: mockUseUpdateUISettings,
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
const buildSettingsResponse = (overrides?: Partial<Record<string, unknown>>) => ({
data: {
field_schema: {
@@ -102,7 +95,7 @@ describe("UISettings", () => {
onError: expect.any(Function),
}),
);
- expect(NotificationManager.success).toHaveBeenCalledWith("UI settings updated successfully");
+ expect(toast.success).toHaveBeenCalledWith("UI settings updated successfully");
});
it("should toggle disable team admin delete team user setting and call update", () => {
@@ -131,7 +124,7 @@ describe("UISettings", () => {
onError: expect.any(Function),
}),
);
- expect(NotificationManager.success).toHaveBeenCalledWith("UI settings updated successfully");
+ expect(toast.success).toHaveBeenCalledWith("UI settings updated successfully");
});
it("should toggle require auth for public AI Hub setting and call update", () => {
@@ -160,6 +153,6 @@ describe("UISettings", () => {
onError: expect.any(Function),
}),
);
- expect(NotificationManager.success).toHaveBeenCalledWith("UI settings updated successfully");
+ expect(toast.success).toHaveBeenCalledWith("UI settings updated successfully");
});
});
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/UISettings/UISettings.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/UISettings/UISettings.tsx
index 3959fd9f012..612ca05d083 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/UISettings/UISettings.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/UISettings/UISettings.tsx
@@ -3,7 +3,7 @@
import { useUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUISettings";
import { useUpdateUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUpdateUISettings";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Alert, AlertDescription, AlertTitle } from "@/components/shared/Alert";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
@@ -76,10 +76,10 @@ export default function UISettings() {
{ disable_model_add_for_internal_users: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -90,10 +90,10 @@ export default function UISettings() {
{ disable_team_admin_delete_team_user: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -102,10 +102,10 @@ export default function UISettings() {
const handleUpdatePageVisibility = (settings: { enabled_ui_pages_internal_users: string[] | null }) => {
updateSettings(settings, {
onSuccess: () => {
- NotificationManager.success("Page visibility settings updated successfully");
+ toast.success("Page visibility settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
});
};
@@ -115,10 +115,10 @@ export default function UISettings() {
{ forward_client_headers_to_llm_api: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -129,10 +129,10 @@ export default function UISettings() {
{ forward_llm_provider_auth_headers: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -143,11 +143,11 @@ export default function UISettings() {
{ enable_projects_ui: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully. Refreshing page...");
+ toast.success("UI settings updated successfully. Refreshing page...");
setTimeout(() => window.location.reload(), 1000);
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -158,11 +158,11 @@ export default function UISettings() {
{ enable_chat_ui: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully. Refreshing page...");
+ toast.success("UI settings updated successfully. Refreshing page...");
setTimeout(() => window.location.reload(), 1000);
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -173,10 +173,10 @@ export default function UISettings() {
{ require_auth_for_public_ai_hub: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -187,10 +187,10 @@ export default function UISettings() {
{ disable_agents_for_internal_users: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -201,10 +201,10 @@ export default function UISettings() {
{ allow_agents_for_team_admins: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -215,10 +215,10 @@ export default function UISettings() {
{ disable_vector_stores_for_internal_users: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -229,10 +229,10 @@ export default function UISettings() {
{ allow_vector_stores_for_team_admins: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -243,10 +243,10 @@ export default function UISettings() {
{ scope_user_search_to_org: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
@@ -257,10 +257,10 @@ export default function UISettings() {
{ disable_custom_api_keys: checked },
{
onSuccess: () => {
- NotificationManager.success("UI settings updated successfully");
+ toast.success("UI settings updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
},
);
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/UserBannerSettings/UserBannerSettings.test.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/UserBannerSettings/UserBannerSettings.test.tsx
index 9a0e2e72311..f11c95680c1 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/UserBannerSettings/UserBannerSettings.test.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/UserBannerSettings/UserBannerSettings.test.tsx
@@ -16,10 +16,6 @@ vi.mock("@/app/(dashboard)/hooks/userBanner/useUpdateUserBanner", () => ({
useUpdateUserBanner: vi.fn(),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
-
import { useUserBanner } from "@/app/(dashboard)/hooks/userBanner/useUserBanner";
import { useUpdateUserBanner } from "@/app/(dashboard)/hooks/userBanner/useUpdateUserBanner";
diff --git a/ui/litellm-dashboard/src/components/Settings/AdminSettings/UserBannerSettings/UserBannerSettings.tsx b/ui/litellm-dashboard/src/components/Settings/AdminSettings/UserBannerSettings/UserBannerSettings.tsx
index 83207f89160..87987aff144 100644
--- a/ui/litellm-dashboard/src/components/Settings/AdminSettings/UserBannerSettings/UserBannerSettings.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/AdminSettings/UserBannerSettings/UserBannerSettings.tsx
@@ -4,7 +4,7 @@ import React, { useState } from "react";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { useUpdateUserBanner } from "@/app/(dashboard)/hooks/userBanner/useUpdateUserBanner";
import { useUserBanner } from "@/app/(dashboard)/hooks/userBanner/useUserBanner";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { UserBanner, UserBannerSeverity, UserBannerUpdate } from "@/components/networking";
import { Alert, AlertDescription } from "@/components/shared/Alert";
import { Button } from "@/components/ui/button";
@@ -60,10 +60,10 @@ function UserBannerSettingsForm({ persisted, isLoading, isPending, saveBanner }:
const handleSave = () => {
saveBanner(draft, {
onSuccess: () => {
- NotificationManager.success("User banner updated successfully");
+ toast.success("User banner updated successfully");
},
onError: (error) => {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
},
});
};
diff --git a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/AddFallbacks.test.tsx b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/AddFallbacks.test.tsx
index eaced9e22b0..40637f8cb34 100644
--- a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/AddFallbacks.test.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/AddFallbacks.test.tsx
@@ -3,16 +3,12 @@ import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
import AddFallbacks, { Fallbacks } from "./AddFallbacks";
import * as fetchModelsModule from "@/components/llm_calls/fetch_models";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
vi.mock("@/components/llm_calls/fetch_models", () => ({
fetchAvailableModels: vi.fn(),
}));
-vi.mock("@/components/molecules/message_manager", () => ({
- default: { error: vi.fn(), success: vi.fn(), warning: vi.fn(), info: vi.fn(), destroy: vi.fn() },
-}));
-
vi.mock("./FallbackSelectionForm", () => ({
FallbackSelectionForm: ({ groups, onGroupsChange }: any) => {
const handleUpdateGroup = () => {
@@ -135,7 +131,7 @@ describe("AddFallbacks", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(MessageManager.error).toHaveBeenCalled();
+ expect(toast.error).toHaveBeenCalled();
});
});
@@ -154,7 +150,7 @@ describe("AddFallbacks", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(MessageManager.error).toHaveBeenCalled();
+ expect(toast.error).toHaveBeenCalled();
});
});
diff --git a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/AddFallbacks.tsx b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/AddFallbacks.tsx
index 2bd17bffaba..d98cc20d421 100644
--- a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/AddFallbacks.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/AddFallbacks.tsx
@@ -7,8 +7,7 @@
import React, { useEffect, useState } from "react";
import { Button } from "@/components/ui/button";
import { UiLoadingSpinner } from "@/components/ui/ui-loading-spinner";
-import MessageManager from "@/components/molecules/message_manager";
-import NotificationManager from "../../../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { fetchAvailableModels, ModelGroup } from "@/components/llm_calls/fetch_models";
import { AddFallbacksModal } from "./AddFallbacksModal";
import { FallbackGroup } from "./FallbackGroupConfig";
@@ -82,9 +81,7 @@ export default function AddFallbacks({ accessToken, value = [], onChange }: AddF
// Validation
const invalidGroups = groups.filter((g) => !g.primaryModel || g.fallbackModels.length === 0);
if (invalidGroups.length > 0) {
- MessageManager.error(
- `Please complete configuration for all groups. ${invalidGroups.length} group(s) incomplete.`,
- );
+ toast.error(`Please complete configuration for all groups. ${invalidGroups.length} group(s) incomplete.`);
return;
}
@@ -104,7 +101,7 @@ export default function AddFallbacks({ accessToken, value = [], onChange }: AddF
setIsSaving(true);
try {
await onChange(updatedFallbacks);
- NotificationManager.success(`${groups.length} fallback configuration(s) added successfully!`);
+ toast.success(`${groups.length} fallback configuration(s) added successfully!`);
handleCancel();
} catch (error) {
// Error handling is done in handleFallbacksChange, so we don't need to show another notification here
@@ -113,7 +110,7 @@ export default function AddFallbacks({ accessToken, value = [], onChange }: AddF
setIsSaving(false);
}
} else {
- NotificationManager.fromBackend("onChange callback not provided");
+ toast.fromError("onChange callback not provided");
}
};
diff --git a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/EditFallbacks.tsx b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/EditFallbacks.tsx
index 3efdcfd6b51..2dd143f7e21 100644
--- a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/EditFallbacks.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/EditFallbacks.tsx
@@ -9,7 +9,7 @@ import { useQuery } from "@tanstack/react-query";
import { LoaderCircle, Pencil } from "lucide-react";
import React, { useMemo, useState } from "react";
import { fetchAvailableModels } from "@/components/llm_calls/fetch_models";
-import NotificationManager from "../../../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { AddFallbacksModal } from "./AddFallbacksModal";
import { FallbackGroup, FallbackGroupConfig } from "./FallbackGroupConfig";
@@ -69,7 +69,7 @@ export default function EditFallbacks({
setIsSaving(true);
try {
await onChange(updatedFallbacks);
- NotificationManager.success(`Fallbacks for ${primaryModel} updated successfully!`);
+ toast.success(`Fallbacks for ${primaryModel} updated successfully!`);
onClose();
} catch (error) {
console.error("Error updating fallbacks:", error);
diff --git a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/FallbackSelectionForm.test.tsx b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/FallbackSelectionForm.test.tsx
index 7f013a56229..ac9b4d98aed 100644
--- a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/FallbackSelectionForm.test.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/FallbackSelectionForm.test.tsx
@@ -3,15 +3,11 @@ import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { FallbackSelectionForm } from "./FallbackSelectionForm";
import type { FallbackGroup } from "./FallbackGroupConfig";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
const mockOnGroupsChange = vi.fn();
const AVAILABLE_MODELS = ["gpt-4", "gpt-3.5-turbo", "claude-3-opus"];
-vi.mock("@/components/molecules/message_manager", () => ({
- default: { error: vi.fn(), success: vi.fn(), warning: vi.fn(), info: vi.fn(), destroy: vi.fn() },
-}));
-
describe("FallbackSelectionForm", () => {
beforeEach(() => {
vi.clearAllMocks();
@@ -135,7 +131,7 @@ describe("FallbackSelectionForm", () => {
const [newGroups] = mockOnGroupsChange.mock.calls[0];
expect(newGroups).toHaveLength(1);
expect(newGroups[0].id).toBe("2");
- expect(MessageManager.warning).not.toHaveBeenCalled();
+ expect(toast.warning).not.toHaveBeenCalled();
});
it("should render FallbackGroupConfig for each group", () => {
diff --git a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/FallbackSelectionForm.tsx b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/FallbackSelectionForm.tsx
index 379742f99b4..53880a7f795 100644
--- a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/FallbackSelectionForm.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/FallbackSelectionForm.tsx
@@ -8,7 +8,7 @@ import { Button } from "@tremor/react";
import { Tabs } from "antd";
import { Plus } from "lucide-react";
import React, { useEffect, useState } from "react";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { FallbackGroup, FallbackGroupConfig } from "./FallbackGroupConfig";
interface FallbackSelectionFormProps {
@@ -61,7 +61,7 @@ export function FallbackSelectionForm({
const handleRemoveGroup = (targetId: string) => {
if (groups.length === 1) {
- MessageManager.warning("At least one group is required");
+ toast.warning("At least one group is required");
return;
}
const newGroups = groups.filter((g) => g.id !== targetId);
diff --git a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/Fallbacks.tsx b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/Fallbacks.tsx
index f82780f0c73..3815a71b867 100644
--- a/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/Fallbacks.tsx
+++ b/ui/litellm-dashboard/src/components/Settings/RouterSettings/Fallbacks/Fallbacks.tsx
@@ -6,7 +6,7 @@ import openai from "openai";
import React, { useEffect, useState } from "react";
import DeleteResourceModal from "../../../common_components/DeleteResourceModal";
import { ProviderLogo } from "../../../molecules/models/ProviderLogo";
-import NotificationsManager from "../../../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getCallbacksCall, setCallbacksCall } from "../../../networking";
import { isProxyAdminRole } from "@/utils/roles";
import AddFallbacks from "./AddFallbacks";
@@ -87,7 +87,7 @@ async function testFallbackModelResponse(selectedModel: string, accessToken: str
});
try {
- NotificationsManager.info("Testing fallback model response...");
+ toast.info("Testing fallback model response...");
const response = await client.chat.completions.create({
model: selectedModel,
@@ -101,7 +101,7 @@ async function testFallbackModelResponse(selectedModel: string, accessToken: str
mock_testing_fallbacks: true,
});
- NotificationsManager.success(
+ toast.success(
<span>
Test model=<strong>{selectedModel}</strong>, received model=
<strong>{response.model}</strong>. See{" "}
@@ -115,9 +115,7 @@ async function testFallbackModelResponse(selectedModel: string, accessToken: str
</span>,
);
} catch (error) {
- NotificationsManager.fromBackend(
- `Error occurred while generating model response. Please try again. Error: ${error}`,
- );
+ toast.fromError(`Error occurred while generating model response. Please try again. Error: ${error}`);
}
}
@@ -195,9 +193,9 @@ const Fallbacks: React.FC<FallbacksProps> = ({ accessToken, userRole, userID })
try {
await setCallbacksCall(accessToken, payload);
setRouterSettings(updatedSettings);
- NotificationsManager.success("Router settings updated successfully");
+ toast.success("Router settings updated successfully");
} catch (error) {
- NotificationsManager.fromBackend("Failed to update router settings: " + error);
+ toast.fromError("Failed to update router settings: " + error);
} finally {
setIsDeleting(false);
setIsDeleteModalOpen(false);
@@ -234,7 +232,7 @@ const Fallbacks: React.FC<FallbacksProps> = ({ accessToken, userRole, userID })
setRouterSettings(updatedSettings);
} catch (error) {
// Revert on error by refetching from server
- NotificationsManager.fromBackend("Failed to update router settings: " + error);
+ toast.fromError("Failed to update router settings: " + error);
if (accessToken && userRole && userID) {
getCallbacksCall(accessToken, userID, userRole).then((data) => {
let router_settings = data.router_settings;
diff --git a/ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx b/ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx
index 9b4e0527190..7b3153f6e13 100644
--- a/ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx
+++ b/ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx
@@ -4,7 +4,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import { renderWithProviders, screen, testQueryClient, waitFor, within } from "../../tests/test-utils";
import TeamSSOSettings from "./TeamSSOSettings";
import * as networking from "./networking";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
vi.mock("./networking");
@@ -99,7 +99,7 @@ vi.mock("./ModelSelect/ModelSelect", () => {
const mockGetDefaultTeamSettings = vi.mocked(networking.getDefaultTeamSettings);
const mockUpdateDefaultTeamSettings = vi.mocked(networking.updateDefaultTeamSettings);
const mockOrganizationListCall = vi.mocked(networking.organizationListCall);
-const mockNotificationsManager = vi.mocked(NotificationsManager);
+const mockToast = vi.mocked(toast);
const MOCK_ORGANIZATIONS = [
{ organization_id: "org-1", organization_alias: "Engineering" },
@@ -151,7 +151,7 @@ describe("TeamSSOSettings", () => {
screen.getByText("No team settings available or you do not have permission to view them."),
).toBeInTheDocument();
});
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith("Failed to fetch team settings");
+ expect(mockToast.fromError).toHaveBeenCalledWith("Failed to fetch team settings");
});
it("should not fetch settings when access token is null", async () => {
@@ -407,7 +407,7 @@ describe("TeamSSOSettings", () => {
expect(mockUpdateDefaultTeamSettings).toHaveBeenCalledWith("test-token", expect.any(Object));
});
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Default team settings updated successfully");
+ expect(mockToast.success).toHaveBeenCalledWith("Default team settings updated successfully");
// Should exit edit mode after save
await waitFor(() => {
@@ -547,7 +547,7 @@ describe("TeamSSOSettings", () => {
await userEvent.click(screen.getByRole("button", { name: /Save Changes/i }));
await waitFor(() => {
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith("Failed to update team settings");
+ expect(mockToast.fromError).toHaveBeenCalledWith("Failed to update team settings");
});
});
diff --git a/ui/litellm-dashboard/src/components/TeamSSOSettings.tsx b/ui/litellm-dashboard/src/components/TeamSSOSettings.tsx
index 7845203411a..ed53a54022f 100644
--- a/ui/litellm-dashboard/src/components/TeamSSOSettings.tsx
+++ b/ui/litellm-dashboard/src/components/TeamSSOSettings.tsx
@@ -23,7 +23,7 @@ import { UiLoadingSpinner } from "@/components/ui/ui-loading-spinner";
import { getDefaultTeamSettings, updateDefaultTeamSettings, Organization } from "./networking";
import BudgetDurationDropdown, { getBudgetDurationLabel } from "./common_components/budget_duration_dropdown";
import { getModelDisplayName } from "./key_team_helpers/fetch_available_models_team_key";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { ModelSelect } from "./ModelSelect/ModelSelect";
import OrganizationDropdown from "./common_components/OrganizationDropdown";
@@ -135,7 +135,7 @@ const TeamSSOSettings: React.FC<TeamSSOSettingsProps> = ({ accessToken }) => {
} catch (error) {
console.error("Error fetching team SSO settings:", error);
setFetchError(true);
- NotificationsManager.fromBackend("Failed to fetch team settings");
+ toast.fromError("Failed to fetch team settings");
} finally {
setLoading(false);
}
@@ -154,10 +154,10 @@ const TeamSSOSettings: React.FC<TeamSSOSettingsProps> = ({ accessToken }) => {
setValues(newValues);
setEditedValues(newValues);
setIsEditing(false);
- NotificationsManager.success("Default team settings updated successfully");
+ toast.success("Default team settings updated successfully");
} catch (error) {
console.error("Error updating team settings:", error);
- NotificationsManager.fromBackend("Failed to update team settings");
+ toast.fromError("Failed to update team settings");
} finally {
setSaving(false);
}
diff --git a/ui/litellm-dashboard/src/components/Teams.test.tsx b/ui/litellm-dashboard/src/components/Teams.test.tsx
index 22ec986ba82..6f15f23b193 100644
--- a/ui/litellm-dashboard/src/components/Teams.test.tsx
+++ b/ui/litellm-dashboard/src/components/Teams.test.tsx
@@ -5,7 +5,7 @@ import { NuqsTestingAdapter, OnUrlUpdateFunction } from "nuqs/adapters/testing";
import React from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { useTeamMetadataSchema } from "@/app/(dashboard)/hooks/teams/useTeamMetadataSchema";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { fetchAvailableModelsForTeamOrKey } from "./key_team_helpers/fetch_available_models_team_key";
import {
fetchMCPAccessGroups,
@@ -53,15 +53,6 @@ vi.mock("@/app/(dashboard)/hooks/teams/useTeamMetadataSchema", () => ({
useTeamMetadataSchema: vi.fn(() => ({ data: [], isLoading: false })),
}));
-vi.mock("./molecules/notifications_manager", () => ({
- default: {
- info: vi.fn(),
- success: vi.fn(),
- error: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
vi.mock("./key_team_helpers/fetch_available_models_team_key", () => ({
fetchAvailableModelsForTeamOrKey: vi.fn(),
getModelDisplayName: vi.fn((model: string) => model),
@@ -918,7 +909,7 @@ describe("Teams - schema-declared metadata fields in team create", () => {
fireEvent.click(createTeamSubmitButtons[createTeamSubmitButtons.length - 1]);
await waitFor(() => {
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(
+ expect(toast.fromError).toHaveBeenCalledWith(
"Error creating the team: Cost center CC-9999 is not recognized. Contact the FinOps team.",
);
});
diff --git a/ui/litellm-dashboard/src/components/Teams.tsx b/ui/litellm-dashboard/src/components/Teams.tsx
index becbe0e2b48..7a96ffa69e2 100644
--- a/ui/litellm-dashboard/src/components/Teams.tsx
+++ b/ui/litellm-dashboard/src/components/Teams.tsx
@@ -27,7 +27,7 @@ import { fetchAvailableModelsForTeamOrKey } from "./key_team_helpers/fetch_avail
import type { Team } from "./key_team_helpers/key_list";
import MCPServerSelector from "./mcp_server_management/MCPServerSelector";
import MCPToolPermissions from "./mcp_server_management/MCPToolPermissions";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { extractProxyErrorMessage } from "@/lib/http/client";
import BudgetDurationDropdown, {
getBudgetDurationLabel,
@@ -222,9 +222,9 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, premiumUser
setIsTeamDeleting(true);
await teamDeleteCall(accessToken, teamToDelete.team_id);
await refreshTeams();
- NotificationsManager.success("Team deleted successfully");
+ toast.success("Team deleted successfully");
} catch (error) {
- NotificationsManager.fromBackend("Error deleting the team: " + error);
+ toast.fromError("Error deleting the team: " + error);
} finally {
setIsTeamDeleting(false);
setIsDeleteModalOpen(false);
@@ -269,7 +269,7 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, premiumUser
formValues.budget_duration = null;
}
- NotificationsManager.info("Creating Team");
+ toast.info("Creating Team");
const metadataObject = {
...metadataPairsToObject(formValues.metadata),
@@ -375,7 +375,7 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, premiumUser
}
await teamCreateCall(accessToken, { ...formValues, models: normalizeTeamModelSelection(formValues.models) });
- NotificationsManager.success("Team created");
+ toast.success("Team created");
await refreshTeams();
form.resetFields();
setLoggingSettings([]);
@@ -386,7 +386,7 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, premiumUser
}
} catch (error) {
console.error("Error creating the team:", error);
- NotificationsManager.fromBackend("Error creating the team: " + extractProxyErrorMessage(error));
+ toast.fromError("Error creating the team: " + extractProxyErrorMessage(error));
}
};
diff --git a/ui/litellm-dashboard/src/components/ToolPolicies/ToolPoliciesPanel.test.tsx b/ui/litellm-dashboard/src/components/ToolPolicies/ToolPoliciesPanel.test.tsx
index 3c8a0da3347..aaa70a5e357 100644
--- a/ui/litellm-dashboard/src/components/ToolPolicies/ToolPoliciesPanel.test.tsx
+++ b/ui/litellm-dashboard/src/components/ToolPolicies/ToolPoliciesPanel.test.tsx
@@ -7,6 +7,7 @@ import { focusManager, QueryClient, QueryClientProvider } from "@tanstack/react-
import { renderWithProviders, testQueryClient } from "../../../tests/test-utils";
import type { ToolRow } from "@/components/networking";
import { ToolPoliciesPanel } from "./ToolPoliciesPanel";
+import { toast } from "@/lib/toast";
const fetchToolsList = vi.fn();
const updateToolPolicy = vi.fn();
@@ -16,10 +17,7 @@ vi.mock("@/components/networking", () => ({
updateToolPolicy: (...args: unknown[]) => updateToolPolicy(...args),
}));
-const fromBackend = vi.fn();
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { fromBackend: (...args: unknown[]) => fromBackend(...args) },
-}));
+const fromBackend = vi.mocked(toast.fromError);
const can = vi.fn();
vi.mock("@/app/(dashboard)/hooks/useCan", () => ({
diff --git a/ui/litellm-dashboard/src/components/ToolPolicies/ToolPoliciesPanel.tsx b/ui/litellm-dashboard/src/components/ToolPolicies/ToolPoliciesPanel.tsx
index df5d8553948..7876e5de966 100644
--- a/ui/litellm-dashboard/src/components/ToolPolicies/ToolPoliciesPanel.tsx
+++ b/ui/litellm-dashboard/src/components/ToolPolicies/ToolPoliciesPanel.tsx
@@ -5,7 +5,7 @@ import React, { useCallback, useMemo, useState } from "react";
import useCan from "@/app/(dashboard)/hooks/useCan";
import { MetricCard } from "@/components/GuardrailsMonitor/MetricCard";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { ToolRow, updateToolPolicy } from "@/components/networking";
import { toolPoliciesListOptions } from "./toolPoliciesQueries";
@@ -79,7 +79,7 @@ export const ToolPoliciesPanel: React.FC<ToolPoliciesPanelProps> = ({ accessToke
await updateToolPolicy(accessToken, toolName, { input_policy: newPolicy });
await patchTool(toolName, { input_policy: newPolicy });
} catch (e) {
- NotificationsManager.fromBackend(`Failed to update input policy: ${toMessage(e, "unknown error")}`);
+ toast.fromError(`Failed to update input policy: ${toMessage(e, "unknown error")}`);
} finally {
setSavingInput((previous) => withoutTool(previous, toolName));
}
@@ -95,7 +95,7 @@ export const ToolPoliciesPanel: React.FC<ToolPoliciesPanelProps> = ({ accessToke
await updateToolPolicy(accessToken, toolName, { output_policy: newPolicy });
await patchTool(toolName, { output_policy: newPolicy });
} catch (e) {
- NotificationsManager.fromBackend(`Failed to update output policy: ${toMessage(e, "unknown error")}`);
+ toast.fromError(`Failed to update output policy: ${toMessage(e, "unknown error")}`);
} finally {
setSavingOutput((previous) => withoutTool(previous, toolName));
}
diff --git a/ui/litellm-dashboard/src/components/UIAccessControlForm.tsx b/ui/litellm-dashboard/src/components/UIAccessControlForm.tsx
index 77bee2c1e52..656142a4765 100644
--- a/ui/litellm-dashboard/src/components/UIAccessControlForm.tsx
+++ b/ui/litellm-dashboard/src/components/UIAccessControlForm.tsx
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
import { Form, Button as Button2, Select } from "antd";
import { Text, TextInput } from "@tremor/react";
import { getSSOSettings, updateSSOSettings } from "./networking";
-import NotificationManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface UIAccessControlFormProps {
accessToken: string | null;
@@ -53,7 +53,7 @@ const UIAccessControlForm: React.FC<UIAccessControlFormProps> = ({ accessToken,
const handleUIAccessSubmit = async (formValues: Record<string, any>) => {
if (!accessToken) {
- NotificationManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
@@ -81,7 +81,7 @@ const UIAccessControlForm: React.FC<UIAccessControlFormProps> = ({ accessToken,
onSuccess();
} catch (error) {
console.error("Failed to save UI access settings:", error);
- NotificationManager.fromBackend("Failed to save UI access settings");
+ toast.fromError("Failed to save UI access settings");
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/UIAccessControlForm.unit.test.tsx b/ui/litellm-dashboard/src/components/UIAccessControlForm.unit.test.tsx
index d547b372ef6..b79284f623b 100644
--- a/ui/litellm-dashboard/src/components/UIAccessControlForm.unit.test.tsx
+++ b/ui/litellm-dashboard/src/components/UIAccessControlForm.unit.test.tsx
@@ -6,13 +6,6 @@ vi.mock("./networking", () => ({
updateSSOSettings: vi.fn(),
}));
-// Mock NotificationManager
-vi.mock("./molecules/notifications_manager", () => ({
- default: {
- fromBackend: vi.fn(),
- },
-}));
-
// Extract the logic we want to test into a pure function
const buildApiPayload = (formValues: Record<string, any>) => {
if (formValues.ui_access_mode_type === "all_authenticated_users") {
diff --git a/ui/litellm-dashboard/src/components/add_model/ClassifierPromptEditor.tsx b/ui/litellm-dashboard/src/components/add_model/ClassifierPromptEditor.tsx
index 814867500a6..d29fab331c7 100644
--- a/ui/litellm-dashboard/src/components/add_model/ClassifierPromptEditor.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/ClassifierPromptEditor.tsx
@@ -2,7 +2,7 @@ import React, { useCallback, useState } from "react";
import { TriangleAlert } from "lucide-react";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { getAutoRouterClassifierDefaultPromptCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Textarea } from "@/components/ui/textarea";
@@ -47,7 +47,7 @@ const ClassifierPromptEditor: React.FC<ClassifierPromptEditorProps> = ({
setDefaultPrompt(fetched);
setDraft(initialDraftText(systemPrompt, fetched));
} catch {
- NotificationsManager.fromBackend("Could not load the default classifier prompt");
+ toast.fromError("Could not load the default classifier prompt");
setIsOpen(false);
} finally {
setIsLoading(false);
diff --git a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.test.tsx b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.test.tsx
index c2a7db1356e..988bae46bb4 100644
--- a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.test.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.test.tsx
@@ -2,7 +2,7 @@ import { renderWithProviders, screen, waitFor, within, fireEvent, testQueryClien
import userEvent from "@testing-library/user-event";
import { vi } from "vitest";
import AddAutoRouterTab from "./add_auto_router_tab";
-import NotificationManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { handleAddAutoRouterSubmit } from "./handle_add_auto_router_submit";
import { getMissingTiersError } from "./build_complexity_router_config";
import { testAutoRouterRouting } from "../networking";
@@ -69,10 +69,6 @@ vi.mock("./handle_add_auto_router_submit", () => ({
handleAddAutoRouterSubmit: vi.fn(),
}));
-vi.mock("../molecules/notifications_manager", () => ({
- default: { fromBackend: vi.fn() },
-}));
-
// Kept real by default so the "mandatory field" test still sees genuine tier validation; one
// test overrides it to reach the submit path without driving four tier selects.
vi.mock("./build_complexity_router_config", async (importOriginal) => {
@@ -137,7 +133,7 @@ describe("AddAutoRouterTab", () => {
await user.click(screen.getByRole("button", { name: /add auto router/i }));
expect(await screen.findByText("Auto router name is required")).toBeInTheDocument();
- expect(NotificationManager.fromBackend).toHaveBeenCalledWith("Please enter an Auto Router Name");
+ expect(toast.fromError).toHaveBeenCalledWith("Please enter an Auto Router Name");
});
it("offers no team selector to a proxy admin, who may create an unscoped router", () => {
@@ -596,9 +592,7 @@ describe("AddAutoRouterTab", () => {
fireEvent.submit(container.querySelector("form")!);
- await waitFor(() =>
- expect(NotificationManager.fromBackend).toHaveBeenCalledWith(expect.stringContaining("no longer available")),
- );
+ await waitFor(() => expect(toast.fromError).toHaveBeenCalledWith(expect.stringContaining("no longer available")));
expect(handleAddAutoRouterSubmit).not.toHaveBeenCalled();
});
});
@@ -666,9 +660,7 @@ describe("AddAutoRouterTab", () => {
fireEvent.submit(container.querySelector("form")!);
- await waitFor(() =>
- expect(NotificationManager.fromBackend).toHaveBeenCalledWith(expect.stringContaining(PINNED_MODEL)),
- );
+ await waitFor(() => expect(toast.fromError).toHaveBeenCalledWith(expect.stringContaining(PINNED_MODEL)));
expect(handleAddAutoRouterSubmit).not.toHaveBeenCalled();
});
});
diff --git a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx
index 2abd4097bdf..126f80b58fd 100644
--- a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx
@@ -33,7 +33,7 @@ import { resolveComplexityDefaultModel } from "./complexity_router_tiers";
import { buildAutoRouterTestTargets, AutoRouterTestTarget } from "./build_auto_router_test_targets";
import AutoRouterConnectionTest from "./auto_router_connection_test";
import AutoRouterRoutingTest from "./AutoRouterRoutingTest";
-import NotificationManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
getAllPresets,
getPresetByKey,
@@ -314,34 +314,34 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({
const missingTiersError = getMissingTiersError(tiers);
if (missingTiersError) {
setShowValidationErrors(true);
- NotificationManager.fromBackend(missingTiersError);
+ toast.fromError(missingTiersError);
return;
}
const tierLabelsError = getTierLabelsError(tierLabels);
if (tierLabelsError) {
setShowValidationErrors(true);
- NotificationManager.fromBackend(tierLabelsError);
+ toast.fromError(tierLabelsError);
return;
}
if (classifierType === "llm" && !classifierLlmConfig?.model) {
setShowValidationErrors(true);
- NotificationManager.fromBackend("Please select a classifier model, or switch back to Heuristic");
+ toast.fromError("Please select a classifier model, or switch back to Heuristic");
return;
}
const keywordRulesError = getKeywordTierRulesError(keywordTierRules);
if (keywordRulesError) {
setShowValidationErrors(true);
- NotificationManager.fromBackend(keywordRulesError);
+ toast.fromError(keywordRulesError);
return;
}
const semanticError = getSemanticConfigError({ semanticMatchingEnabled, embeddingModel, keywordTierRules });
if (semanticError) {
setShowValidationErrors(true);
- NotificationManager.fromBackend(semanticError);
+ toast.fromError(semanticError);
return;
}
@@ -352,7 +352,7 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({
const referencedModelsError = getReferencedModelsError(referencedModelsParams, groupsOnlyAvailability);
if (referencedModelsError) {
setShowValidationErrors(true);
- NotificationManager.fromBackend(referencedModelsError);
+ toast.fromError(referencedModelsError);
return;
}
@@ -385,7 +385,7 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({
})
.catch((error) => {
console.error("Validation failed:", error);
- NotificationManager.fromBackend("Please fill in all required fields");
+ toast.fromError("Please fill in all required fields");
});
};
@@ -394,7 +394,7 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({
if (!name) {
setShowValidationErrors(true);
form.validateFields(["auto_router_name"]).catch(() => undefined);
- NotificationManager.fromBackend("Please enter an Auto Router Name");
+ toast.fromError("Please enter an Auto Router Name");
return;
}
@@ -411,7 +411,7 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({
const targets = buildAutoRouterTestTargets(testTargetParams);
if (targets.length === 0) {
- NotificationManager.fromBackend("Please select at least one model for a complexity tier");
+ toast.fromError("Please select at least one model for a complexity tier");
return;
}
diff --git a/ui/litellm-dashboard/src/components/add_model/handle_add_auto_router_submit.tsx b/ui/litellm-dashboard/src/components/add_model/handle_add_auto_router_submit.tsx
index ef774d870b5..91df483ea03 100644
--- a/ui/litellm-dashboard/src/components/add_model/handle_add_auto_router_submit.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/handle_add_auto_router_submit.tsx
@@ -1,5 +1,5 @@
import { modelCreateCall, Model } from "../networking";
-import NotificationManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
export const handleAddAutoRouterSubmit = async (values: any, accessToken: string, form: any, callback?: () => void) => {
try {
@@ -42,7 +42,7 @@ export const handleAddAutoRouterSubmit = async (values: any, accessToken: string
await modelCreateCall(accessToken, autoRouterConfig as Model);
const routerTypeName = values.model_type === "complexity_router" ? "Auto Router" : "Semantic Router";
- NotificationManager.success(`Successfully created ${routerTypeName}: ${values.auto_router_name}`);
+ toast.success(`Successfully created ${routerTypeName}: ${values.auto_router_name}`);
form.resetFields();
@@ -51,6 +51,6 @@ export const handleAddAutoRouterSubmit = async (values: any, accessToken: string
}
} catch (error) {
console.error("Failed to add auto router:", error);
- NotificationManager.fromBackend("Failed to add auto router: " + error);
+ toast.fromError("Failed to add auto router: " + error);
}
};
diff --git a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.test.tsx b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.test.tsx
index c261e505684..7ef09d34924 100644
--- a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.test.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.test.tsx
@@ -1,12 +1,6 @@
-import { describe, expect, it, vi } from "vitest";
+import { describe, expect, it } from "vitest";
import { prepareModelAddRequest } from "./handle_add_model_submit";
-vi.mock("../molecules/notifications_manager", () => ({
- default: {
- fromBackend: vi.fn(),
- },
-}));
-
describe("prepareModelAddRequest", () => {
it("returns deployment data for the most basic form", async () => {
const formValues = {
diff --git a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx
index af5fe0931c8..bb2f78fa84e 100644
--- a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx
@@ -1,4 +1,4 @@
-import NotificationManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Model, modelCreateCall } from "../networking";
import { provider_map } from "../provider_info_helpers";
import { ptuPickerToUtcIso } from "../../utils/ptuDatetime";
@@ -128,7 +128,7 @@ export const prepareModelAddRequest = async (formValues: Record<string, any>, ac
delete litellmExtraParams.litellm_credential_name;
}
} catch (error) {
- NotificationManager.fromBackend("Failed to parse LiteLLM Extra Params: " + error);
+ toast.fromError("Failed to parse LiteLLM Extra Params: " + error);
throw new Error("Failed to parse litellm_extra_params: " + error);
}
for (const [key, value] of Object.entries(litellmExtraParams)) {
@@ -141,7 +141,7 @@ export const prepareModelAddRequest = async (formValues: Record<string, any>, ac
try {
modelInfoParams = JSON.parse(value);
} catch (error) {
- NotificationManager.fromBackend("Failed to parse LiteLLM Extra Params: " + error);
+ toast.fromError("Failed to parse LiteLLM Extra Params: " + error);
throw new Error("Failed to parse litellm_extra_params: " + error);
}
for (const [key, value] of Object.entries(modelInfoParams)) {
@@ -193,7 +193,7 @@ export const prepareModelAddRequest = async (formValues: Record<string, any>, ac
return deployments;
} catch (error) {
- NotificationManager.fromBackend("Failed to create model: " + error);
+ toast.fromError("Failed to create model: " + error);
}
};
@@ -221,6 +221,6 @@ export const handleAddModelSubmit = async (values: any, accessToken: string, for
callback && callback();
form.resetFields();
} catch (error) {
- NotificationManager.fromBackend("Failed to add model: " + error);
+ toast.fromError("Failed to add model: " + error);
}
};
diff --git a/ui/litellm-dashboard/src/components/add_model/model_connection_test.test.tsx b/ui/litellm-dashboard/src/components/add_model/model_connection_test.test.tsx
index 9c5527d7e74..c436a24474c 100644
--- a/ui/litellm-dashboard/src/components/add_model/model_connection_test.test.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/model_connection_test.test.tsx
@@ -1,16 +1,13 @@
import { act, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { testConnectionRequest } from "../networking";
import { prepareModelAddRequest } from "./handle_add_model_submit";
import ModelConnectionTest from "./model_connection_test";
vi.mock("../networking", () => ({ testConnectionRequest: vi.fn() }));
vi.mock("./handle_add_model_submit", () => ({ prepareModelAddRequest: vi.fn() }));
-vi.mock("../molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
const preparedRequest = [{ litellmParamsObj: { model: "openai/gpt-4o-mini" }, modelInfoObj: { mode: "chat" } }];
@@ -56,7 +53,7 @@ describe("ModelConnectionTest", () => {
"chat",
);
expect(screen.getByTestId("connection-success-msg")).toHaveTextContent("Connection to GPT-4o mini successful!");
- expect(NotificationsManager.success).toHaveBeenCalledWith("Connection test successful!");
+ expect(toast.success).toHaveBeenCalledWith("Connection test successful!");
expect(onTestComplete).toHaveBeenCalledTimes(1);
});
@@ -93,7 +90,7 @@ describe("ModelConnectionTest", () => {
fireEvent.click(screen.getByRole("button", { name: /Copy to Clipboard/ }));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining("https://api.example.test/v1/chat/completions"));
- expect(NotificationsManager.success).toHaveBeenCalledWith("Copied to clipboard");
+ expect(toast.success).toHaveBeenCalledWith("Copied to clipboard");
});
it("shows a preparation failure without sending a connection request", async () => {
diff --git a/ui/litellm-dashboard/src/components/add_model/model_connection_test.tsx b/ui/litellm-dashboard/src/components/add_model/model_connection_test.tsx
index 071890190d1..f6ef86a77ca 100644
--- a/ui/litellm-dashboard/src/components/add_model/model_connection_test.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/model_connection_test.tsx
@@ -4,7 +4,7 @@ import { AlertTriangle, CircleCheck, Copy, ExternalLink, Info, LoaderCircle } fr
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { testConnectionRequest } from "../networking";
import { prepareModelAddRequest } from "./handle_add_model_submit";
@@ -54,7 +54,7 @@ const ModelConnectionTest: React.FC<ModelConnectionTestProps> = ({
const response = await testConnectionRequest(accessToken, litellmParamsObj, modelInfoObj, modelInfoObj?.mode);
if (response.status === "success") {
- NotificationsManager.success("Connection test successful!");
+ toast.success("Connection test successful!");
setError(null);
setIsSuccess(true);
} else {
@@ -191,7 +191,7 @@ ${formattedBody}
className="mt-2"
onClick={() => {
navigator.clipboard.writeText(curlCommand || "");
- NotificationsManager.success("Copied to clipboard");
+ toast.success("Copied to clipboard");
}}
>
<Copy data-icon="inline-start" />
diff --git a/ui/litellm-dashboard/src/components/add_pass_through.tsx b/ui/litellm-dashboard/src/components/add_pass_through.tsx
index 0c9fbfb0347..8788c8ef8db 100644
--- a/ui/litellm-dashboard/src/components/add_pass_through.tsx
+++ b/ui/litellm-dashboard/src/components/add_pass_through.tsx
@@ -13,7 +13,7 @@ import KeyValueInput from "./key_value_input";
import QueryParamInput from "./query_param_input";
import { passThroughItem } from "./PassThroughSettings/PassThroughSettings";
import RoutePreview from "./route_preview";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import PassThroughSecuritySection from "./common_components/PassThroughSecuritySection";
import PassThroughGuardrailsSection from "./common_components/PassThroughGuardrailsSection";
const { Option } = Select2;
@@ -91,7 +91,7 @@ const AddPassThroughEndpoint: React.FC<AddFallbacksProps> = ({
const updatedPassThroughSettings = [...passThroughItems, createdEndpoint];
setPassThroughItems(updatedPassThroughSettings);
- NotificationsManager.success("Pass-through endpoint created successfully");
+ toast.success("Pass-through endpoint created successfully");
form.resetFields();
setPathValue("");
setTargetValue("");
@@ -100,7 +100,7 @@ const AddPassThroughEndpoint: React.FC<AddFallbacksProps> = ({
setGuardrails({});
setIsModalVisible(false);
} catch (error) {
- NotificationsManager.fromBackend("Error creating pass-through endpoint: " + error);
+ toast.fromError("Error creating pass-through endpoint: " + error);
} finally {
setIsLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/alerting/alerting_settings.tsx b/ui/litellm-dashboard/src/components/alerting/alerting_settings.tsx
index bd8b87bc89c..98e876801ac 100644
--- a/ui/litellm-dashboard/src/components/alerting/alerting_settings.tsx
+++ b/ui/litellm-dashboard/src/components/alerting/alerting_settings.tsx
@@ -5,7 +5,7 @@ import React, { useState, useEffect } from "react";
import { alertingSettingsCall, updateConfigFieldSetting } from "../networking";
import DynamicForm from "./dynamic_form";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface alertingSettingsItem {
field_name: string;
field_type: string;
@@ -73,7 +73,7 @@ const AlertingSettings: React.FC<AlertingSettingsProps> = ({ accessToken, premiu
}
}
// update value in state
- NotificationsManager.success("Wait 10s for proxy to update.");
+ toast.success("Wait 10s for proxy to update.");
} catch (error) {
// do something
}
diff --git a/ui/litellm-dashboard/src/components/bulk_create_users_button.test.tsx b/ui/litellm-dashboard/src/components/bulk_create_users_button.test.tsx
index fff03ed8e82..24685f9c129 100644
--- a/ui/litellm-dashboard/src/components/bulk_create_users_button.test.tsx
+++ b/ui/litellm-dashboard/src/components/bulk_create_users_button.test.tsx
@@ -14,13 +14,6 @@ vi.mock("./networking", () => ({
}),
}));
-vi.mock("./molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
const csvFile = () =>
new File(["user_email,user_role\[email protected],internal_user\n"], "users.csv", { type: "text/csv" });
diff --git a/ui/litellm-dashboard/src/components/bulk_create_users_button.tsx b/ui/litellm-dashboard/src/components/bulk_create_users_button.tsx
index faaf2cbf7a5..baaf58035a1 100644
--- a/ui/litellm-dashboard/src/components/bulk_create_users_button.tsx
+++ b/ui/litellm-dashboard/src/components/bulk_create_users_button.tsx
@@ -7,7 +7,7 @@ import { userCreateCall, invitationCreateCall, getProxyUISettings } from "./netw
import Papa from "papaparse";
import { CheckCircleIcon, XCircleIcon, ExclamationIcon } from "@heroicons/react/outline";
import { CopyToClipboard } from "react-copy-to-clipboard";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface BulkCreateUsersProps {
accessToken: string;
@@ -91,7 +91,7 @@ const BulkCreateUsersButton: React.FC<BulkCreateUsersProps> = ({
// Check file type
if (file.type !== "text/csv" && !file.name.endsWith(".csv")) {
setFileError(`Invalid file type: ${file.name}. Please upload a CSV file (.csv extension).`);
- NotificationsManager.fromBackend("Invalid file type. Please upload a CSV file.");
+ toast.fromError("Invalid file type. Please upload a CSV file.");
return;
}
@@ -247,7 +247,7 @@ const BulkCreateUsersButton: React.FC<BulkCreateUsersProps> = ({
`Found ${userData.length - validData.length} row(s) with errors out of ${userData.length} total rows. Please correct them before proceeding.`,
);
} else {
- NotificationsManager.success(`Successfully parsed ${validData.length} users`);
+ toast.success(`Successfully parsed ${validData.length} users`);
}
} catch (error: unknown) {
const errorMessage = error instanceof Error ? error.message : "Unknown error";
@@ -485,10 +485,7 @@ const BulkCreateUsersButton: React.FC<BulkCreateUsersProps> = ({
<div className="mt-1">
<div className="flex items-center">
<span className="text-xs text-gray-500 truncate max-w-[150px]">{record.invitation_link}</span>
- <CopyToClipboard
- text={record.invitation_link}
- onCopy={() => NotificationsManager.success("Invitation link copied!")}
- >
+ <CopyToClipboard text={record.invitation_link} onCopy={() => toast.success("Invitation link copied!")}>
<button className="ml-1 text-blue-500 text-xs hover:text-blue-700">Copy</button>
</CopyToClipboard>
</div>
diff --git a/ui/litellm-dashboard/src/components/chat/KeysPanel.tsx b/ui/litellm-dashboard/src/components/chat/KeysPanel.tsx
index 1935c0f226a..ea092e5af14 100644
--- a/ui/litellm-dashboard/src/components/chat/KeysPanel.tsx
+++ b/ui/litellm-dashboard/src/components/chat/KeysPanel.tsx
@@ -11,7 +11,7 @@ import { Badge } from "@/components/ui/badge";
import { Skeleton } from "@/components/ui/skeleton";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { keyListCall, regenerateKeyCall } from "../networking";
import { KeyResponse } from "../key_team_helpers/key_list";
import { formatExpiresUtc, isKeyExpired, calculateExpiryPreviewFromDuration } from "@/utils/keyExpiryUtils";
@@ -132,10 +132,10 @@ const KeysPanel: React.FC<Props> = ({ accessToken, userId, premiumUser }) => {
const response = await regenerateKeyCall(accessToken, rotateTarget.token || rotateTarget.token_id, payload);
setRegeneratedKey(response.key);
- MessageManager.success("Key rotated successfully");
+ toast.success("Key rotated successfully");
queryClient.invalidateQueries({ queryKey: [KEYS_QUERY_KEY] });
} catch {
- MessageManager.error("Failed to rotate key");
+ toast.error("Failed to rotate key");
} finally {
setIsRegenerating(false);
}
diff --git a/ui/litellm-dashboard/src/components/chat/MCPAppsPanel.tsx b/ui/litellm-dashboard/src/components/chat/MCPAppsPanel.tsx
index 7dbfc058a77..52c067a0732 100644
--- a/ui/litellm-dashboard/src/components/chat/MCPAppsPanel.tsx
+++ b/ui/litellm-dashboard/src/components/chat/MCPAppsPanel.tsx
@@ -15,7 +15,7 @@ import {
} from "../networking";
import { AUTH_TYPE, MCPServer, MCPTool, handleTransport, isUnsupportedOnGatewayConnect } from "../mcp_tools/types";
import { Logo } from "@/components/molecules/logo/Logo";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { useUserMcpOAuthFlow } from "@/hooks/useUserMcpOAuthFlow";
interface OAuth2ConnectButtonProps {
@@ -249,7 +249,7 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange,
try {
const result = await listMCPTools(accessToken, server.server_id);
if (result?.error) {
- MessageManager.warning(`Could not load tools for ${serverName}`);
+ toast.warning(`Could not load tools for ${serverName}`);
return;
}
if (connectableNow(server.server_id) === undefined) return;
@@ -257,7 +257,7 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange,
onChange([...selectedServersRef.current, serverName]);
}
} catch {
- MessageManager.warning(`Could not load tools for ${serverName}`);
+ toast.warning(`Could not load tools for ${serverName}`);
} finally {
setTogglingOn((prev) => {
const next = new Set(prev);
diff --git a/ui/litellm-dashboard/src/components/chat/MCPConnectPicker.tsx b/ui/litellm-dashboard/src/components/chat/MCPConnectPicker.tsx
index a353457946c..41c9327591a 100644
--- a/ui/litellm-dashboard/src/components/chat/MCPConnectPicker.tsx
+++ b/ui/litellm-dashboard/src/components/chat/MCPConnectPicker.tsx
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
import { Loader2 } from "lucide-react";
import { Switch } from "@/components/ui/switch";
import { Skeleton } from "@/components/ui/skeleton";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { Logo } from "@/components/molecules/logo/Logo";
import { fetchMCPServers, listMCPTools } from "../networking";
import { MCPServer } from "../mcp_tools/types";
@@ -56,12 +56,12 @@ const MCPConnectPicker: React.FC<Props> = ({ accessToken, selectedServers, onCha
try {
const result = await listMCPTools(accessToken, serverName);
if (result?.error) {
- MessageManager.warning(`Could not load tools for ${serverName} \u2014 it will be excluded from this message.`);
+ toast.warning(`Could not load tools for ${serverName} \u2014 it will be excluded from this message.`);
return;
}
onChange([...selectedServers, serverName]);
} catch {
- MessageManager.warning(`Could not load tools for ${serverName} \u2014 it will be excluded from this message.`);
+ toast.warning(`Could not load tools for ${serverName} \u2014 it will be excluded from this message.`);
} finally {
setTogglingOn((prev) => {
const next = new Set(prev);
diff --git a/ui/litellm-dashboard/src/components/chat/MCPCredentialsTab.tsx b/ui/litellm-dashboard/src/components/chat/MCPCredentialsTab.tsx
index 4f80a941511..33c153b3474 100644
--- a/ui/litellm-dashboard/src/components/chat/MCPCredentialsTab.tsx
+++ b/ui/litellm-dashboard/src/components/chat/MCPCredentialsTab.tsx
@@ -18,7 +18,7 @@ import {
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { deleteMCPOAuthUserCredential, listMCPUserCredentials, MCPUserCredentialListItem } from "../networking";
const MCP_CREDENTIALS_QUERY_KEY = "mcp-user-credentials";
@@ -83,7 +83,7 @@ const MCPCredentialsTab: React.FC<Props> = ({ accessToken }) => {
(prev ?? []).filter((c) => c.server_id !== serverId),
);
} catch {
- MessageManager.error("Failed to revoke connection. Please try again.");
+ toast.error("Failed to revoke connection. Please try again.");
} finally {
setRevoking((prev) => {
const n = new Set(prev);
diff --git a/ui/litellm-dashboard/src/components/claude_code_plugins/MakeSkillPublicForm.tsx b/ui/litellm-dashboard/src/components/claude_code_plugins/MakeSkillPublicForm.tsx
index 58dc62ee6b2..9d921041d92 100644
--- a/ui/litellm-dashboard/src/components/claude_code_plugins/MakeSkillPublicForm.tsx
+++ b/ui/litellm-dashboard/src/components/claude_code_plugins/MakeSkillPublicForm.tsx
@@ -6,7 +6,7 @@ import { Checkbox } from "@/components/ui/checkbox";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { cn } from "@/lib/cva.config";
import { enableClaudeCodePlugin, disableClaudeCodePlugin } from "../networking";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { Plugin } from "./types";
const STEP_TITLES = ["Select Skills", "Confirm"];
@@ -38,7 +38,7 @@ const MakeSkillPublicForm: React.FC<MakeSkillPublicFormProps> = ({
const handleNext = () => {
if (selectedSkills.size === 0) {
- NotificationsManager.fromBackend("Please select at least one skill");
+ toast.fromError("Please select at least one skill");
return;
}
setCurrentStep(1);
@@ -71,7 +71,7 @@ const MakeSkillPublicForm: React.FC<MakeSkillPublicFormProps> = ({
const handleSubmit = async () => {
if (selectedSkills.size === 0) {
- NotificationsManager.fromBackend("Please select at least one skill");
+ toast.fromError("Please select at least one skill");
return;
}
@@ -91,12 +91,12 @@ const MakeSkillPublicForm: React.FC<MakeSkillPublicFormProps> = ({
}),
);
- NotificationsManager.success(`Skill Hub updated — ${selectedSkills.size} skill(s) published`);
+ toast.success(`Skill Hub updated — ${selectedSkills.size} skill(s) published`);
handleClose();
onSuccess();
} catch (error) {
console.error("Error publishing skills:", error);
- NotificationsManager.fromBackend("Failed to update skills. Please try again.");
+ toast.fromError("Failed to update skills. Please try again.");
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/cloudzero_export_modal.tsx b/ui/litellm-dashboard/src/components/cloudzero_export_modal.tsx
index 6a3d5ded452..2aaad786e91 100644
--- a/ui/litellm-dashboard/src/components/cloudzero_export_modal.tsx
+++ b/ui/litellm-dashboard/src/components/cloudzero_export_modal.tsx
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
import { Text, Button, Callout, TextInput } from "@tremor/react";
import { Modal, Form, Spin, Select } from "antd";
import { getGlobalLitellmHeaderName } from "@/components/networking";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface CloudZeroExportModalProps {
isOpen: boolean;
@@ -59,11 +59,11 @@ const CloudZeroExportModal: React.FC<CloudZeroExportModalProps> = ({ isOpen, onC
} else if (response.status !== 404) {
// 404 means no settings configured yet, which is fine
const errorData = await response.json();
- NotificationsManager.fromBackend(`Failed to load existing settings: ${errorData.error || "Unknown error"}`);
+ toast.fromError(`Failed to load existing settings: ${errorData.error || "Unknown error"}`);
}
} catch (error) {
console.error("Error loading CloudZero settings:", error);
- NotificationsManager.fromBackend("Failed to load existing settings");
+ toast.fromError("Failed to load existing settings");
} finally {
setSettingsLoading(false);
}
@@ -71,7 +71,7 @@ const CloudZeroExportModal: React.FC<CloudZeroExportModalProps> = ({ isOpen, onC
const handleSaveCloudZeroSettings = async (values: CloudZeroSettings) => {
if (!accessToken) {
- NotificationsManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
@@ -98,7 +98,7 @@ const CloudZeroExportModal: React.FC<CloudZeroExportModalProps> = ({ isOpen, onC
const data = await response.json();
if (response.ok) {
- NotificationsManager.success(data.message || "CloudZero settings saved successfully");
+ toast.success(data.message || "CloudZero settings saved successfully");
setExistingSettings({
api_key_masked: values.api_key.substring(0, 4) + "****" + values.api_key.slice(-4),
connection_id: values.connection_id,
@@ -106,12 +106,12 @@ const CloudZeroExportModal: React.FC<CloudZeroExportModalProps> = ({ isOpen, onC
});
return true;
} else {
- NotificationsManager.fromBackend(data.error || "Failed to save CloudZero settings");
+ toast.fromError(data.error || "Failed to save CloudZero settings");
return false;
}
} catch (error) {
console.error("Error saving CloudZero settings:", error);
- NotificationsManager.fromBackend("Failed to save CloudZero settings");
+ toast.fromError("Failed to save CloudZero settings");
return false;
} finally {
setLoading(false);
@@ -120,7 +120,7 @@ const CloudZeroExportModal: React.FC<CloudZeroExportModalProps> = ({ isOpen, onC
const handleExportCloudZero = async () => {
if (!accessToken) {
- NotificationsManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
@@ -141,14 +141,14 @@ const CloudZeroExportModal: React.FC<CloudZeroExportModalProps> = ({ isOpen, onC
const data = await response.json();
if (response.ok) {
- NotificationsManager.success(data.message || "Export to CloudZero completed successfully");
+ toast.success(data.message || "Export to CloudZero completed successfully");
onClose();
} else {
- NotificationsManager.fromBackend(data.error || "Failed to export to CloudZero");
+ toast.fromError(data.error || "Failed to export to CloudZero");
}
} catch (error) {
console.error("Error exporting to CloudZero:", error);
- NotificationsManager.fromBackend("Failed to export to CloudZero");
+ toast.fromError("Failed to export to CloudZero");
} finally {
setExportLoading(false);
}
@@ -158,11 +158,11 @@ const CloudZeroExportModal: React.FC<CloudZeroExportModalProps> = ({ isOpen, onC
setExportLoading(true);
try {
// TODO: Implement CSV export functionality
- NotificationsManager.info("CSV export functionality coming soon!");
+ toast.info("CSV export functionality coming soon!");
onClose();
} catch (error) {
console.error("Error exporting CSV:", error);
- NotificationsManager.fromBackend("Failed to export CSV");
+ toast.fromError("Failed to export CSV");
} finally {
setExportLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/common_components/ModelAliasManager.tsx b/ui/litellm-dashboard/src/components/common_components/ModelAliasManager.tsx
index 9b89d85507b..2aecedb8a6e 100644
--- a/ui/litellm-dashboard/src/components/common_components/ModelAliasManager.tsx
+++ b/ui/litellm-dashboard/src/components/common_components/ModelAliasManager.tsx
@@ -3,7 +3,7 @@ import { PlusCircleIcon, PencilIcon, TrashIcon } from "@heroicons/react/outline"
import { Card, CardTitle } from "@/components/ui/card";
import { Table, TableHeader, TableHead, TableBody, TableRow, TableCell } from "@/components/ui/table";
import ModelSelector from "./ModelSelector";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
interface ModelAliasManagerProps {
accessToken: string;
@@ -40,13 +40,13 @@ const ModelAliasManager: React.FC<ModelAliasManagerProps> = ({
const handleAddAlias = () => {
if (!newAlias.aliasName || !newAlias.targetModel) {
- NotificationsManager.fromBackend("Please provide both alias name and target model");
+ toast.fromError("Please provide both alias name and target model");
return;
}
// Check for duplicate alias names
if (aliases.some((alias) => alias.aliasName === newAlias.aliasName)) {
- NotificationsManager.fromBackend("An alias with this name already exists");
+ toast.fromError("An alias with this name already exists");
return;
}
@@ -70,7 +70,7 @@ const ModelAliasManager: React.FC<ModelAliasManagerProps> = ({
onAliasUpdate(aliasObject);
}
- NotificationsManager.success("Alias added successfully");
+ toast.success("Alias added successfully");
};
const handleEditAlias = (alias: AliasItem) => {
@@ -81,13 +81,13 @@ const ModelAliasManager: React.FC<ModelAliasManagerProps> = ({
if (!editingAlias) return;
if (!editingAlias.aliasName || !editingAlias.targetModel) {
- NotificationsManager.fromBackend("Please provide both alias name and target model");
+ toast.fromError("Please provide both alias name and target model");
return;
}
// Check for duplicate alias names (excluding current alias)
if (aliases.some((alias) => alias.id !== editingAlias.id && alias.aliasName === editingAlias.aliasName)) {
- NotificationsManager.fromBackend("An alias with this name already exists");
+ toast.fromError("An alias with this name already exists");
return;
}
@@ -106,7 +106,7 @@ const ModelAliasManager: React.FC<ModelAliasManagerProps> = ({
onAliasUpdate(aliasObject);
}
- NotificationsManager.success("Alias updated successfully");
+ toast.success("Alias updated successfully");
};
const handleCancelEdit = () => {
@@ -127,7 +127,7 @@ const ModelAliasManager: React.FC<ModelAliasManagerProps> = ({
onAliasUpdate(aliasObject);
}
- NotificationsManager.success("Alias deleted successfully");
+ toast.success("Alias deleted successfully");
};
// Convert current aliases to object for config example
diff --git a/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.test.tsx b/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.test.tsx
index da36063e68a..019f60aecd9 100644
--- a/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.test.tsx
+++ b/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.test.tsx
@@ -3,7 +3,7 @@ import { describe, expect, it, vi } from "vitest";
import { fireEvent, renderWithProviders, screen, waitFor, within } from "@/../tests/test-utils";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import EditAutoRouterModal from "./edit_auto_router_modal";
vi.mock(
"@/app/(dashboard)/hooks/autoRouter/useComplexityScorerDefaults",
@@ -130,7 +130,7 @@ describe("EditAutoRouterModal keyword matching", () => {
await screen.findByText(/Escalation Keywords/i);
await user.click(screen.getByRole("button", { name: /save changes/i }));
- await waitFor(() => expect(NotificationsManager.fromBackend).toHaveBeenCalled());
+ await waitFor(() => expect(toast.fromError).toHaveBeenCalled());
expect(modelPatchUpdateCall).not.toHaveBeenCalled();
});
@@ -731,9 +731,7 @@ describe("EditAutoRouterModal default model", () => {
await user.click(await screen.findByRole("button", { name: /save changes/i }));
- await waitFor(() =>
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith(expect.stringContaining("Simple or Medium tier")),
- );
+ await waitFor(() => expect(toast.fromError).toHaveBeenCalledWith(expect.stringContaining("Simple or Medium tier")));
expect(modelPatchUpdateCall).not.toHaveBeenCalled();
});
diff --git a/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsx b/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsx
index 32521a3e043..cd4ecee1dc8 100644
--- a/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsx
+++ b/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsx
@@ -31,7 +31,7 @@ import ComplexityRouterConfig, {
DEFAULT_TIER_DISTANCE_PENALTY,
heuristicScoringRole,
} from "../add_model/ComplexityRouterConfig";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
Dialog,
DialogContent,
@@ -367,7 +367,7 @@ const EditAutoRouterModal: React.FC<EditAutoRouterModalProps> = ({
});
} catch (error) {
console.error("Error parsing auto router config:", error);
- NotificationsManager.fromBackend("Error loading auto router configuration");
+ toast.fromError("Error loading auto router configuration");
}
};
@@ -380,12 +380,12 @@ const EditAutoRouterModal: React.FC<EditAutoRouterModalProps> = ({
const { tiers, classifier_type, classifier_llm_config } = complexityRouterConfig;
if (Object.values(tiers).every((models) => models.length === 0)) {
setShowValidationErrors(true);
- NotificationsManager.fromBackend("Please select at least one model for a complexity tier");
+ toast.fromError("Please select at least one model for a complexity tier");
return;
}
if (classifier_type === "llm" && !classifier_llm_config?.model) {
setShowValidationErrors(true);
- NotificationsManager.fromBackend("Please select a classifier model, or switch back to Heuristic");
+ toast.fromError("Please select a classifier model, or switch back to Heuristic");
return;
}
// Same guards the create form applies (add_auto_router_tab.tsx). The backend rejects a
@@ -395,14 +395,14 @@ const EditAutoRouterModal: React.FC<EditAutoRouterModalProps> = ({
const keywordRulesError = getKeywordTierRulesError(keywordTierRules);
if (keywordRulesError) {
setShowValidationErrors(true);
- NotificationsManager.fromBackend(keywordRulesError);
+ toast.fromError(keywordRulesError);
return;
}
const semanticError = getSemanticConfigError({ semanticMatchingEnabled, embeddingModel, keywordTierRules });
if (semanticError) {
setShowValidationErrors(true);
- NotificationsManager.fromBackend(semanticError);
+ toast.fromError(semanticError);
return;
}
@@ -414,7 +414,7 @@ const EditAutoRouterModal: React.FC<EditAutoRouterModalProps> = ({
const defaultModel = resolveComplexityDefaultModel(tiers, complexityRouterConfig.default_model);
if (!defaultModel) {
setShowValidationErrors(true);
- NotificationsManager.fromBackend(
+ toast.fromError(
"Add a model to the Simple or Medium tier, or pin a default model, so requests have somewhere to route.",
);
return;
@@ -450,7 +450,7 @@ const EditAutoRouterModal: React.FC<EditAutoRouterModalProps> = ({
modelData.model_info.id,
);
- NotificationsManager.success("Auto router configuration updated successfully");
+ toast.success("Auto router configuration updated successfully");
onSuccess({
...modelData,
model_name: values.auto_router_name,
@@ -490,12 +490,12 @@ const EditAutoRouterModal: React.FC<EditAutoRouterModalProps> = ({
model_info: updatedModelInfo,
};
- NotificationsManager.success("Auto router configuration updated successfully");
+ toast.success("Auto router configuration updated successfully");
onSuccess(updatedModelData);
onCancel();
} catch (error) {
console.error("Error updating auto router:", error);
- NotificationsManager.fromBackend("Failed to update auto router configuration");
+ toast.fromError("Failed to update auto router configuration");
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/email_events/email_event_settings.tsx b/ui/litellm-dashboard/src/components/email_events/email_event_settings.tsx
index 63ff4f6f725..5d063118b0b 100644
--- a/ui/litellm-dashboard/src/components/email_events/email_event_settings.tsx
+++ b/ui/litellm-dashboard/src/components/email_events/email_event_settings.tsx
@@ -4,7 +4,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getEmailEventSettings, updateEmailEventSettings, resetEmailEventSettings } from "../networking";
import { EmailEvent } from "../../types";
import { EmailEventSetting } from "./types";
@@ -31,7 +31,7 @@ const EmailEventSettings: React.FC<EmailEventSettingsProps> = ({ accessToken })
setEventSettings(response.settings);
} catch (error) {
console.error("Failed to fetch email event settings:", error);
- NotificationsManager.fromBackend(error);
+ toast.fromError(error);
} finally {
setLoading(false);
}
@@ -49,10 +49,10 @@ const EmailEventSettings: React.FC<EmailEventSettingsProps> = ({ accessToken })
try {
await updateEmailEventSettings(accessToken, { settings: eventSettings });
- NotificationsManager.success("Email event settings updated successfully");
+ toast.success("Email event settings updated successfully");
} catch (error) {
console.error("Failed to update email event settings:", error);
- NotificationsManager.fromBackend(error);
+ toast.fromError(error);
}
};
@@ -61,12 +61,12 @@ const EmailEventSettings: React.FC<EmailEventSettingsProps> = ({ accessToken })
try {
await resetEmailEventSettings(accessToken);
- NotificationsManager.success("Email event settings reset to defaults");
+ toast.success("Email event settings reset to defaults");
// Refresh settings after reset
fetchEventSettings();
} catch (error) {
console.error("Failed to reset email event settings:", error);
- NotificationsManager.fromBackend(error);
+ toast.fromError(error);
}
};
diff --git a/ui/litellm-dashboard/src/components/email_settings.tsx b/ui/litellm-dashboard/src/components/email_settings.tsx
index 6f1c3b1f846..65fae5a2012 100644
--- a/ui/litellm-dashboard/src/components/email_settings.tsx
+++ b/ui/litellm-dashboard/src/components/email_settings.tsx
@@ -3,7 +3,7 @@ import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "@/components/ui/input-group";
import { Eye, EyeOff } from "lucide-react";
-import NotificationManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { serviceHealthCheck, setCallbacksCall } from "./networking";
import { EmailEventSettings } from "./email_events";
@@ -78,9 +78,9 @@ const EmailSettings: React.FC<EmailSettingsProps> = ({ accessToken, premiumUser,
};
try {
await setCallbacksCall(accessToken, payload);
- NotificationManager.success("Email settings updated successfully");
+ toast.success("Email settings updated successfully");
} catch (error) {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
}
};
@@ -161,9 +161,9 @@ const EmailSettings: React.FC<EmailSettingsProps> = ({ accessToken, premiumUser,
if (!accessToken) return;
try {
await serviceHealthCheck(accessToken, "email");
- NotificationManager.success("Email test triggered. Check your configured email inbox/logs.");
+ toast.success("Email test triggered. Check your configured email inbox/logs.");
} catch (error) {
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
}
}}
>
diff --git a/ui/litellm-dashboard/src/components/llm_calls/responses_api.tsx b/ui/litellm-dashboard/src/components/llm_calls/responses_api.tsx
index 775ccee9bee..94e8cb46765 100644
--- a/ui/litellm-dashboard/src/components/llm_calls/responses_api.tsx
+++ b/ui/litellm-dashboard/src/components/llm_calls/responses_api.tsx
@@ -2,7 +2,7 @@ import openai from "openai";
import { MessageType } from "../chat_ui/types";
import { TokenUsage } from "../chat_ui/ResponseMetrics";
import { getProxyBaseUrl } from "@/components/networking";
-import NotificationManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { extractPromptCacheTokens } from "@/utils/promptCacheUsage";
import type { MCPEvent } from "@/components/mcp_tools/types";
import { MCPServer, MCPToolset } from "@/components/mcp_tools/types";
@@ -317,9 +317,7 @@ export async function makeOpenAIResponsesRequest(
} catch (error) {
if (signal?.aborted) {
} else {
- NotificationManager.fromBackend(
- `Error occurred while generating model response. Please try again. Error: ${error}`,
- );
+ toast.fromError(`Error occurred while generating model response. Please try again. Error: ${error}`);
}
throw error; // Re-throw to allow the caller to handle the error
}
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/ByokCredentialModal.test.tsx b/ui/litellm-dashboard/src/components/mcp_tools/ByokCredentialModal.test.tsx
index 021aec5f85f..f23d06e492c 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/ByokCredentialModal.test.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/ByokCredentialModal.test.tsx
@@ -3,6 +3,7 @@ import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { registerAuthHeaderNameGetter, registerAuthTokenGetter, registerBaseUrlGetter } from "@/lib/http/runtime";
+import { toast } from "@/lib/toast";
import { ByokCredentialModal } from "./ByokCredentialModal";
import type { MCPServer } from "./types";
@@ -12,10 +13,6 @@ const fetchSpy = vi.hoisted(() => {
return spy;
});
-vi.mock("@/components/molecules/message_manager", () => ({
- default: { success: vi.fn(), error: vi.fn() },
-}));
-
const SERVER = { server_id: "srv-1", alias: "Linear", server_name: "Linear" } as MCPServer;
const jsonResponse = (body: unknown, status = 200) =>
@@ -57,16 +54,13 @@ describe("ByokCredentialModal", () => {
fetchSpy.mockResolvedValue(
jsonResponse({ detail: { error: "This MCP server does not support BYOK credentials" } }, 400),
);
- const MessageManager = (await import("@/components/molecules/message_manager")).default;
const onSuccess = vi.fn();
const user = userEvent.setup();
render(<ByokCredentialModal server={SERVER} open onClose={() => {}} onSuccess={onSuccess} />);
await fillAndSubmit(user);
- await waitFor(() =>
- expect(MessageManager.error).toHaveBeenCalledWith("This MCP server does not support BYOK credentials"),
- );
+ await waitFor(() => expect(toast.error).toHaveBeenCalledWith("This MCP server does not support BYOK credentials"));
expect(onSuccess).not.toHaveBeenCalled();
});
});
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/ByokCredentialModal.tsx b/ui/litellm-dashboard/src/components/mcp_tools/ByokCredentialModal.tsx
index f36de019aa5..9fe306de0e8 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/ByokCredentialModal.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/ByokCredentialModal.tsx
@@ -2,7 +2,7 @@
import React, { useState } from "react";
import { Modal, Input, Switch } from "antd";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { fetchClient } from "@/lib/http/api";
import { ApiError } from "@/lib/http/client";
import {
@@ -50,7 +50,7 @@ export const ByokCredentialModal: React.FC<ByokCredentialModalProps> = ({ server
const handleAuthorize = async () => {
if (!apiKey.trim()) {
- MessageManager.error("Please enter your API key");
+ toast.error("Please enter your API key");
return;
}
setLoading(true);
@@ -59,11 +59,11 @@ export const ByokCredentialModal: React.FC<ByokCredentialModalProps> = ({ server
params: { path: { server_id: server.server_id } },
body: { credential: apiKey.trim(), save: saveKey },
});
- MessageManager.success(`Connected to ${serverDisplayName}`);
+ toast.success(`Connected to ${serverDisplayName}`);
onSuccess(server.server_id);
handleClose();
} catch (e) {
- MessageManager.error(byokSaveErrorMessage(e));
+ toast.error(byokSaveErrorMessage(e));
} finally {
setLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/model_add/CredentialsPanel.test.tsx b/ui/litellm-dashboard/src/components/model_add/CredentialsPanel.test.tsx
index 19f6d883930..8121f7c230f 100644
--- a/ui/litellm-dashboard/src/components/model_add/CredentialsPanel.test.tsx
+++ b/ui/litellm-dashboard/src/components/model_add/CredentialsPanel.test.tsx
@@ -5,7 +5,7 @@ import type { ComponentProps } from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { CredentialItem, credentialCreateCall, credentialUpdateCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import CredentialsPanel from "./CredentialsPanel";
@@ -22,10 +22,6 @@ vi.mock("@/app/(dashboard)/hooks/credentials/useCredentials", () => ({
useCredentials: () => mockUseCredentials(),
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), error: vi.fn(), fromBackend: vi.fn() },
-}));
-
vi.mock("@/components/networking", async (importOriginal) => {
const actual = await importOriginal<typeof import("@/components/networking")>();
return {
@@ -160,7 +156,7 @@ describe("CredentialsPanel", () => {
await user.click(screen.getByTestId("credential-modal-add-submit"));
await waitFor(() => {
- expect(NotificationsManager.success).toHaveBeenCalledWith("Credential added successfully");
+ expect(toast.success).toHaveBeenCalledWith("Credential added successfully");
});
expect(refetch).toHaveBeenCalled();
expect(screen.queryByTestId("credential-modal-add-submit")).not.toBeInTheDocument();
@@ -178,11 +174,11 @@ describe("CredentialsPanel", () => {
await user.click(screen.getByTestId("credential-modal-add-submit"));
await waitFor(() => {
- expect(NotificationsManager.error).toHaveBeenCalledWith("Failed to add credential");
+ expect(toast.error).toHaveBeenCalledWith("Failed to add credential");
});
// The modal stays open so the user can retry, and no success toast fired.
expect(screen.getByTestId("credential-modal-add-submit")).toBeInTheDocument();
- expect(NotificationsManager.success).not.toHaveBeenCalled();
+ expect(toast.success).not.toHaveBeenCalled();
});
it("drops the masked api key from the update payload while keeping the edited api base", async () => {
diff --git a/ui/litellm-dashboard/src/components/model_add/CredentialsPanel.tsx b/ui/litellm-dashboard/src/components/model_add/CredentialsPanel.tsx
index d6109ea7655..bccf546e7e4 100644
--- a/ui/litellm-dashboard/src/components/model_add/CredentialsPanel.tsx
+++ b/ui/litellm-dashboard/src/components/model_add/CredentialsPanel.tsx
@@ -16,7 +16,7 @@ import { stripMaskedSecrets } from "@/utils/maskedSecretUtils";
import { isProxyAdminRole } from "@/utils/roles";
import DeleteResourceModal from "../common_components/DeleteResourceModal";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import CredentialModal from "./CredentialModal";
import CredentialsTable from "./CredentialsTable";
@@ -58,11 +58,11 @@ export default function CredentialsPanel({ uploadProps }: CredentialsPanelProps)
try {
const newCredential = buildCredential(values, stripMaskedSecrets(withoutRestrictedFields(values)));
await credentialUpdateCall(accessToken, values.credential_name as string, newCredential);
- NotificationsManager.success("Credential updated successfully");
+ toast.success("Credential updated successfully");
setIsUpdateModalOpen(false);
await refetchCredentials();
} catch (error) {
- NotificationsManager.error("Failed to update credential");
+ toast.error("Failed to update credential");
}
};
@@ -73,11 +73,11 @@ export default function CredentialsPanel({ uploadProps }: CredentialsPanelProps)
try {
const newCredential = buildCredential(values, withoutRestrictedFields(values));
await credentialCreateCall(accessToken, newCredential);
- NotificationsManager.success("Credential added successfully");
+ toast.success("Credential added successfully");
setIsAddModalOpen(false);
await refetchCredentials();
} catch (error) {
- NotificationsManager.error("Failed to add credential");
+ toast.error("Failed to add credential");
}
};
@@ -88,10 +88,10 @@ export default function CredentialsPanel({ uploadProps }: CredentialsPanelProps)
setIsCredentialDeleting(true);
try {
await credentialDeleteCall(accessToken, credentialToDelete.credential_name);
- NotificationsManager.success("Credential deleted successfully");
+ toast.success("Credential deleted successfully");
await refetchCredentials();
} catch (error) {
- NotificationsManager.error("Failed to delete credential");
+ toast.error("Failed to delete credential");
} finally {
setCredentialToDelete(null);
setIsDeleteModalOpen(false);
diff --git a/ui/litellm-dashboard/src/components/model_dashboard/ModelSettingsModal/ModelSettingsModal.test.tsx b/ui/litellm-dashboard/src/components/model_dashboard/ModelSettingsModal/ModelSettingsModal.test.tsx
index a1b5de3d0ea..fb6624ed92d 100644
--- a/ui/litellm-dashboard/src/components/model_dashboard/ModelSettingsModal/ModelSettingsModal.test.tsx
+++ b/ui/litellm-dashboard/src/components/model_dashboard/ModelSettingsModal/ModelSettingsModal.test.tsx
@@ -1,6 +1,6 @@
import { useProxyConfig } from "@/app/(dashboard)/hooks/proxyConfig/useProxyConfig";
import { useStoreModelInDB } from "@/app/(dashboard)/hooks/storeModelInDB/useStoreModelInDB";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "@/components/shared/errorUtils";
import { screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
@@ -10,19 +10,13 @@ import ModelSettingsModal from "./ModelSettingsModal";
vi.mock("@/app/(dashboard)/hooks/storeModelInDB/useStoreModelInDB");
vi.mock("@/app/(dashboard)/hooks/proxyConfig/useProxyConfig");
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
vi.mock("@/components/shared/errorUtils", () => ({
parseErrorMessage: vi.fn(),
}));
const mockUseStoreModelInDB = vi.mocked(useStoreModelInDB);
const mockUseProxyConfig = vi.mocked(useProxyConfig);
-const mockNotificationsManager = vi.mocked(NotificationsManager);
+const mockToast = vi.mocked(toast);
const mockParseErrorMessage = vi.mocked(parseErrorMessage);
describe("ModelSettingsModal", () => {
@@ -155,7 +149,7 @@ describe("ModelSettingsModal", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Model storage settings updated successfully");
+ expect(mockToast.success).toHaveBeenCalledWith("Model storage settings updated successfully");
expect(mockRefetch).toHaveBeenCalled();
expect(mockOnSuccess).toHaveBeenCalledTimes(1);
});
@@ -173,9 +167,7 @@ describe("ModelSettingsModal", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith(
- "Failed to save model storage settings: Network error",
- );
+ expect(mockToast.fromError).toHaveBeenCalledWith("Failed to save model storage settings: Network error");
});
});
@@ -194,9 +186,7 @@ describe("ModelSettingsModal", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith(
- "Failed to save model storage settings: Backend error",
- );
+ expect(mockToast.fromError).toHaveBeenCalledWith("Failed to save model storage settings: Backend error");
});
});
@@ -299,7 +289,7 @@ describe("ModelSettingsModal", () => {
await user.click(saveButton);
await waitFor(() => {
- expect(mockNotificationsManager.success).toHaveBeenCalled();
+ expect(mockToast.success).toHaveBeenCalled();
});
});
});
diff --git a/ui/litellm-dashboard/src/components/model_dashboard/ModelSettingsModal/ModelSettingsModal.tsx b/ui/litellm-dashboard/src/components/model_dashboard/ModelSettingsModal/ModelSettingsModal.tsx
index 25c722b82eb..ba050b51c50 100644
--- a/ui/litellm-dashboard/src/components/model_dashboard/ModelSettingsModal/ModelSettingsModal.tsx
+++ b/ui/litellm-dashboard/src/components/model_dashboard/ModelSettingsModal/ModelSettingsModal.tsx
@@ -2,7 +2,7 @@
import { ConfigType, useProxyConfig } from "@/app/(dashboard)/hooks/proxyConfig/useProxyConfig";
import { StoreModelInDBParams, useStoreModelInDB } from "@/app/(dashboard)/hooks/storeModelInDB/useStoreModelInDB";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { parseErrorMessage } from "@/components/shared/errorUtils";
import { Button, Form, Modal, Skeleton, Space, Switch, Typography } from "antd";
import React, { useEffect, useMemo } from "react";
@@ -44,16 +44,16 @@ const ModelSettingsModal: React.FC<ModelSettingsModalProps> = ({ isVisible, onCa
try {
await mutateAsync(formValues, {
onSuccess: () => {
- NotificationsManager.success("Model storage settings updated successfully");
+ toast.success("Model storage settings updated successfully");
refetch();
onSuccess?.();
},
onError: (error) => {
- NotificationsManager.fromBackend("Failed to save model storage settings: " + parseErrorMessage(error));
+ toast.fromError("Failed to save model storage settings: " + parseErrorMessage(error));
},
});
} catch (error) {
- NotificationsManager.fromBackend("Failed to save model storage settings: " + parseErrorMessage(error));
+ toast.fromError("Failed to save model storage settings: " + parseErrorMessage(error));
}
};
diff --git a/ui/litellm-dashboard/src/components/model_group_alias_settings.tsx b/ui/litellm-dashboard/src/components/model_group_alias_settings.tsx
index b130c455e71..c5e3b28f551 100644
--- a/ui/litellm-dashboard/src/components/model_group_alias_settings.tsx
+++ b/ui/litellm-dashboard/src/components/model_group_alias_settings.tsx
@@ -3,7 +3,7 @@ import { PlusCircleIcon, PencilIcon, TrashIcon, ChevronDownIcon, ChevronRightIco
import { setCallbacksCall } from "./networking";
import { Card, CardTitle } from "@/components/ui/card";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
type ModelGroupAliasValue = string | { model: string; hidden?: boolean };
@@ -67,20 +67,20 @@ const ModelGroupAliasSettings: React.FC<ModelGroupAliasSettingsProps> = ({
return true;
} catch (error) {
console.error("Failed to save model group alias settings:", error);
- NotificationsManager.fromBackend("Failed to save model group alias settings");
+ toast.fromError("Failed to save model group alias settings");
return false;
}
};
const handleAddAlias = async () => {
if (!newAlias.aliasName || !newAlias.targetModelGroup) {
- NotificationsManager.fromBackend("Please provide both alias name and target model group");
+ toast.fromError("Please provide both alias name and target model group");
return;
}
// Check for duplicate alias names
if (aliases.some((alias) => alias.aliasName === newAlias.aliasName)) {
- NotificationsManager.fromBackend("An alias with this name already exists");
+ toast.fromError("An alias with this name already exists");
return;
}
@@ -95,7 +95,7 @@ const ModelGroupAliasSettings: React.FC<ModelGroupAliasSettingsProps> = ({
if (await saveAliasesToBackend(updatedAliases)) {
setAliases(updatedAliases);
setNewAlias({ aliasName: "", targetModelGroup: "" });
- NotificationsManager.success("Alias added successfully");
+ toast.success("Alias added successfully");
}
};
@@ -107,13 +107,13 @@ const ModelGroupAliasSettings: React.FC<ModelGroupAliasSettingsProps> = ({
if (!editingAlias) return;
if (!editingAlias.aliasName || !editingAlias.targetModelGroup) {
- NotificationsManager.fromBackend("Please provide both alias name and target model group");
+ toast.fromError("Please provide both alias name and target model group");
return;
}
// Check for duplicate alias names (excluding current alias)
if (aliases.some((alias) => alias.id !== editingAlias.id && alias.aliasName === editingAlias.aliasName)) {
- NotificationsManager.fromBackend("An alias with this name already exists");
+ toast.fromError("An alias with this name already exists");
return;
}
@@ -122,7 +122,7 @@ const ModelGroupAliasSettings: React.FC<ModelGroupAliasSettingsProps> = ({
if (await saveAliasesToBackend(updatedAliases)) {
setAliases(updatedAliases);
setEditingAlias(null);
- NotificationsManager.success("Alias updated successfully");
+ toast.success("Alias updated successfully");
}
};
@@ -135,7 +135,7 @@ const ModelGroupAliasSettings: React.FC<ModelGroupAliasSettingsProps> = ({
if (await saveAliasesToBackend(updatedAliases)) {
setAliases(updatedAliases);
- NotificationsManager.success("Alias deleted successfully");
+ toast.success("Alias deleted successfully");
}
};
diff --git a/ui/litellm-dashboard/src/components/model_info_view.test.tsx b/ui/litellm-dashboard/src/components/model_info_view.test.tsx
index 74fd398eaab..1f6b783d1b0 100644
--- a/ui/litellm-dashboard/src/components/model_info_view.test.tsx
+++ b/ui/litellm-dashboard/src/components/model_info_view.test.tsx
@@ -4,7 +4,7 @@ import userEvent from "@testing-library/user-event";
import React, { ReactNode } from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import ModelInfoView from "./model_info_view";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import * as networking from "./networking";
vi.mock(
"@/app/(dashboard)/hooks/autoRouter/useComplexityScorerDefaults",
@@ -15,16 +15,6 @@ vi.mock("../../utils/dataUtils", () => ({
copyToClipboard: vi.fn().mockResolvedValue(true),
}));
-vi.mock("./molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- error: vi.fn(),
- info: vi.fn(),
- warning: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
vi.mock("./networking", () => ({
modelInfoV1Call: vi.fn(),
credentialGetCall: vi.fn(),
@@ -56,7 +46,7 @@ vi.mock("@/app/(dashboard)/hooks/uiSettings/usePtuCostAttributionEnabled", () =>
usePtuCostAttributionEnabled: () => mockUsePtuCostAttributionEnabled(),
}));
-const mockNotificationsManager = vi.mocked(NotificationsManager);
+const mockToast = vi.mocked(toast);
const mockModelInfoV1Call = vi.mocked(networking.modelInfoV1Call);
const mockCredentialGetCall = vi.mocked(networking.credentialGetCall);
const mockCredentialListCall = vi.mocked(networking.credentialListCall);
@@ -259,7 +249,7 @@ describe("ModelInfoView", () => {
await waitFor(() => {
expect(mockTestConnectionRequest).toHaveBeenCalled();
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Connection test successful!");
+ expect(mockToast.success).toHaveBeenCalledWith("Connection test successful!");
});
});
@@ -304,7 +294,7 @@ describe("ModelInfoView", () => {
await user.click(testButton);
await waitFor(() => {
- expect(mockNotificationsManager.error).toHaveBeenCalled();
+ expect(mockToast.error).toHaveBeenCalled();
});
});
@@ -522,7 +512,7 @@ describe("ModelInfoView", () => {
await waitFor(() => {
expect(mockModelPatchUpdateCall).toHaveBeenCalled();
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Model settings updated successfully");
+ expect(mockToast.success).toHaveBeenCalledWith("Model settings updated successfully");
expect(mockOnModelUpdate).toHaveBeenCalled();
});
});
@@ -1053,7 +1043,7 @@ describe("ModelInfoView", () => {
await userEvent.click(testConnectionButton);
await waitFor(() => {
- expect(mockNotificationsManager.warning).toHaveBeenCalledWith(
+ expect(mockToast.warning).toHaveBeenCalledWith(
"No complexity tiers are configured yet, so there is nothing to test.",
);
});
diff --git a/ui/litellm-dashboard/src/components/model_info_view.tsx b/ui/litellm-dashboard/src/components/model_info_view.tsx
index 0532238b872..b5f68677aeb 100644
--- a/ui/litellm-dashboard/src/components/model_info_view.tsx
+++ b/ui/litellm-dashboard/src/components/model_info_view.tsx
@@ -53,7 +53,7 @@ import CacheControlSettings from "./add_model/cache_control_settings";
import DeleteResourceModal from "./common_components/DeleteResourceModal";
import EditAutoRouterModal from "./edit_auto_router/edit_auto_router_modal";
import ReuseCredentialsModal from "./model_add/reuse_credentials";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
CredentialItem,
credentialCreateCall,
@@ -383,9 +383,9 @@ export default function ModelInfoView({
custom_llm_provider: localModelData.litellm_params?.custom_llm_provider,
},
};
- NotificationsManager.info("Storing credential..");
+ toast.info("Storing credential..");
let credentialResponse = await credentialCreateCall(accessToken, credentialItem);
- NotificationsManager.success("Credential stored successfully");
+ toast.success("Credential stored successfully");
};
const handleModelUpdate = async (values: any) => {
@@ -399,7 +399,7 @@ export default function ModelInfoView({
parsedExtraParams = values.litellm_extra_params ? JSON.parse(values.litellm_extra_params) : {};
delete parsedExtraParams.litellm_credential_name;
} catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in LiteLLM Params");
+ toast.fromError("Invalid JSON in LiteLLM Params");
setIsSaving(false);
return;
}
@@ -511,7 +511,7 @@ export default function ModelInfoView({
}
updatedModelInfo = applyPtuModelInfo(updatedModelInfo, values, ptuCostAttributionEnabled);
} catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in Model Info");
+ toast.fromError("Invalid JSON in Model Info");
return;
}
@@ -543,12 +543,12 @@ export default function ModelInfoView({
onModelUpdate(updatedModelData);
}
- NotificationsManager.success("Model settings updated successfully");
+ toast.success("Model settings updated successfully");
setIsDirty(false);
setIsEditing(false);
} catch (error) {
console.error("Error updating model:", error);
- NotificationsManager.fromBackend("Failed to update model settings");
+ toast.fromError("Failed to update model settings");
} finally {
setIsSaving(false);
}
@@ -583,7 +583,7 @@ export default function ModelInfoView({
if (isComplexityRouterModel) {
const targets = buildComplexityRouterTestTargets(localModelData ?? modelData);
if (targets.length === 0) {
- NotificationsManager.warning("No complexity tiers are configured yet, so there is nothing to test.");
+ toast.warning("No complexity tiers are configured yet, so there is nothing to test.");
return;
}
setAutoRouterTestTargets(targets);
@@ -592,7 +592,7 @@ export default function ModelInfoView({
return;
}
try {
- NotificationsManager.info("Testing connection...");
+ toast.info("Testing connection...");
const response = await testConnectionRequest(
accessToken,
{
@@ -613,15 +613,15 @@ export default function ModelInfoView({
);
if (response.status === "success") {
- NotificationsManager.success("Connection test successful!");
+ toast.success("Connection test successful!");
} else {
throw new Error(response?.result?.error || response?.message || "Unknown error");
}
} catch (error) {
if (error instanceof Error) {
- NotificationsManager.error("Error testing connection: " + truncateString(error.message, 100));
+ toast.error("Error testing connection: " + truncateString(error.message, 100));
} else {
- NotificationsManager.error("Error testing connection: " + String(error));
+ toast.error("Error testing connection: " + String(error));
}
}
};
@@ -631,7 +631,7 @@ export default function ModelInfoView({
setDeleteLoading(true);
if (!accessToken) return;
await modelDeleteCall(accessToken, modelId);
- NotificationsManager.success("Model deleted successfully");
+ toast.success("Model deleted successfully");
if (onModelUpdate) {
onModelUpdate({
@@ -643,7 +643,7 @@ export default function ModelInfoView({
onClose();
} catch (error) {
console.error("Error deleting the model:", error);
- NotificationsManager.fromBackend("Failed to delete model");
+ toast.fromError("Failed to delete model");
} finally {
setDeleteLoading(false);
setIsDeleteModalOpen(false);
diff --git a/ui/litellm-dashboard/src/components/molecules/message_manager.test.ts b/ui/litellm-dashboard/src/components/molecules/message_manager.test.ts
deleted file mode 100644
index 197a7442978..00000000000
--- a/ui/litellm-dashboard/src/components/molecules/message_manager.test.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import { createElement } from "react";
-import { beforeEach, describe, expect, it, vi } from "vitest";
-
-const sonner = vi.hoisted(() => ({
- success: vi.fn(),
- info: vi.fn(),
- warning: vi.fn(),
- error: vi.fn(),
- dismiss: vi.fn(),
-}));
-
-vi.mock("sonner", () => ({ toast: sonner }));
-vi.mock("@/components/molecules/notifications_manager", () =>
- vi.importActual<typeof import("./notifications_manager")>("./notifications_manager"),
-);
-
-import MessageManager from "./message_manager";
-import NotificationManager from "./notifications_manager";
-
-describe("legacy toast facades", () => {
- beforeEach(() => {
- vi.clearAllMocks();
- });
-
- it("MessageManager converts antd-era seconds into milliseconds", () => {
- MessageManager.error("failed!", 5);
- expect(sonner.error).toHaveBeenCalledWith("failed!", { description: undefined, duration: 5000 });
- });
-
- it("MessageManager falls back to the kind default when no duration is given", () => {
- MessageManager.success("done!");
- expect(sonner.success).toHaveBeenCalledWith("done!", { description: undefined, duration: 4000 });
- });
-
- it("MessageManager.destroy and NotificationManager.clear both dismiss", () => {
- MessageManager.destroy();
- NotificationManager.clear();
- expect(sonner.dismiss).toHaveBeenCalledTimes(2);
- });
-
- it("NotificationManager.fromBackend routes through toast.fromError", () => {
- NotificationManager.fromBackend({ message: "Team not found", type: "not_found_error", code: "404" });
- expect(sonner.error).toHaveBeenCalledWith("Not Found", { description: "Team not found", duration: 6000 });
- });
-
- it("NotificationManager.fromBackend converts the antd-era extra.duration seconds", () => {
- NotificationManager.fromBackend("boom", { duration: 8 });
- expect(sonner.error).toHaveBeenCalledWith("Error", { description: "boom", duration: 8000 });
- });
-
- it("NotificationManager keeps the antd config-object form: message is the title, description below it", () => {
- NotificationManager.success({
- message: "MCP Server submitted for admin review",
- description: "Once an admin approves it, the server will appear in your MCP Servers list.",
- duration: 10,
- });
- expect(sonner.success).toHaveBeenCalledWith("MCP Server submitted for admin review", {
- description: "Once an admin approves it, the server will appear in your MCP Servers list.",
- duration: 10000,
- });
- });
-
- it("NotificationManager falls back to the kind's title when a config object has no message", () => {
- NotificationManager.warning({ description: "Heads up" });
- expect(sonner.warning).toHaveBeenCalledWith("Warning", { description: "Heads up", duration: 6000 });
- });
-
- it("NotificationManager treats a React element as the message, not a config object", () => {
- const element = createElement("span", null, "done");
- NotificationManager.info(element);
- expect(sonner.info).toHaveBeenCalledWith(element, { description: undefined, duration: 4000 });
- });
-});
diff --git a/ui/litellm-dashboard/src/components/molecules/message_manager.tsx b/ui/litellm-dashboard/src/components/molecules/message_manager.tsx
deleted file mode 100644
index 36ed0b52496..00000000000
--- a/ui/litellm-dashboard/src/components/molecules/message_manager.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { toast } from "@/lib/toast";
-
-const secondsToMs = (seconds: number | undefined): number | undefined =>
- seconds === undefined ? undefined : seconds * 1000;
-
-const MessageManager = {
- success: (content: string, duration?: number): void => toast.success(content, { durationMs: secondsToMs(duration) }),
- error: (content: string, duration?: number): void => toast.error(content, { durationMs: secondsToMs(duration) }),
- warning: (content: string, duration?: number): void => toast.warning(content, { durationMs: secondsToMs(duration) }),
- info: (content: string, duration?: number): void => toast.info(content, { durationMs: secondsToMs(duration) }),
- destroy: (): void => toast.dismiss(),
-};
-
-export default MessageManager;
diff --git a/ui/litellm-dashboard/src/components/molecules/notifications_manager.tsx b/ui/litellm-dashboard/src/components/molecules/notifications_manager.tsx
deleted file mode 100644
index 2805f22a52e..00000000000
--- a/ui/litellm-dashboard/src/components/molecules/notifications_manager.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { isValidElement, type ReactNode } from "react";
-import { toast, type ToastKind } from "@/lib/toast";
-
-export type NotificationConfig = {
- readonly message?: ReactNode;
- readonly description?: ReactNode;
- readonly duration?: number;
- readonly placement?: string;
- readonly key?: string;
-};
-
-type NotificationInput = ReactNode | NotificationConfig;
-
-const FALLBACK_TITLES: Readonly<Record<ToastKind, string>> = {
- success: "Success",
- info: "Info",
- warning: "Warning",
- error: "Error",
-};
-
-const secondsToMs = (seconds: number | undefined): number | undefined =>
- seconds === undefined ? undefined : seconds * 1000;
-
-const isConfig = (input: NotificationInput): input is NotificationConfig =>
- input !== null && typeof input === "object" && !isValidElement(input) && !(Symbol.iterator in input);
-
-const show = (kind: ToastKind, input: NotificationInput): void => {
- if (!isConfig(input)) {
- toast[kind](input);
- return;
- }
- toast[kind](input.message ?? FALLBACK_TITLES[kind], {
- description: input.description,
- durationMs: secondsToMs(input.duration),
- });
-};
-
-const NotificationManager = {
- success: (input: NotificationInput): void => show("success", input),
- info: (input: NotificationInput): void => show("info", input),
- warning: (input: NotificationInput): void => show("warning", input),
- error: (input: NotificationInput): void => show("error", input),
- fromBackend: (input: unknown, extra?: Omit<NotificationConfig, "message" | "description">): void =>
- toast.fromError(input, { durationMs: secondsToMs(extra?.duration) }),
- clear: (): void => toast.dismiss(),
-};
-
-export default NotificationManager;
diff --git a/ui/litellm-dashboard/src/components/networking.test.ts b/ui/litellm-dashboard/src/components/networking.test.ts
index d32586e1774..86fe86307a2 100644
--- a/ui/litellm-dashboard/src/components/networking.test.ts
+++ b/ui/litellm-dashboard/src/components/networking.test.ts
@@ -9,15 +9,6 @@ vi.mock("@/utils/cookieUtils", () => ({
storeLoginToken: vi.fn(),
}));
-vi.mock("./molecules/notifications_manager", () => ({
- default: {
- info: vi.fn(),
- success: vi.fn(),
- error: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
describe("networking - expired session handling", () => {
const originalFetch = global.fetch;
@@ -31,10 +22,10 @@ describe("networking - expired session handling", () => {
it("should call clearTokenCookies on expired session", async () => {
const errorData = "Authentication Error - Expired Key";
- const { default: NotificationsManager } = await import("./molecules/notifications_manager");
+ const { toast } = await import("@/lib/toast");
if (errorData.includes("Authentication Error - Expired Key")) {
- NotificationsManager.info("UI Session Expired. Logging out.");
+ toast.info("UI Session Expired. Logging out.");
clearTokenCookies();
}
diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx
index 56293339361..a4ea85519eb 100644
--- a/ui/litellm-dashboard/src/components/networking.tsx
+++ b/ui/litellm-dashboard/src/components/networking.tsx
@@ -51,7 +51,7 @@ export const getAutoRouterClassifierDefaultPromptCall = async (
/**
* Helper file for calls being made to proxy
*/
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { clearTokenCookies, getCookie, storeLoginToken } from "@/utils/cookieUtils";
import { decodeToken } from "@/utils/jwtUtils";
import { TagNewRequest, TagUpdateRequest, TagListResponse, TagInfoResponse } from "./tag_management/types";
@@ -60,7 +60,6 @@ import { EmailEventSettingsResponse, EmailEventSettingsUpdateRequest } from "./e
import type { SkillRegisterRequest } from "./claude_code_plugins/types";
import type { ObjectPermission } from "./object_permission_types";
import { jsonFields } from "./common_components/check_openapi_schema";
-import NotificationsManager from "./molecules/notifications_manager";
import type { MCPUserEnvVarsStatus } from "./mcp_tools/types";
import type {
CoordinationRedisSettings,
@@ -340,7 +339,7 @@ export const handleError = async (errorData: string | any) => {
// Convert errorData to string if it isn't already
const errorString = typeof errorData === "string" ? errorData : JSON.stringify(errorData);
if (errorString.includes("Authentication Error - Expired Key")) {
- NotificationsManager.info("UI Session Expired. Logging out.");
+ toast.info("UI Session Expired. Logging out.");
lastErrorTime = currentTime;
clearTokenCookies();
const browserLocation = getWindowLocation();
@@ -609,10 +608,10 @@ export const modelCreateCall = async (accessToken: string, formValues: Model) =>
});
// Close any existing messages before showing new ones
- MessageManager.destroy();
+ toast.dismiss();
// Sequential success messages
- NotificationsManager.success(`Model ${formValues.model_name} created successfully`);
+ toast.success(`Model ${formValues.model_name} created successfully`);
return data;
} catch (error) {
@@ -1658,7 +1657,6 @@ export const modelInfoCall = async (
url += `?${params.toString()}`;
}
- //NotificationsManager.info("Requesting model data");
const response = await fetch(url, {
method: "GET",
headers: {
@@ -1674,7 +1672,7 @@ export const modelInfoCall = async (
if (errorData.includes("No model list passed")) {
errorData = "No Models Exist. Click Add Model to get started.";
}
- NotificationsManager.info(errorData);
+ toast.info(errorData);
ModelListerrorShown = true;
if (errorTimer) clearTimeout(errorTimer);
@@ -1687,7 +1685,6 @@ export const modelInfoCall = async (
}
const data = await response.json();
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -1790,9 +1787,7 @@ export const modelHubCall = async (accessToken: string) => {
* Get all models on proxy
*/
try {
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.get(`/model_group/info`, { accessToken });
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -2056,9 +2051,7 @@ export const uiSpendLogsCall = async ({
export const adminSpendLogsCall = async (accessToken: string) => {
try {
- //NotificationsManager.info("Making spend logs request");
const data = await apiClient.get(`/global/spend/logs`, { accessToken });
- //NotificationsManager.success("Spend Logs received");
return data;
} catch (error) {
console.error("Failed to create key:", error);
@@ -2070,7 +2063,6 @@ export const adminTopKeysCall = async (accessToken: string) => {
try {
let url = proxyBaseUrl ? `${proxyBaseUrl}/global/spend/keys?limit=5` : `/global/spend/keys?limit=5`;
- //NotificationsManager.info("Making spend keys request");
const response = await fetch(url, {
method: "GET",
headers: {
@@ -2086,7 +2078,6 @@ export const adminTopKeysCall = async (accessToken: string) => {
}
const data = await response.json();
- //NotificationsManager.success("Spend Logs received");
return data;
} catch (error) {
console.error("Failed to create key:", error);
@@ -2105,9 +2096,7 @@ export const adminTopEndUsersCall = async (
? { api_key: keyToken, startTime: startTime, endTime: endTime }
: { startTime: startTime, endTime: endTime };
- //NotificationsManager.info("Making top end users request");
const data = await apiClient.post(`/global/spend/end_users`, { accessToken, body });
- //NotificationsManager.success("Top End users received");
return data;
} catch (error) {
console.error("Failed to create key:", error);
@@ -2191,7 +2180,6 @@ export const adminTopModelsCall = async (accessToken: string) => {
try {
let url = proxyBaseUrl ? `${proxyBaseUrl}/global/spend/models?limit=5` : `/global/spend/models?limit=5`;
- //NotificationsManager.info("Making top models request");
const response = await fetch(url, {
method: "GET",
headers: {
@@ -2207,7 +2195,6 @@ export const adminTopModelsCall = async (accessToken: string) => {
}
const data = await response.json();
- //NotificationsManager.success("Top Models received");
return data;
} catch (error) {
console.error("Failed to create key:", error);
@@ -2394,7 +2381,7 @@ export const keyInfoV1Call = async (accessToken: string, key: string) => {
if (!response.ok) {
const errorData = await response.text();
handleError(errorData);
- NotificationsManager.fromBackend("Failed to fetch key info - " + errorData);
+ toast.fromError("Failed to fetch key info - " + errorData);
}
const data = await response.json();
@@ -2753,7 +2740,7 @@ export const teamUpdateCall = async (
const errorData = await response.text();
handleError(errorData);
console.error("Error response from the server:", errorData);
- NotificationsManager.fromBackend("Failed to update team settings: " + unwrapProxyErrorMessage(errorData));
+ toast.fromError("Failed to update team settings: " + unwrapProxyErrorMessage(errorData));
throw new Error(errorData);
}
const data = (await response.json()) as { data: Team; team_id: string };
@@ -3095,7 +3082,6 @@ export const userUpdateUserCall = async (
user_id: string;
data: UserInfo;
};
- //NotificationsManager.success("User role updated");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3147,7 +3133,6 @@ export const userBulkUpdateUserCall = async (
successful_updates: number;
failed_updates: number;
};
- //NotificationsManager.success("User role updated");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3191,9 +3176,7 @@ export const getBudgetList = async (accessToken: string) => {
* Get all configurable params for setting a budget
*/
try {
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.get(`/budget/list`, { accessToken });
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3206,9 +3189,7 @@ export const getCallbacksCall = async (accessToken: string, userID: string, user
* Get all the models user has access to
*/
try {
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.get(`/get/config/callbacks`, { accessToken });
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3223,7 +3204,6 @@ export const getGeneralSettingsCall = async (accessToken: string) => {
? `${proxyBaseUrl}/config/list?config_type=general_settings`
: `/config/list?config_type=general_settings`;
- //NotificationsManager.info("Requesting model data");
const response = await fetch(url, {
method: "GET",
headers: {
@@ -3240,7 +3220,6 @@ export const getGeneralSettingsCall = async (accessToken: string) => {
}
const data = await response.json();
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3348,9 +3327,7 @@ export const getPassThroughEndpointsCall = async (accessToken: string, teamId?:
path += `/team/${teamId}`;
}
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.get(path, { accessToken });
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3365,7 +3342,6 @@ export const getConfigFieldSetting = async (accessToken: string, fieldName: stri
? `${proxyBaseUrl}/config/field/info?field_name=${fieldName}`
: `/config/field/info?field_name=${fieldName}`;
- //NotificationsManager.info("Requesting model data");
const response = await fetch(url, {
method: "GET",
headers: {
@@ -3395,14 +3371,12 @@ export const createPassThroughEndpoint = async (accessToken: string, formValues:
* Set callbacks on proxy
*/
try {
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.post(`/config/pass_through_endpoint`, {
accessToken,
body: {
...formValues, // Include formValues in the request body
},
});
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3418,10 +3392,8 @@ export const updateConfigFieldSetting = async (accessToken: string, fieldName: s
field_value: fieldValue,
config_type: "general_settings",
};
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.post(`/config/field/update`, { accessToken, body: formData });
- //NotificationsManager.info("Received model data");
- NotificationsManager.success("Successfully updated value!");
+ toast.success("Successfully updated value!");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3436,9 +3408,8 @@ export const deleteConfigFieldSetting = async (accessToken: string, fieldName: s
field_name: fieldName,
config_type: "general_settings",
};
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.post(`/config/field/delete`, { accessToken, body: formData });
- NotificationsManager.success("Field reset on proxy");
+ toast.success("Field reset on proxy");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3453,7 +3424,6 @@ export const deletePassThroughEndpointsCall = async (accessToken: string, endpoi
? `${proxyBaseUrl}/config/pass_through_endpoint?endpoint_id=${endpointId}`
: `/config/pass_through_endpoint?endpoint_id=${endpointId}`;
- //NotificationsManager.info("Requesting model data");
const response = await fetch(url, {
method: "DELETE",
headers: {
@@ -3470,7 +3440,6 @@ export const deletePassThroughEndpointsCall = async (accessToken: string, endpoi
}
const data = await response.json();
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3484,14 +3453,12 @@ export const setCallbacksCall = async (accessToken: string, formValues: Record<s
* Set callbacks on proxy
*/
try {
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.post(`/config/update`, {
accessToken,
body: {
...formValues, // Include formValues in the request body
},
});
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3539,7 +3506,6 @@ export const cachingHealthCheckCall = async (accessToken: string) => {
try {
let url = proxyBaseUrl ? `${proxyBaseUrl}/cache/ping` : `/cache/ping`;
- //NotificationsManager.info("Requesting model data");
const response = await fetch(url, {
method: "GET",
headers: {
@@ -3555,7 +3521,6 @@ export const cachingHealthCheckCall = async (accessToken: string) => {
}
const data = await response.json();
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -3598,9 +3563,7 @@ export const getProxyUISettings = async (accessToken: string) => {
* Get all the models user has access to
*/
try {
- //NotificationsManager.info("Requesting model data");
const data = await apiClient.get(`/sso/get/ui_settings`, { accessToken });
- //NotificationsManager.info("Received model data");
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
@@ -6639,7 +6602,7 @@ export const updatePassThroughEndpoint = async (
}
const data = await response.json();
- NotificationsManager.success("Pass through endpoint updated successfully");
+ toast.success("Pass through endpoint updated successfully");
return data;
} catch (error) {
console.error("Failed to update pass through endpoint:", error);
diff --git a/ui/litellm-dashboard/src/components/onboarding_link.tsx b/ui/litellm-dashboard/src/components/onboarding_link.tsx
index b5f3c6d3e17..f25811719c1 100644
--- a/ui/litellm-dashboard/src/components/onboarding_link.tsx
+++ b/ui/litellm-dashboard/src/components/onboarding_link.tsx
@@ -2,7 +2,7 @@ import React from "react";
import { Button, Modal, Typography } from "antd";
import { CopyToClipboard } from "react-copy-to-clipboard";
import { Text } from "@tremor/react";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
export interface InvitationLink {
id: string;
@@ -100,7 +100,7 @@ export default function OnboardingModal({
</Text>
</div>
<div className="flex justify-end mt-5">
- <CopyToClipboard text={getInvitationUrl()} onCopy={() => NotificationsManager.success("Copied!")}>
+ <CopyToClipboard text={getInvitationUrl()} onCopy={() => toast.success("Copied!")}>
<Button type="primary">
{modalType === "invitation" ? "Copy invitation link" : "Copy password reset link"}
</Button>
diff --git a/ui/litellm-dashboard/src/components/organisms/RegenerateKeyModal.test.tsx b/ui/litellm-dashboard/src/components/organisms/RegenerateKeyModal.test.tsx
index 98ce3827151..180f9d1f265 100644
--- a/ui/litellm-dashboard/src/components/organisms/RegenerateKeyModal.test.tsx
+++ b/ui/litellm-dashboard/src/components/organisms/RegenerateKeyModal.test.tsx
@@ -3,6 +3,7 @@ import userEvent from "@testing-library/user-event";
import { renderWithProviders, screen, waitFor } from "../../../tests/test-utils";
import { RegenerateKeyModal } from "./RegenerateKeyModal";
import { KeyResponse } from "../key_team_helpers/key_list";
+import { toast } from "@/lib/toast";
// Mock the networking call
const mockRegenerateKeyCall = vi.fn();
@@ -10,14 +11,7 @@ vi.mock("../networking", () => ({
regenerateKeyCall: (...args: unknown[]) => mockRegenerateKeyCall(...args),
}));
-const mockNotificationFromBackend = vi.fn();
-const mockNotificationSuccess = vi.fn();
-vi.mock("../molecules/notifications_manager", () => ({
- default: {
- fromBackend: (...args: unknown[]) => mockNotificationFromBackend(...args),
- success: (...args: unknown[]) => mockNotificationSuccess(...args),
- },
-}));
+const mockNotificationFromBackend = vi.mocked(toast.fromError);
const makeToken = (overrides: Partial<KeyResponse> = {}): KeyResponse =>
({
diff --git a/ui/litellm-dashboard/src/components/organisms/RegenerateKeyModal.tsx b/ui/litellm-dashboard/src/components/organisms/RegenerateKeyModal.tsx
index 8138614982a..3902f3f736b 100644
--- a/ui/litellm-dashboard/src/components/organisms/RegenerateKeyModal.tsx
+++ b/ui/litellm-dashboard/src/components/organisms/RegenerateKeyModal.tsx
@@ -4,7 +4,7 @@ import { Alert, Button, Col, Flex, Form, Input, InputNumber, Modal, Row, Space,
import { useEffect, useState } from "react";
import { CopyToClipboard } from "react-copy-to-clipboard";
import { KeyResponse } from "../key_team_helpers/key_list";
-import NotificationManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { regenerateKeyCall } from "../networking";
import { calculateExpiryPreviewFromDuration, formatExpiresUtc, isKeyExpired } from "@/utils/keyExpiryUtils";
@@ -62,7 +62,7 @@ export function RegenerateKeyModal({ selectedToken, visible, onClose, onKeyUpdat
const response = await regenerateKeyCall(accessToken, selectedToken.token || selectedToken.token_id, formValues);
setRegeneratedKey(response.key);
- NotificationManager.success("Virtual Key regenerated successfully");
+ toast.success("Virtual Key regenerated successfully");
// Build the update payload. Spread the API response first so any new
// fields it returns (new token, timestamps, etc.) are captured, then
@@ -94,7 +94,7 @@ export function RegenerateKeyModal({ selectedToken, visible, onClose, onKeyUpdat
return;
}
console.error("Error regenerating key:", error);
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
}
};
diff --git a/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx b/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx
index 4f3cd4455a1..8df77246140 100644
--- a/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx
+++ b/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx
@@ -237,17 +237,6 @@ vi.mock("../networking", () => ({
getAgentsList: vi.fn().mockResolvedValue({ agents: [] }),
}));
-vi.mock("../molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- error: vi.fn(),
- warning: vi.fn(),
- info: vi.fn(),
- clear: vi.fn(),
- },
-}));
-
vi.mock("../agent_management/AgentSelector", () => ({ default: () => null }));
vi.mock("../common_components/budget_duration_dropdown", () => ({
NEVER_RESETS_BUDGET_DURATION: "none",
diff --git a/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx b/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx
index 8573c2f7415..d8cd537bc8a 100644
--- a/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx
+++ b/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx
@@ -42,7 +42,7 @@ import { Team } from "../key_team_helpers/key_list";
import MCPServerSelector from "../mcp_server_management/MCPServerSelector";
import { NO_MCP_SERVERS_SENTINEL } from "../mcp_tools/constants";
import MCPToolPermissions from "../mcp_server_management/MCPToolPermissions";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
getAgentsList,
getGuardrailsList,
@@ -371,14 +371,14 @@ const CreateKey: React.FC<CreateKeyProps> = ({ team, teams, data, addKey, autoOp
);
}
- NotificationsManager.info("Making API Call");
+ toast.info("Making API Call");
setIsModalVisible(true);
if (keyOwner === "you") {
formValues.user_id = userID;
} else if (keyOwner === "agent") {
if (!selectedAgentId) {
- NotificationsManager.fromBackend("Please select an agent");
+ toast.fromError("Please select an agent");
return;
}
formValues.agent_id = selectedAgentId;
@@ -562,7 +562,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({ team, teams, data, addKey, autoOp
queryClient.invalidateQueries({ queryKey: keyKeys.lists() });
setApiKey(response["key"]);
- NotificationsManager.success("Virtual Key Created");
+ toast.success("Virtual Key Created");
form.resetFields();
setBudgetLimits([]);
setTagRateLimits([]);
@@ -571,7 +571,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({ team, teams, data, addKey, autoOp
localStorage.removeItem("userData" + userID);
} catch (error) {
const simplifiedError = simplifyKeyGenerateError(error);
- NotificationsManager.fromBackend(simplifiedError);
+ toast.fromError(simplifiedError);
}
};
@@ -665,7 +665,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({ team, teams, data, addKey, autoOp
setUserOptions(options);
} catch (error) {
console.error("Error fetching users:", error);
- NotificationsManager.fromBackend("Failed to search for users");
+ toast.fromError("Failed to search for users");
} finally {
setUserSearchLoading(false);
}
diff --git a/ui/litellm-dashboard/src/components/organization/org-create/OrgCreateDialog.test.tsx b/ui/litellm-dashboard/src/components/organization/org-create/OrgCreateDialog.test.tsx
index 1799795a428..3ffb11fb90d 100644
--- a/ui/litellm-dashboard/src/components/organization/org-create/OrgCreateDialog.test.tsx
+++ b/ui/litellm-dashboard/src/components/organization/org-create/OrgCreateDialog.test.tsx
@@ -4,10 +4,6 @@ import userEvent from "@testing-library/user-event";
import React from "react";
import { describe, expect, it, vi } from "vitest";
-vi.mock("@/components/molecules/notifications_manager", () => ({
- __esModule: true,
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
vi.mock("@/components/ModelSelect/ModelSelect", () => ({
ModelSelect: ({ onChange }: { onChange: (values: string[]) => void }) => (
<button type="button" onClick={() => onChange(["gpt-5.2"])}>
diff --git a/ui/litellm-dashboard/src/components/organization/org-create/OrgCreateDialog.tsx b/ui/litellm-dashboard/src/components/organization/org-create/OrgCreateDialog.tsx
index 4e1a00704e3..e9d9ba0dcf8 100644
--- a/ui/litellm-dashboard/src/components/organization/org-create/OrgCreateDialog.tsx
+++ b/ui/litellm-dashboard/src/components/organization/org-create/OrgCreateDialog.tsx
@@ -6,7 +6,7 @@ import * as React from "react";
import { organizationKeys } from "@/app/(dashboard)/hooks/organizations/useOrganizations";
import { ModelSelect } from "@/components/ModelSelect/ModelSelect";
import MCPServerSelector from "@/components/mcp_server_management/MCPServerSelector";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { FieldGroup } from "@/components/shared/form/field";
import { FormField } from "@/components/shared/form/FormField";
import { Button } from "@/components/ui/button";
@@ -51,12 +51,12 @@ export const OrgCreateDialog = ({
const mutation = useMutation({
mutationFn: (body: OrgCreateBody) => createOrganization(body),
onSuccess: () => {
- NotificationsManager.success("Organization created successfully");
+ toast.success("Organization created successfully");
queryClient.invalidateQueries({ queryKey: organizationKeys.all });
closeAndReset();
},
onError: (error: unknown) =>
- NotificationsManager.fromBackend(error instanceof Error ? error.message : "Failed to create organization"),
+ toast.fromError(error instanceof Error ? error.message : "Failed to create organization"),
});
const handleOpenChange = (nextOpen: boolean) => {
diff --git a/ui/litellm-dashboard/src/components/organization/org-settings/OrgSettingsForm.test.tsx b/ui/litellm-dashboard/src/components/organization/org-settings/OrgSettingsForm.test.tsx
index 4dfd37e3466..3103c673a3b 100644
--- a/ui/litellm-dashboard/src/components/organization/org-settings/OrgSettingsForm.test.tsx
+++ b/ui/litellm-dashboard/src/components/organization/org-settings/OrgSettingsForm.test.tsx
@@ -4,10 +4,6 @@ import userEvent from "@testing-library/user-event";
import React from "react";
import { describe, expect, it, vi } from "vitest";
-vi.mock("@/components/molecules/notifications_manager", () => ({
- __esModule: true,
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
vi.mock("@/components/ModelSelect/ModelSelect", () => ({
ModelSelect: ({ onChange }: { onChange: (values: string[]) => void }) => (
<button type="button" onClick={() => onChange([])}>
diff --git a/ui/litellm-dashboard/src/components/organization/org-settings/OrgSettingsForm.tsx b/ui/litellm-dashboard/src/components/organization/org-settings/OrgSettingsForm.tsx
index affe0ed2d4e..a1a38c4b1f4 100644
--- a/ui/litellm-dashboard/src/components/organization/org-settings/OrgSettingsForm.tsx
+++ b/ui/litellm-dashboard/src/components/organization/org-settings/OrgSettingsForm.tsx
@@ -6,7 +6,7 @@ import * as React from "react";
import { organizationKeys } from "@/app/(dashboard)/hooks/organizations/useOrganizations";
import { ModelSelect } from "@/components/ModelSelect/ModelSelect";
import MCPServerSelector from "@/components/mcp_server_management/MCPServerSelector";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import type { Organization } from "@/components/networking";
import { FieldGroup } from "@/components/shared/form/field";
import { FormField } from "@/components/shared/form/FormField";
@@ -63,14 +63,12 @@ export const OrgSettingsForm = ({
const mutation = useMutation({
mutationFn: (body: OrgPatchBody) => patchOrganization(organizationId, body),
onSuccess: () => {
- NotificationsManager.success("Organization settings updated successfully");
+ toast.success("Organization settings updated successfully");
queryClient.invalidateQueries({ queryKey: organizationKeys.all });
onSaved();
},
onError: (error: unknown) =>
- NotificationsManager.fromBackend(
- error instanceof Error ? error.message : "Failed to update organization settings",
- ),
+ toast.fromError(error instanceof Error ? error.message : "Failed to update organization settings"),
});
const onSubmit = form.handleSubmit((values) => {
diff --git a/ui/litellm-dashboard/src/components/organization/organization_view.test.tsx b/ui/litellm-dashboard/src/components/organization/organization_view.test.tsx
index 4d96fc84ca9..062e4df0181 100644
--- a/ui/litellm-dashboard/src/components/organization/organization_view.test.tsx
+++ b/ui/litellm-dashboard/src/components/organization/organization_view.test.tsx
@@ -44,10 +44,6 @@ vi.mock("../object_permissions_view", () => ({
__esModule: true,
default: () => <div data-testid="object-permissions-view" />,
}));
-vi.mock("../molecules/notifications_manager", () => ({
- __esModule: true,
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
vi.mock("../team/edit_membership", () => ({
__esModule: true,
default: () => null,
diff --git a/ui/litellm-dashboard/src/components/organization/organization_view.tsx b/ui/litellm-dashboard/src/components/organization/organization_view.tsx
index 8c1607088c9..2590f3bad52 100644
--- a/ui/litellm-dashboard/src/components/organization/organization_view.tsx
+++ b/ui/litellm-dashboard/src/components/organization/organization_view.tsx
@@ -15,7 +15,7 @@ import { ArrowLeft } from "lucide-react";
import React, { useMemo, useState } from "react";
import MemberTable, { type MemberTableColumn } from "../common_components/MemberTable";
import UserSearchModal from "../common_components/user_search_modal";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
Member,
organizationMemberAddCall,
@@ -70,11 +70,11 @@ const OrganizationInfoView: React.FC<OrganizationInfoProps> = ({
};
await organizationMemberAddCall(accessToken, organizationId, member);
- NotificationsManager.success("Organization member added successfully");
+ toast.success("Organization member added successfully");
setIsAddMemberModalVisible(false);
queryClient.invalidateQueries({ queryKey: organizationKeys.all });
} catch (error) {
- NotificationsManager.fromBackend("Failed to add organization member");
+ toast.fromError("Failed to add organization member");
console.error("Error adding organization member:", error);
}
};
@@ -90,11 +90,11 @@ const OrganizationInfoView: React.FC<OrganizationInfoProps> = ({
};
await organizationMemberUpdateCall(accessToken, organizationId, member);
- NotificationsManager.success("Organization member updated successfully");
+ toast.success("Organization member updated successfully");
setIsEditMemberModalVisible(false);
queryClient.invalidateQueries({ queryKey: organizationKeys.all });
} catch (error) {
- NotificationsManager.fromBackend("Failed to update organization member");
+ toast.fromError("Failed to update organization member");
console.error("Error updating organization member:", error);
}
};
@@ -104,11 +104,11 @@ const OrganizationInfoView: React.FC<OrganizationInfoProps> = ({
if (!accessToken) return;
await organizationMemberDeleteCall(accessToken, organizationId, values.user_id);
- NotificationsManager.success("Organization member deleted successfully");
+ toast.success("Organization member deleted successfully");
setIsEditMemberModalVisible(false);
queryClient.invalidateQueries({ queryKey: organizationKeys.all });
} catch (error) {
- NotificationsManager.fromBackend("Failed to delete organization member");
+ toast.fromError("Failed to delete organization member");
console.error("Error deleting organization member:", error);
}
};
diff --git a/ui/litellm-dashboard/src/components/pass_through_info.tsx b/ui/litellm-dashboard/src/components/pass_through_info.tsx
index 37d7e5d5da1..c6c12effecb 100644
--- a/ui/litellm-dashboard/src/components/pass_through_info.tsx
+++ b/ui/litellm-dashboard/src/components/pass_through_info.tsx
@@ -17,7 +17,7 @@ import { Button, Form, Input, Switch, InputNumber, Select } from "antd";
import { updatePassThroughEndpoint, deletePassThroughEndpointsCall } from "./networking";
import { Eye, EyeOff } from "lucide-react";
import RoutePreview from "./route_preview";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import PassThroughSecuritySection from "./common_components/PassThroughSecuritySection";
import PassThroughGuardrailsSection from "./common_components/PassThroughGuardrailsSection";
@@ -91,7 +91,7 @@ const PassThroughInfoView: React.FC<PassThroughInfoProps> = ({
try {
headers = typeof values.headers === "string" ? JSON.parse(values.headers) : values.headers;
} catch (e) {
- NotificationsManager.fromBackend("Invalid JSON format for headers");
+ toast.fromError("Invalid JSON format for headers");
return;
}
}
@@ -122,7 +122,7 @@ const PassThroughInfoView: React.FC<PassThroughInfoProps> = ({
}
} catch (error) {
console.error("Error updating endpoint:", error);
- NotificationsManager.fromBackend("Failed to update pass through endpoint");
+ toast.fromError("Failed to update pass through endpoint");
}
};
@@ -131,14 +131,14 @@ const PassThroughInfoView: React.FC<PassThroughInfoProps> = ({
if (!accessToken || !endpointData?.id) return;
await deletePassThroughEndpointsCall(accessToken, endpointData.id);
- NotificationsManager.success("Pass through endpoint deleted successfully");
+ toast.success("Pass through endpoint deleted successfully");
onClose();
if (onEndpointUpdated) {
onEndpointUpdated();
}
} catch (error) {
console.error("Error deleting endpoint:", error);
- NotificationsManager.fromBackend("Failed to delete pass through endpoint");
+ toast.fromError("Failed to delete pass through endpoint");
}
};
diff --git a/ui/litellm-dashboard/src/components/price_data_reload.test.tsx b/ui/litellm-dashboard/src/components/price_data_reload.test.tsx
index cbee2328478..8b6c238f18a 100644
--- a/ui/litellm-dashboard/src/components/price_data_reload.test.tsx
+++ b/ui/litellm-dashboard/src/components/price_data_reload.test.tsx
@@ -2,7 +2,7 @@ import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
cancelModelCostMapReload,
getModelCostMapReloadStatus,
@@ -19,9 +19,6 @@ vi.mock("./networking", () => ({
reloadModelCostMap: vi.fn(),
scheduleModelCostMapReload: vi.fn(),
}));
-vi.mock("./molecules/notifications_manager", () => ({
- default: { success: vi.fn(), fromBackend: vi.fn() },
-}));
const unscheduledStatus = { scheduled: false, interval_hours: null, last_run: null, next_run: null };
const scheduledStatus = {
@@ -66,7 +63,7 @@ describe("PriceDataReload", () => {
await waitFor(() => expect(reloadModelCostMap).toHaveBeenCalledWith("sk-test"));
expect(onReloadSuccess).toHaveBeenCalledTimes(1);
- expect(NotificationsManager.success).toHaveBeenCalledWith("Price data reloaded successfully! 42 models updated.");
+ expect(toast.success).toHaveBeenCalledWith("Price data reloaded successfully! 42 models updated.");
});
it("schedules periodic reloads using the selected interval", async () => {
@@ -82,7 +79,7 @@ describe("PriceDataReload", () => {
await user.click(screen.getByRole("button", { name: "Schedule" }));
await waitFor(() => expect(scheduleModelCostMapReload).toHaveBeenCalledWith("sk-test", 12));
- expect(NotificationsManager.success).toHaveBeenCalledWith("Periodic reload scheduled for every 12 hours");
+ expect(toast.success).toHaveBeenCalledWith("Periodic reload scheduled for every 12 hours");
});
it.each(["-1", "1.5", "169"])("should reject an invalid periodic reload interval of %s hours", async (interval) => {
@@ -94,7 +91,7 @@ describe("PriceDataReload", () => {
await user.click(screen.getByRole("button", { name: "Schedule" }));
expect(scheduleModelCostMapReload).not.toHaveBeenCalled();
- expect(NotificationsManager.fromBackend).toHaveBeenCalledWith("Hours must be a whole number between 1 and 168");
+ expect(toast.fromError).toHaveBeenCalledWith("Hours must be a whole number between 1 and 168");
});
it.each([1, 168])("should schedule a periodic reload at the inclusive %s-hour boundary", async (interval) => {
@@ -118,6 +115,6 @@ describe("PriceDataReload", () => {
await user.click(await screen.findByRole("button", { name: /Cancel Periodic Reload/ }));
await waitFor(() => expect(cancelModelCostMapReload).toHaveBeenCalledWith("sk-test"));
- expect(NotificationsManager.success).toHaveBeenCalledWith("Periodic reload cancelled successfully");
+ expect(toast.success).toHaveBeenCalledWith("Periodic reload cancelled successfully");
});
});
diff --git a/ui/litellm-dashboard/src/components/price_data_reload.tsx b/ui/litellm-dashboard/src/components/price_data_reload.tsx
index a60bc2e8ec8..1c6801eede2 100644
--- a/ui/litellm-dashboard/src/components/price_data_reload.tsx
+++ b/ui/litellm-dashboard/src/components/price_data_reload.tsx
@@ -28,7 +28,7 @@ import { Separator } from "@/components/ui/separator";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { cn } from "@/lib/cva.config";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
cancelModelCostMapReload,
getModelCostMapReloadStatus,
@@ -148,7 +148,7 @@ const PriceDataReload: React.FC<PriceDataReloadProps> = ({
const handleHardRefresh = async () => {
if (!accessToken) {
- NotificationsManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
@@ -157,16 +157,16 @@ const PriceDataReload: React.FC<PriceDataReloadProps> = ({
const response = await reloadModelCostMap(accessToken);
if (response.status === "success") {
- NotificationsManager.success(`Price data reloaded successfully! ${response.models_count || 0} models updated.`);
+ toast.success(`Price data reloaded successfully! ${response.models_count || 0} models updated.`);
onReloadSuccess?.();
await fetchReloadStatus();
await fetchSourceInfo();
} else {
- NotificationsManager.fromBackend("Failed to reload price data");
+ toast.fromError("Failed to reload price data");
}
} catch (error) {
console.error("Error reloading price data:", error);
- NotificationsManager.fromBackend("Failed to reload price data. Please try again.");
+ toast.fromError("Failed to reload price data. Please try again.");
} finally {
setIsLoading(false);
}
@@ -174,13 +174,13 @@ const PriceDataReload: React.FC<PriceDataReloadProps> = ({
const handleScheduleReload = async () => {
if (!accessToken) {
- NotificationsManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
const intervalHours = Number(hours);
if (!isValidReloadInterval(intervalHours)) {
- NotificationsManager.fromBackend("Hours must be a whole number between 1 and 168");
+ toast.fromError("Hours must be a whole number between 1 and 168");
return;
}
@@ -189,15 +189,15 @@ const PriceDataReload: React.FC<PriceDataReloadProps> = ({
const response = await scheduleModelCostMapReload(accessToken, intervalHours);
if (response.status === "success") {
- NotificationsManager.success(`Periodic reload scheduled for every ${intervalHours} hours`);
+ toast.success(`Periodic reload scheduled for every ${intervalHours} hours`);
setShowScheduleModal(false);
await fetchReloadStatus();
} else {
- NotificationsManager.fromBackend("Failed to schedule periodic reload");
+ toast.fromError("Failed to schedule periodic reload");
}
} catch (error) {
console.error("Error scheduling reload:", error);
- NotificationsManager.fromBackend("Failed to schedule periodic reload. Please try again.");
+ toast.fromError("Failed to schedule periodic reload. Please try again.");
} finally {
setIsScheduling(false);
}
@@ -205,7 +205,7 @@ const PriceDataReload: React.FC<PriceDataReloadProps> = ({
const handleCancelReload = async () => {
if (!accessToken) {
- NotificationsManager.fromBackend("No access token available");
+ toast.fromError("No access token available");
return;
}
@@ -214,14 +214,14 @@ const PriceDataReload: React.FC<PriceDataReloadProps> = ({
const response = await cancelModelCostMapReload(accessToken);
if (response.status === "success") {
- NotificationsManager.success("Periodic reload cancelled successfully");
+ toast.success("Periodic reload cancelled successfully");
await fetchReloadStatus();
} else {
- NotificationsManager.fromBackend("Failed to cancel periodic reload");
+ toast.fromError("Failed to cancel periodic reload");
}
} catch (error) {
console.error("Error cancelling reload:", error);
- NotificationsManager.fromBackend("Failed to cancel periodic reload. Please try again.");
+ toast.fromError("Failed to cancel periodic reload. Please try again.");
} finally {
setIsCancelling(false);
}
diff --git a/ui/litellm-dashboard/src/components/public_model_hub.tsx b/ui/litellm-dashboard/src/components/public_model_hub.tsx
index 4ca7a52692a..e60bb7635ff 100644
--- a/ui/litellm-dashboard/src/components/public_model_hub.tsx
+++ b/ui/litellm-dashboard/src/components/public_model_hub.tsx
@@ -22,7 +22,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { MultiSelect } from "./shared/MultiSelect";
import { DataTable } from "./shared/DataTable";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import Navbar from "./navbar";
import {
agentHubPublicModelsCall,
@@ -439,7 +439,7 @@ const PublicModelHub: React.FC<PublicModelHubProps> = ({ accessToken, isEmbedded
const copyToClipboard = (text: string) => {
navigator.clipboard.writeText(text);
- NotificationsManager.success("Copied to clipboard!");
+ toast.success("Copied to clipboard!");
};
const formatCapabilityName = (key: string) => {
diff --git a/ui/litellm-dashboard/src/components/router_settings/index.test.tsx b/ui/litellm-dashboard/src/components/router_settings/index.test.tsx
index 72657069cde..407a46a5a1c 100644
--- a/ui/litellm-dashboard/src/components/router_settings/index.test.tsx
+++ b/ui/litellm-dashboard/src/components/router_settings/index.test.tsx
@@ -27,7 +27,7 @@ vi.mock("@/components/networking", () => ({
}));
import { getCallbacksCall, getRouterSettingsCall, setCallbacksCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
const mockCallbacksResponse = {
router_settings: {
@@ -168,7 +168,7 @@ describe("RouterSettings", () => {
});
await user.click(screen.getByRole("button", { name: /save changes/i }));
- expect(NotificationsManager.success).toHaveBeenCalledWith("router settings updated successfully");
+ expect(toast.success).toHaveBeenCalledWith("router settings updated successfully");
});
it("should not render or save routing_groups (owned by the Routing Groups tab)", async () => {
@@ -207,8 +207,8 @@ describe("RouterSettings", () => {
await user.click(screen.getByRole("button", { name: /save changes/i }));
await waitFor(() => {
- expect(NotificationsManager.fromBackend).toHaveBeenCalled();
+ expect(toast.fromError).toHaveBeenCalled();
});
- expect(NotificationsManager.success).not.toHaveBeenCalled();
+ expect(toast.success).not.toHaveBeenCalled();
});
});
diff --git a/ui/litellm-dashboard/src/components/router_settings/index.tsx b/ui/litellm-dashboard/src/components/router_settings/index.tsx
index b2668d98d69..127829e082a 100644
--- a/ui/litellm-dashboard/src/components/router_settings/index.tsx
+++ b/ui/litellm-dashboard/src/components/router_settings/index.tsx
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { Button } from "@/components/ui/button";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getCallbacksCall, getRouterSettingsCall, setCallbacksCall } from "../networking";
import RouterSettingsForm, { RouterSettingsFormValue } from "./RouterSettingsForm";
@@ -168,9 +168,9 @@ const RouterSettings: React.FC<RouterSettingsProps> = ({ accessToken, userRole,
try {
await setCallbacksCall(accessToken, payload);
- NotificationsManager.success("router settings updated successfully");
+ toast.success("router settings updated successfully");
} catch (error) {
- NotificationsManager.fromBackend("Failed to update router settings: " + error);
+ toast.fromError("Failed to update router settings: " + error);
}
};
diff --git a/ui/litellm-dashboard/src/components/routing_groups/index.tsx b/ui/litellm-dashboard/src/components/routing_groups/index.tsx
index 8b33b050377..41e71c77e1f 100644
--- a/ui/litellm-dashboard/src/components/routing_groups/index.tsx
+++ b/ui/litellm-dashboard/src/components/routing_groups/index.tsx
@@ -10,7 +10,7 @@ import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import useProxySettings from "@/app/(dashboard)/hooks/proxySettings/useProxySettings";
import RoutingGroupsTable from "./RoutingGroupsTable";
import RoutingGroupModal from "./RoutingGroupModal";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import type { RoutingGroup } from "./types";
const { Text } = Typography;
@@ -76,14 +76,14 @@ const RoutingGroups: React.FC = () => {
try {
await saveMutation.mutateAsync(next);
- NotificationsManager.success(
+ toast.success(
drawerMode === "create"
? `Created routing group "${incoming.group_name}"`
: `Updated routing group "${incoming.group_name}"`,
);
setDrawerOpen(false);
} catch (err) {
- NotificationsManager.error(err instanceof Error ? err.message : "Failed to save routing group");
+ toast.error(err instanceof Error ? err.message : "Failed to save routing group");
}
};
@@ -92,10 +92,10 @@ const RoutingGroups: React.FC = () => {
const next = groups.filter((g) => g.group_name !== deletingGroup.group_name);
try {
await saveMutation.mutateAsync(next);
- NotificationsManager.success(`Deleted routing group "${deletingGroup.group_name}"`);
+ toast.success(`Deleted routing group "${deletingGroup.group_name}"`);
setDeletingGroup(null);
} catch (err) {
- NotificationsManager.error(err instanceof Error ? err.message : "Failed to delete routing group");
+ toast.error(err instanceof Error ? err.message : "Failed to delete routing group");
}
};
diff --git a/ui/litellm-dashboard/src/components/settings.test.tsx b/ui/litellm-dashboard/src/components/settings.test.tsx
index dd45521ab4f..d29f3d44bbb 100644
--- a/ui/litellm-dashboard/src/components/settings.test.tsx
+++ b/ui/litellm-dashboard/src/components/settings.test.tsx
@@ -14,17 +14,6 @@ vi.mock("./networking", () => ({
alertingSettingsCall: vi.fn().mockResolvedValue([]),
}));
-vi.mock("./molecules/notifications_manager", () => ({
- __esModule: true,
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- info: vi.fn(),
- warning: vi.fn(),
- clear: vi.fn(),
- },
-}));
-
vi.mock("./alerting/alerting_settings", () => ({
__esModule: true,
default: () => <div>Mock Alerting Settings</div>,
diff --git a/ui/litellm-dashboard/src/components/settings.tsx b/ui/litellm-dashboard/src/components/settings.tsx
index bd146b188f5..2b9d8dad90b 100644
--- a/ui/litellm-dashboard/src/components/settings.tsx
+++ b/ui/litellm-dashboard/src/components/settings.tsx
@@ -19,7 +19,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import EmailSettings from "./email_settings";
import { Logo } from "@/components/molecules/logo/Logo";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import AlertingSettings from "./alerting/alerting_settings";
import CloudZeroCostTracking from "./CloudZeroCostTracking/CloudZeroCostTracking";
@@ -264,7 +264,7 @@ const Settings: React.FC<SettingsPageProps> = ({ accessToken, userRole, userID,
setCallbackConfigs(data || []);
})
.catch((error) => {
- NotificationsManager.fromBackend("Failed to load callback configs: " + parseErrorMessage(error));
+ toast.fromError("Failed to load callback configs: " + parseErrorMessage(error));
});
}, [accessToken]);
@@ -351,9 +351,7 @@ const Settings: React.FC<SettingsPageProps> = ({ accessToken, userRole, userID,
try {
await setCallbacksCall(accessToken, payload);
- NotificationsManager.success(
- isEdit ? "Callback updated successfully" : `Callback ${callbackName} added successfully`,
- );
+ toast.success(isEdit ? "Callback updated successfully" : `Callback ${callbackName} added successfully`);
if (isEdit) {
setShowEditCallback(false);
@@ -372,7 +370,7 @@ const Settings: React.FC<SettingsPageProps> = ({ accessToken, userRole, userID,
setCallbacks(updatedData.callbacks);
}
} catch (error) {
- NotificationsManager.fromBackend(error);
+ toast.fromError(error);
} finally {
if (isEdit) {
setIsUpdatingCallback(false);
@@ -442,9 +440,9 @@ const Settings: React.FC<SettingsPageProps> = ({ accessToken, userRole, userID,
try {
await setCallbacksCall(accessToken, payload);
} catch (error) {
- NotificationsManager.fromBackend(error);
+ toast.fromError(error);
}
- NotificationsManager.success("Alerts updated successfully");
+ toast.success("Alerts updated successfully");
};
const handleDeleteCallback = (callback: any) => {
@@ -460,7 +458,7 @@ const Settings: React.FC<SettingsPageProps> = ({ accessToken, userRole, userID,
try {
setIsDeletingCallback(true);
await deleteCallback(accessToken, callbackToDelete.name);
- NotificationsManager.success(`Callback ${callbackToDelete.name} deleted successfully`);
+ toast.success(`Callback ${callbackToDelete.name} deleted successfully`);
// Refresh the callbacks list
if (userID && userRole) {
@@ -472,7 +470,7 @@ const Settings: React.FC<SettingsPageProps> = ({ accessToken, userRole, userID,
setCallbackToDelete(null);
} catch (error) {
console.error("Failed to delete callback:", error);
- NotificationsManager.fromBackend(error);
+ toast.fromError(error);
} finally {
setIsDeletingCallback(false);
}
@@ -507,9 +505,9 @@ const Settings: React.FC<SettingsPageProps> = ({ accessToken, userRole, userID,
onTest={async (cb) => {
try {
await serviceHealthCheck(accessToken, cb.name);
- NotificationsManager.success("Health check triggered");
+ toast.success("Health check triggered");
} catch (error) {
- NotificationsManager.fromBackend(parseErrorMessage(error));
+ toast.fromError(parseErrorMessage(error));
}
}}
/>
@@ -590,11 +588,11 @@ const Settings: React.FC<SettingsPageProps> = ({ accessToken, userRole, userID,
onClick={async () => {
try {
await serviceHealthCheck(accessToken, "slack");
- NotificationsManager.success(
+ toast.success(
"Alert test triggered. Test request to slack made - check logs/alerts on slack to verify",
);
} catch (error) {
- NotificationsManager.fromBackend(parseErrorMessage(error));
+ toast.fromError(parseErrorMessage(error));
}
}}
className="mx-2"
diff --git a/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.test.tsx b/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.test.tsx
index eb6fe5f50cd..6c8cdae6deb 100644
--- a/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.test.tsx
+++ b/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.test.tsx
@@ -3,11 +3,7 @@ import { render, screen, act } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import CreatedKeyDisplay from "./CreatedKeyDisplay";
-vi.mock("@/components/molecules/message_manager", () => ({
- default: { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn(), loading: vi.fn(), destroy: vi.fn() },
-}));
-
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
describe("CreatedKeyDisplay", () => {
beforeEach(() => {
@@ -48,7 +44,7 @@ describe("CreatedKeyDisplay", () => {
await user.click(screen.getByRole("button", { name: /copy virtual key/i }));
- expect(MessageManager.success).toHaveBeenCalledWith("Key copied to clipboard");
+ expect(toast.success).toHaveBeenCalledWith("Key copied to clipboard");
});
it("should revert button text back after 2 seconds", async () => {
diff --git a/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.tsx b/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.tsx
index bcca3e698a5..2db90c3129a 100644
--- a/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.tsx
+++ b/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.tsx
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import { CopyToClipboard } from "react-copy-to-clipboard";
import { Button } from "@/components/ui/button";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
interface CreatedKeyDisplayProps {
apiKey: string;
@@ -16,7 +16,7 @@ const CreatedKeyDisplay: React.FC<CreatedKeyDisplayProps> = ({ apiKey }) => {
const handleCopy = () => {
setCopied(true);
- MessageManager.success("Key copied to clipboard");
+ toast.success("Key copied to clipboard");
setTimeout(() => setCopied(false), 2000);
};
diff --git a/ui/litellm-dashboard/src/components/team/AvailableTeamsPanel.tsx b/ui/litellm-dashboard/src/components/team/AvailableTeamsPanel.tsx
index d7768e8376f..432418eae2b 100644
--- a/ui/litellm-dashboard/src/components/team/AvailableTeamsPanel.tsx
+++ b/ui/litellm-dashboard/src/components/team/AvailableTeamsPanel.tsx
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from "react";
import { availableTeamListCall, teamMemberAddCall } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import AvailableTeamsTable from "./AvailableTeamsTable";
import { AvailableTeam } from "./AvailableTeamsTableColumns";
@@ -54,11 +54,11 @@ const AvailableTeamsPanel: React.FC<AvailableTeamsProps> = ({ accessToken, userI
role: "user",
});
- NotificationsManager.success("Successfully joined team");
+ toast.success("Successfully joined team");
setAvailableTeams((teams) => teams.filter((team) => team.team_id !== teamId));
} catch (error) {
console.error("Error joining team:", error);
- NotificationsManager.fromBackend("Failed to join team");
+ toast.fromError("Failed to join team");
}
};
diff --git a/ui/litellm-dashboard/src/components/team/EditMembership.tsx b/ui/litellm-dashboard/src/components/team/EditMembership.tsx
index 362f019aa3b..beeabae310f 100644
--- a/ui/litellm-dashboard/src/components/team/EditMembership.tsx
+++ b/ui/litellm-dashboard/src/components/team/EditMembership.tsx
@@ -98,9 +98,7 @@ const MemberModal = <T extends BaseMember>({
await Promise.resolve(onSubmit(formData));
form.resetFields();
- // NotificationsManager.success(`Successfully ${mode === 'add' ? 'added' : 'updated'} member`);
} catch (error) {
- // NotificationManager.fromBackend('Failed to submit form');
console.error("Form submission error:", error);
} finally {
setIsSubmitting(false);
diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
index a23cf77e00e..9e30104a4f1 100644
--- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
@@ -31,7 +31,7 @@ import {
import { ArrowLeftIcon } from "@heroicons/react/outline";
import { Accordion, AccordionBody, AccordionHeader, Badge, Card, Grid, Text, TextInput, Title } from "@tremor/react";
import { Button, Form, Input, InputNumber, Select, Space, Switch, Tabs, Tag, Tooltip } from "antd";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { CheckIcon, CopyIcon } from "lucide-react";
import React, { useEffect, useMemo, useState } from "react";
import { copyToClipboard as utilCopyToClipboard } from "../../utils/dataUtils";
@@ -59,7 +59,6 @@ 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 { estimateRules, estimateTooltips } from "../templates/estimatedOutputTokens";
import ObjectPermissionsView from "../object_permissions_view";
import NumericalInput from "../shared/numerical_input";
@@ -258,7 +257,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
const response = await teamInfoCall(accessToken, teamId);
setTeamData(response);
} catch (error) {
- NotificationsManager.fromBackend("Failed to load team information");
+ toast.fromError("Failed to load team information");
console.error("Error fetching team info:", error);
} finally {
setLoading(false);
@@ -349,7 +348,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
await teamMemberAddCall(accessToken, teamId, member);
- NotificationsManager.success("Team member added successfully");
+ toast.success("Team member added successfully");
setIsAddMemberModalVisible(false);
form.resetFields();
@@ -368,7 +367,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
errMsg = error.message;
}
- NotificationsManager.fromBackend(errMsg);
+ toast.fromError(errMsg);
console.error("Error adding team member:", error);
}
};
@@ -389,11 +388,11 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
budget_duration: values.budget_duration,
allowed_models: values.allowed_models,
};
- MessageManager.destroy(); // Remove all existing toasts
+ toast.dismiss(); // Remove all existing toasts
await teamMemberUpdateCall(accessToken, teamId, member);
- NotificationsManager.success("Team member updated successfully");
+ toast.success("Team member updated successfully");
setIsEditMemberModalVisible(false);
// Fetch updated team info
@@ -411,9 +410,9 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
}
setIsEditMemberModalVisible(false);
- MessageManager.destroy(); // Remove all existing toasts
+ toast.dismiss(); // Remove all existing toasts
- NotificationsManager.fromBackend(errMsg);
+ toast.fromError(errMsg);
console.error("Error updating team member:", error);
}
};
@@ -430,7 +429,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
try {
await teamMemberDeleteCall(accessToken, teamId, memberToDelete);
- NotificationsManager.success("Team member removed successfully");
+ toast.success("Team member removed successfully");
// Fetch updated team info
const updatedTeamData = await teamInfoCall(accessToken, teamId);
@@ -439,7 +438,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
// Notify parent component of the update
onUpdate(updatedTeamData);
} catch (error) {
- NotificationsManager.fromBackend("Failed to remove team member");
+ toast.fromError("Failed to remove team member");
console.error("Error removing team member:", error);
} finally {
setIsDeleting(false);
@@ -467,7 +466,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
try {
secretManagerSettings = JSON.parse(values.secret_manager_settings);
} catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in secret manager settings");
+ toast.fromError("Invalid JSON in secret manager settings");
return;
}
}
@@ -489,7 +488,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
try {
estimatedOutputTokensPerModel = JSON.parse(trimmedEstimates);
} catch (e) {
- NotificationsManager.fromBackend("Invalid JSON in estimated output tokens per model");
+ toast.fromError("Invalid JSON in estimated output tokens per model");
return;
}
}
@@ -654,7 +653,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
await teamUpdateCall(accessToken, updateData);
queryClient.invalidateQueries({ queryKey: organizationKeys.all });
- NotificationsManager.success("Team settings updated successfully");
+ toast.success("Team settings updated successfully");
setIsEditing(false);
fetchTeamInfo();
} catch (error) {
diff --git a/ui/litellm-dashboard/src/components/team/member_permissions.tsx b/ui/litellm-dashboard/src/components/team/member_permissions.tsx
index 62c7d1f96da..063cdc0bad3 100644
--- a/ui/litellm-dashboard/src/components/team/member_permissions.tsx
+++ b/ui/litellm-dashboard/src/components/team/member_permissions.tsx
@@ -5,7 +5,7 @@ import { Checkbox } from "@/components/ui/checkbox";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { RotateCw, Save } from "lucide-react";
import React, { useEffect, useState } from "react";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getPermissionInfo } from "./permission_definitions";
interface MemberPermissionsProps {
@@ -32,7 +32,7 @@ const MemberPermissions: React.FC<MemberPermissionsProps> = ({ teamId, accessTok
setSelectedPermissions(teamPermissions);
setHasChanges(false);
} catch (error) {
- NotificationsManager.fromBackend("Failed to load permissions");
+ toast.fromError("Failed to load permissions");
console.error("Error fetching permissions:", error);
} finally {
setLoading(false);
@@ -56,10 +56,10 @@ const MemberPermissions: React.FC<MemberPermissionsProps> = ({ teamId, accessTok
if (!accessToken) return;
setSaving(true);
await teamPermissionsUpdateCall(accessToken, teamId, selectedPermissions);
- NotificationsManager.success("Permissions updated successfully");
+ toast.success("Permissions updated successfully");
setHasChanges(false);
} catch (error) {
- NotificationsManager.fromBackend("Failed to update permissions");
+ toast.fromError("Failed to update permissions");
console.error("Error updating permissions:", error);
} finally {
setSaving(false);
diff --git a/ui/litellm-dashboard/src/components/templates/KeyInfoView.handleKeyUpdate.test.tsx b/ui/litellm-dashboard/src/components/templates/KeyInfoView.handleKeyUpdate.test.tsx
index 983c91d87a7..46747d2a0dc 100644
--- a/ui/litellm-dashboard/src/components/templates/KeyInfoView.handleKeyUpdate.test.tsx
+++ b/ui/litellm-dashboard/src/components/templates/KeyInfoView.handleKeyUpdate.test.tsx
@@ -30,16 +30,6 @@ vi.mock("../networking", () => {
};
});
-// Notifications
-vi.mock("../molecules/notifications_manager", () => {
- const Notifications = {
- success: vi.fn(),
- error: vi.fn(),
- fromBackend: vi.fn(),
- };
- return { default: Notifications };
-});
-
// Roles: ensure 'Admin' has write access and include all role helper functions
vi.mock("../../utils/roles", async (importOriginal) => {
const actual = await importOriginal<typeof import("../../utils/roles")>();
diff --git a/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx b/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
index 87a6d68ebc4..b510ebbb447 100644
--- a/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
@@ -35,7 +35,7 @@ import { KeyResponse } from "../key_team_helpers/key_list";
import MCPServerSelector from "../mcp_server_management/MCPServerSelector";
import { NO_MCP_SERVERS_SENTINEL } from "../mcp_tools/constants";
import MCPToolPermissions from "../mcp_server_management/MCPToolPermissions";
-import NotificationsManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getPromptsList, modelAvailableCall, tagListCall } from "../networking";
import { fetchTeamModels } from "../organisms/create_key_button";
import NumericalInput from "../shared/numerical_input";
@@ -205,7 +205,7 @@ export function KeyEditView({
const response = await tagListCall(accessToken);
setTagsList(response);
} catch (error) {
- NotificationsManager.fromBackend("Error fetching tags: " + error);
+ toast.fromError("Error fetching tags: " + error);
}
};
fetchTags();
diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx
index 99981edb1c8..c57a76a878a 100644
--- a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx
@@ -24,7 +24,7 @@ import { hasRouterSettings } from "../common_components/routerSettingsPayload";
import { extractLoggingSettings, formatMetadataForDisplay, stripTagsFromMetadata } from "../key_info_utils";
import { KeyResponse } from "../key_team_helpers/key_list";
import LoggingSettingsView from "../logging_settings_view";
-import NotificationManager from "../molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { getPolicyInfoWithGuardrails, keyDeleteCall, keyUpdateCall } from "../networking";
import { useResetKeySpend } from "@/app/(dashboard)/hooks/keys/useResetKeySpend";
import { useSetKeyBlockedState } from "@/app/(dashboard)/hooks/keys/useSetKeyBlockedState";
@@ -225,9 +225,7 @@ export default function KeyInfoView({
(toolsetId) => !(allMcpToolsets ?? []).some((toolset) => toolset.toolset_id === toolsetId),
);
if (unresolvableSelection && Object.keys(mcpEntitlement.mcp_tool_permissions).length > 0) {
- NotificationManager.error(
- "MCP server or toolset list is unavailable, so MCP permissions cannot be saved yet. Retry.",
- );
+ toast.error("MCP server or toolset list is unavailable, so MCP permissions cannot be saved yet. Retry.");
return;
}
formValues.object_permission = {
@@ -277,7 +275,7 @@ export default function KeyInfoView({
};
} catch (error) {
console.error("Error parsing metadata JSON:", error);
- NotificationManager.error("Invalid metadata JSON");
+ toast.error("Invalid metadata JSON");
return;
}
} else {
@@ -323,11 +321,11 @@ export default function KeyInfoView({
if (onKeyDataUpdate) {
onKeyDataUpdate(newKeyValues);
}
- NotificationManager.success("Key updated successfully");
+ toast.success("Key updated successfully");
setIsEditing(false);
// Refresh key data here if needed
} catch (error) {
- NotificationManager.fromBackend(parseErrorMessage(error));
+ toast.fromError(parseErrorMessage(error));
console.error("Error updating key:", error);
}
};
@@ -337,7 +335,7 @@ export default function KeyInfoView({
setDeleteLoading(true);
if (!accessToken) return;
await keyDeleteCall(accessToken as string, currentKeyData.token || currentKeyData.token_id);
- NotificationManager.success("Key deleted successfully");
+ toast.success("Key deleted successfully");
await queryClient.invalidateQueries({ queryKey: keyKeys.lists() });
if (onDelete) {
onDelete();
@@ -345,7 +343,7 @@ export default function KeyInfoView({
onClose();
} catch (error) {
console.error("Error deleting the key:", error);
- NotificationManager.fromBackend(error);
+ toast.fromError(error);
} finally {
setDeleteLoading(false);
setIsDeleteModalOpen(false);
@@ -422,11 +420,11 @@ export default function KeyInfoView({
if (onKeyDataUpdate) {
onKeyDataUpdate({ spend: 0 });
}
- NotificationManager.success("Key spend reset to $0");
+ toast.success("Key spend reset to $0");
setIsResetSpendModalOpen(false);
},
onError: (error) => {
- NotificationManager.fromBackend(parseErrorMessage(error));
+ toast.fromError(parseErrorMessage(error));
console.error("Error resetting key spend:", error);
},
});
@@ -444,11 +442,11 @@ export default function KeyInfoView({
if (onKeyDataUpdate) {
onKeyDataUpdate({ blocked });
}
- NotificationManager.success(blocked ? "Key blocked" : "Key unblocked");
+ toast.success(blocked ? "Key blocked" : "Key unblocked");
setIsBlockModalOpen(false);
},
onError: (error) => {
- NotificationManager.fromBackend(parseErrorMessage(error));
+ toast.fromError(parseErrorMessage(error));
console.error("Error updating key blocked state:", error);
},
},
diff --git a/ui/litellm-dashboard/src/components/update_model_credentials_modal.test.tsx b/ui/litellm-dashboard/src/components/update_model_credentials_modal.test.tsx
index ab18ae71203..b21b768543c 100644
--- a/ui/litellm-dashboard/src/components/update_model_credentials_modal.test.tsx
+++ b/ui/litellm-dashboard/src/components/update_model_credentials_modal.test.tsx
@@ -12,10 +12,6 @@ vi.mock("./networking", async () => {
};
});
-vi.mock("./molecules/notifications_manager", () => ({
- default: { success: vi.fn(), error: vi.fn(), info: vi.fn(), fromBackend: vi.fn() },
-}));
-
const mockModelPatchUpdateCall = vi.mocked(networking.modelPatchUpdateCall);
beforeAll(() => {
diff --git a/ui/litellm-dashboard/src/components/update_model_credentials_modal.tsx b/ui/litellm-dashboard/src/components/update_model_credentials_modal.tsx
index b98f0ec3242..d88efd64bc9 100644
--- a/ui/litellm-dashboard/src/components/update_model_credentials_modal.tsx
+++ b/ui/litellm-dashboard/src/components/update_model_credentials_modal.tsx
@@ -1,7 +1,7 @@
import { Alert, Button, Form, Input, Modal, Typography } from "antd";
import { useState } from "react";
import { modelPatchUpdateCall } from "./networking";
-import NotificationsManager from "./molecules/notifications_manager";
+import { toast } from "@/lib/toast";
const { Text } = Typography;
@@ -31,7 +31,7 @@ export default function UpdateModelCredentialsModal({
const handleSubmit = async (values: { api_key?: string }) => {
const apiKey = values.api_key?.trim();
if (!apiKey) {
- NotificationsManager.fromBackend("Enter a new API key");
+ toast.fromError("Enter a new API key");
return;
}
setIsSaving(true);
@@ -41,13 +41,13 @@ export default function UpdateModelCredentialsModal({
{ litellm_params: { api_key: apiKey }, model_info: { id: modelId } },
modelId,
);
- NotificationsManager.success("API key updated");
+ toast.success("API key updated");
form.resetFields();
onUpdated();
onCancel();
} catch (error) {
console.error("Error updating API key:", error);
- NotificationsManager.fromBackend("Failed to update API key");
+ toast.fromError("Failed to update API key");
} finally {
setIsSaving(false);
}
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/InputCard.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/InputCard.tsx
index e538e13ec7a..5f4c623fae1 100644
--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/InputCard.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/InputCard.tsx
@@ -4,7 +4,7 @@
*/
import { useState } from "react";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { ParsedMessage } from "./prettyMessagesTypes";
import { SectionHeader } from "./SectionHeader";
import { CollapsibleMessage } from "./CollapsibleMessage";
@@ -33,7 +33,7 @@ export function InputCard({ messages, promptTokens, inputCost }: InputCardProps)
const handleCopy = () => {
const content = lastMessage?.content || "";
navigator.clipboard.writeText(content);
- MessageManager.success("Input copied");
+ toast.success("Input copied");
};
return (
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/OutputCard.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/OutputCard.tsx
index 2b7f26a63e4..7d0ec62ffe2 100644
--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/OutputCard.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/OutputCard.tsx
@@ -4,7 +4,7 @@
*/
import { useState } from "react";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { COLOR_BORDER } from "./constants";
import { ParsedMessage } from "./prettyMessagesTypes";
import { SectionHeader } from "./SectionHeader";
@@ -23,7 +23,7 @@ export function OutputCard({ message, completionTokens, outputCost }: OutputCard
if (!message) return;
navigator.clipboard.writeText(message.content || "");
- MessageManager.success("Output copied");
+ toast.success("Output copied");
};
return (
diff --git a/ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.test.tsx b/ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.test.tsx
index ae814c4f25c..f003a2c36d4 100644
--- a/ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.test.tsx
+++ b/ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.test.tsx
@@ -3,7 +3,7 @@ import { renderHook, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useDeletePolicyAttachment } from "./useDeletePolicyAttachment";
import { deletePolicyAttachmentCall } from "@/components/networking";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
import { vi, describe, beforeEach, it, expect } from "vitest";
// Mock dependencies
@@ -11,13 +11,6 @@ vi.mock("@/components/networking", () => ({
deletePolicyAttachmentCall: vi.fn(),
}));
-vi.mock("@/components/molecules/message_manager", () => ({
- default: {
- success: vi.fn(),
- error: vi.fn(),
- },
-}));
-
describe("useDeletePolicyAttachment", () => {
let queryClient: QueryClient;
@@ -50,7 +43,7 @@ describe("useDeletePolicyAttachment", () => {
});
expect(deletePolicyAttachmentCall).toHaveBeenCalledWith("test-token", "attachment-1");
- expect(MessageManager.success).toHaveBeenCalledWith("Attachment deleted successfully");
+ expect(toast.success).toHaveBeenCalledWith("Attachment deleted successfully");
expect(mockOnSuccess).toHaveBeenCalled();
});
@@ -75,7 +68,7 @@ describe("useDeletePolicyAttachment", () => {
});
expect(deletePolicyAttachmentCall).toHaveBeenCalledWith("test-token", "attachment-1");
- expect(MessageManager.error).toHaveBeenCalledWith("Failed to delete attachment");
+ expect(toast.error).toHaveBeenCalledWith("Failed to delete attachment");
expect(mockOnError).toHaveBeenCalledWith(error);
});
});
diff --git a/ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.ts b/ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.ts
index 456dc3beaab..93e6931215d 100644
--- a/ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.ts
+++ b/ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.ts
@@ -1,6 +1,6 @@
import { useMutation } from "@tanstack/react-query";
import { deletePolicyAttachmentCall } from "@/components/networking";
-import MessageManager from "@/components/molecules/message_manager";
+import { toast } from "@/lib/toast";
interface UseDeletePolicyAttachmentProps {
accessToken: string | null;
@@ -17,14 +17,14 @@ export const useDeletePolicyAttachment = ({ accessToken, onSuccess, onError }: U
return deletePolicyAttachmentCall(accessToken, attachmentId);
},
onSuccess: () => {
- MessageManager.success("Attachment deleted successfully");
+ toast.success("Attachment deleted successfully");
if (onSuccess) {
onSuccess();
}
},
onError: (error) => {
console.error("Error deleting attachment:", error);
- MessageManager.error("Failed to delete attachment");
+ toast.error("Failed to delete attachment");
if (onError) {
onError(error);
}
diff --git a/ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.test.tsx b/ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.test.tsx
index 71a6881cd03..2e809cfd728 100644
--- a/ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.test.tsx
+++ b/ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.test.tsx
@@ -13,10 +13,6 @@ vi.mock("@/components/networking", () => ({
serverRootPath: "",
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), error: vi.fn() },
-}));
-
const FLOW_STATE_KEY = "litellm-mcp-oauth-flow-state";
const RESULT_KEY = "litellm-mcp-oauth-result";
diff --git a/ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.tsx b/ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.tsx
index 6a7b201113e..2d6f0344eb9 100644
--- a/ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.tsx
+++ b/ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.tsx
@@ -1,7 +1,7 @@
"use client";
import { useCallback, useEffect, useRef, useState } from "react";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import {
buildMcpOAuthAuthorizeUrl,
cacheTemporaryMcpServer,
@@ -126,7 +126,7 @@ export const useMcpOAuthFlow = ({
if (!accessToken) {
setError("Missing admin token");
- NotificationsManager.error("Access token missing. Please re-authenticate and try again.");
+ toast.error("Access token missing. Please re-authenticate and try again.");
return;
}
@@ -134,7 +134,7 @@ export const useMcpOAuthFlow = ({
if (!temporaryPayload || !temporaryPayload.url || !temporaryPayload.transport) {
const message = "Please complete server URL and transport before starting OAuth.";
setError(message);
- NotificationsManager.error(message);
+ toast.error(message);
return;
}
try {
@@ -221,7 +221,7 @@ export const useMcpOAuthFlow = ({
setStatus("error");
const message = extractErrorMessage(err);
setError(message);
- NotificationsManager.error(message);
+ toast.error(message);
}
}, [accessToken, getCredentials, getTemporaryPayload, onBeforeRedirect]);
@@ -263,7 +263,7 @@ export const useMcpOAuthFlow = ({
processingRef.current = false;
setError("Failed to resume OAuth flow. Please retry.");
setStatus("error");
- NotificationsManager.error("Failed to resume OAuth flow. Please retry.");
+ toast.error("Failed to resume OAuth flow. Please retry.");
return;
}
@@ -330,7 +330,7 @@ export const useMcpOAuthFlow = ({
setTokenResponse(token);
setStatus("success");
setError(null);
- NotificationsManager.success("OAuth token retrieved successfully");
+ toast.success("OAuth token retrieved successfully");
} catch (err) {
if (resetVersion !== resetVersionRef.current) {
return;
@@ -338,7 +338,7 @@ export const useMcpOAuthFlow = ({
const message = extractErrorMessage(err);
setError(message);
setStatus("error");
- NotificationsManager.error(message);
+ toast.error(message);
} finally {
if (resetVersion === resetVersionRef.current) {
clearStoredFlow();
diff --git a/ui/litellm-dashboard/src/hooks/useToolsOAuthFlow.test.tsx b/ui/litellm-dashboard/src/hooks/useToolsOAuthFlow.test.tsx
index b7c65add47c..d8d211f3017 100644
--- a/ui/litellm-dashboard/src/hooks/useToolsOAuthFlow.test.tsx
+++ b/ui/litellm-dashboard/src/hooks/useToolsOAuthFlow.test.tsx
@@ -11,10 +11,6 @@ vi.mock("@/components/networking", () => ({
serverRootPath: "",
}));
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: { success: vi.fn(), error: vi.fn() },
-}));
-
vi.mock("@/utils/pkce", () => ({
generateCodeVerifier: () => "verifier-1",
generateCodeChallenge: async () => "challenge-1",
diff --git a/ui/litellm-dashboard/src/hooks/useToolsOAuthFlow.tsx b/ui/litellm-dashboard/src/hooks/useToolsOAuthFlow.tsx
index 2cfd6e7737c..3d5aee972ea 100644
--- a/ui/litellm-dashboard/src/hooks/useToolsOAuthFlow.tsx
+++ b/ui/litellm-dashboard/src/hooks/useToolsOAuthFlow.tsx
@@ -15,7 +15,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { buildMcpOAuthAuthorizeUrl, exchangeMcpOAuthToken, registerMcpOAuthClient } from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { extractErrorMessage } from "@/utils/errorUtils";
import { generateCodeChallenge, generateCodeVerifier } from "@/utils/pkce";
import { getSecureItem, setSecureItem } from "@/utils/secureStorage";
@@ -139,7 +139,7 @@ export const useToolsOAuthFlow = ({
const msg = extractErrorMessage(err);
setError(msg);
setStatus("error");
- NotificationsManager.error(msg);
+ toast.error(msg);
}
}, [accessToken, serverId, serverAlias, scopes, preClientId, gatewayMintsClient]);
@@ -218,13 +218,13 @@ export const useToolsOAuthFlow = ({
setStatus("success");
setError(null);
- NotificationsManager.success("Connected successfully");
+ toast.success("Connected successfully");
onSuccessRef.current(token.access_token);
} catch (err) {
const msg = extractErrorMessage(err);
setError(msg);
setStatus("error");
- NotificationsManager.error(msg);
+ toast.error(msg);
} finally {
clearStorage(FLOW_STATE_KEY);
setTimeout(() => {
diff --git a/ui/litellm-dashboard/src/hooks/useUserMcpOAuthFlow.tsx b/ui/litellm-dashboard/src/hooks/useUserMcpOAuthFlow.tsx
index 13bad227297..d7684a76f05 100644
--- a/ui/litellm-dashboard/src/hooks/useUserMcpOAuthFlow.tsx
+++ b/ui/litellm-dashboard/src/hooks/useUserMcpOAuthFlow.tsx
@@ -19,7 +19,7 @@ import {
registerMcpOAuthClient,
storeMCPOAuthUserCredential,
} from "@/components/networking";
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
import { extractErrorMessage } from "@/utils/errorUtils";
import { generateCodeChallenge, generateCodeVerifier } from "@/utils/pkce";
import { getSecureItem, setSecureItem } from "@/utils/secureStorage";
@@ -140,7 +140,7 @@ export const useUserMcpOAuthFlow = ({
const msg = extractErrorMessage(err);
setError(msg);
setStatus("error");
- NotificationsManager.error(msg);
+ toast.error(msg);
}
}, [accessToken, serverId, serverAlias, scopes, preClientId]);
@@ -221,13 +221,13 @@ export const useUserMcpOAuthFlow = ({
setStatus("success");
setError(null);
- NotificationsManager.success("Connected successfully");
+ toast.success("Connected successfully");
onSuccess();
} catch (err) {
const msg = extractErrorMessage(err);
setError(msg);
setStatus("error");
- NotificationsManager.error(msg);
+ toast.error(msg);
} finally {
clearStorage(FLOW_STATE_KEY);
setTimeout(() => {
diff --git a/ui/litellm-dashboard/src/lib/toast.test.ts b/ui/litellm-dashboard/src/lib/toast.test.ts
index fb22c9039bf..0afd0ec2cc4 100644
--- a/ui/litellm-dashboard/src/lib/toast.test.ts
+++ b/ui/litellm-dashboard/src/lib/toast.test.ts
@@ -10,6 +10,7 @@ const sonner = vi.hoisted(() => ({
}));
vi.mock("sonner", () => ({ toast: sonner }));
+vi.unmock("@/lib/toast");
import { toast } from "./toast";
diff --git a/ui/litellm-dashboard/src/utils/dataUtils.test.ts b/ui/litellm-dashboard/src/utils/dataUtils.test.ts
index f9e2be81163..d975a4a73f4 100644
--- a/ui/litellm-dashboard/src/utils/dataUtils.test.ts
+++ b/ui/litellm-dashboard/src/utils/dataUtils.test.ts
@@ -1,17 +1,9 @@
import { describe, it, expect, beforeEach, vi, afterEach } from "vitest";
import { copyToClipboard, formatNumberWithCommas, getSpendString, updateExistingKeys } from "./dataUtils";
-// Mock NotificationsManager
-vi.mock("../../src/components/molecules/notifications_manager", () => ({
- default: {
- success: vi.fn(),
- fromBackend: vi.fn(),
- },
-}));
-
// Import the mocked module
-import NotificationsManager from "../components/molecules/notifications_manager";
-const mockNotificationsManager = vi.mocked(NotificationsManager);
+import { toast } from "@/lib/toast";
+const mockToast = vi.mocked(toast);
describe("dataUtils", () => {
beforeEach(() => {
@@ -136,14 +128,14 @@ describe("dataUtils", () => {
const result = await copyToClipboard("test text");
expect(navigator.clipboard.writeText).toHaveBeenCalledWith("test text");
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Copied to clipboard");
+ expect(mockToast.success).toHaveBeenCalledWith("Copied to clipboard");
expect(result).toBe(true);
});
it("should use custom message when provided", async () => {
await copyToClipboard("test text", "Custom message");
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Custom message");
+ expect(mockToast.success).toHaveBeenCalledWith("Custom message");
});
it("should return false for null/undefined text", async () => {
@@ -175,7 +167,7 @@ describe("dataUtils", () => {
expect(navigator.clipboard.writeText).toHaveBeenCalledWith("test text");
expect(document.execCommand).toHaveBeenCalledWith("copy");
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Copied to clipboard");
+ expect(mockToast.success).toHaveBeenCalledWith("Copied to clipboard");
expect(result).toBe(true);
});
});
@@ -208,7 +200,7 @@ describe("dataUtils", () => {
expect(document.createElement).toHaveBeenCalledWith("textarea");
expect(document.execCommand).toHaveBeenCalledWith("copy");
- expect(mockNotificationsManager.success).toHaveBeenCalledWith("Copied to clipboard");
+ expect(mockToast.success).toHaveBeenCalledWith("Copied to clipboard");
expect(result).toBe(true);
});
@@ -241,7 +233,7 @@ describe("dataUtils", () => {
const result = await copyToClipboard("test text");
expect(document.execCommand).toHaveBeenCalledWith("copy");
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith("Failed to copy to clipboard");
+ expect(mockToast.fromError).toHaveBeenCalledWith("Failed to copy to clipboard");
expect(result).toBe(false);
});
@@ -252,7 +244,7 @@ describe("dataUtils", () => {
const result = await copyToClipboard("test text");
- expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith("Failed to copy to clipboard");
+ expect(mockToast.fromError).toHaveBeenCalledWith("Failed to copy to clipboard");
expect(result).toBe(false);
});
diff --git a/ui/litellm-dashboard/src/utils/dataUtils.ts b/ui/litellm-dashboard/src/utils/dataUtils.ts
index 0f8d11a178e..514d13bf9f4 100644
--- a/ui/litellm-dashboard/src/utils/dataUtils.ts
+++ b/ui/litellm-dashboard/src/utils/dataUtils.ts
@@ -1,4 +1,4 @@
-import NotificationsManager from "@/components/molecules/notifications_manager";
+import { toast } from "@/lib/toast";
export function updateExistingKeys<Source extends object>(target: Source, source: object): Source {
const clonedTarget = structuredClone(target);
@@ -73,7 +73,7 @@ export const copyToClipboard = async (
if (navigator && navigator.clipboard && navigator.clipboard.writeText) {
try {
await navigator.clipboard.writeText(text);
- NotificationsManager.success(messageText);
+ toast.success(messageText);
return true;
} catch (err) {
console.error("Clipboard API failed: ", err);
@@ -106,13 +106,13 @@ const fallbackCopyToClipboard = (text: string, messageText: string): boolean =>
document.body.removeChild(textArea);
if (successful) {
- NotificationsManager.success(messageText);
+ toast.success(messageText);
return true;
} else {
throw new Error("execCommand failed");
}
} catch (err) {
- NotificationsManager.fromBackend("Failed to copy to clipboard");
+ toast.fromError("Failed to copy to clipboard");
console.error("Failed to copy: ", err);
return false;
}
diff --git a/ui/litellm-dashboard/tests/setupTests.ts b/ui/litellm-dashboard/tests/setupTests.ts
index 1ff0bed9862..f6989bf4ccc 100644
--- a/ui/litellm-dashboard/tests/setupTests.ts
+++ b/ui/litellm-dashboard/tests/setupTests.ts
@@ -88,17 +88,15 @@ const ensureTestLocalStorage = () => {
ensureTestLocalStorage();
-// Global mock for NotificationManager to prevent React rendering issues in tests
-// This avoids "window is not defined" errors when notifications try to render
-// after test environment is torn down
-vi.mock("@/components/molecules/notifications_manager", () => ({
- default: {
+// Global mock so every test can assert on toast calls; toast.test.ts opts back in with vi.unmock
+vi.mock("@/lib/toast", () => ({
+ toast: {
success: vi.fn(),
- fromBackend: vi.fn(),
- error: vi.fn(),
- warning: vi.fn(),
info: vi.fn(),
- clear: vi.fn(),
+ warning: vi.fn(),
+ error: vi.fn(),
+ fromError: vi.fn(),
+ dismiss: vi.fn(),
},
}));