Skip to content

Commit f7a3af5

Browse files
authored
new notifications (#13813)
1 parent 6f6fd0d commit f7a3af5

File tree

71 files changed

+462
-442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+462
-442
lines changed

ui/litellm-dashboard/src/components/SCIM.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
PlusCircleOutlined
2222
} from "@ant-design/icons";
2323
import { parseErrorMessage } from "./shared/errorUtils";
24-
import NotificationManager from "./molecules/notifications_manager";
24+
import NotificationsManager from "./molecules/notifications_manager";
2525

2626
interface SCIMConfigProps {
2727
accessToken: string | null;
@@ -52,7 +52,7 @@ const SCIMConfig: React.FC<SCIMConfigProps> = ({ accessToken, userID, proxySetti
5252

5353
const handleCreateSCIMToken = async (values: any) => {
5454
if (!accessToken || !userID) {
55-
NotificationManager.fromBackend("You need to be logged in to create a SCIM token");
55+
NotificationsManager.fromBackend("You need to be logged in to create a SCIM token");
5656
return;
5757
}
5858

@@ -68,10 +68,10 @@ const SCIMConfig: React.FC<SCIMConfigProps> = ({ accessToken, userID, proxySetti
6868

6969
const response = await keyCreateCall(accessToken, userID, formData);
7070
setTokenData(response);
71-
message.success("SCIM token created successfully");
71+
NotificationsManager.success("SCIM token created successfully");
7272
} catch (error: any) {
7373
console.error("Error creating SCIM token:", error);
74-
NotificationManager.fromBackend("Failed to create SCIM token: " + parseErrorMessage(error));
74+
NotificationsManager.fromBackend("Failed to create SCIM token: " + parseErrorMessage(error));
7575
} finally {
7676
setIsCreatingToken(false);
7777
}
@@ -112,7 +112,7 @@ const SCIMConfig: React.FC<SCIMConfigProps> = ({ accessToken, userID, proxySetti
112112
/>
113113
<CopyToClipboard
114114
text={scimBaseUrl}
115-
onCopy={() => message.success("URL copied to clipboard")}
115+
onCopy={() => NotificationsManager.success("URL copied to clipboard")}
116116
>
117117
<TremorButton variant="primary" className="ml-2 flex items-center">
118118
<CopyOutlined className="h-4 w-4 mr-1" />
@@ -183,7 +183,7 @@ const SCIMConfig: React.FC<SCIMConfigProps> = ({ accessToken, userID, proxySetti
183183
/>
184184
<CopyToClipboard
185185
text={tokenData.key}
186-
onCopy={() => message.success("Token copied to clipboard")}
186+
onCopy={() => NotificationsManager.success("Token copied to clipboard")}
187187
>
188188
<TremorButton variant="primary" className="flex items-center">
189189
<CopyOutlined className="h-4 w-4 mr-1" />

ui/litellm-dashboard/src/components/SSOModals.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
22
import { Modal, Form, Input, Button as Button2, Select, message } from "antd";
33
import { Text, TextInput } from "@tremor/react";
44
import { getSSOSettings, updateSSOSettings } from "./networking";
5-
import NotificationManager from "./molecules/notifications_manager";
5+
import NotificationsManager from "./molecules/notifications_manager";
66

77
interface SSOModalsProps {
88
isAddSSOModalVisible: boolean;
@@ -162,7 +162,7 @@ const SSOModals: React.FC<SSOModalsProps> = ({
162162
// Enhanced form submission handler
163163
const handleFormSubmit = async (formValues: Record<string, any>) => {
164164
if (!accessToken) {
165-
NotificationManager.fromBackend("No access token available");
165+
NotificationsManager.fromBackend("No access token available");
166166
return;
167167
}
168168

@@ -174,14 +174,14 @@ const SSOModals: React.FC<SSOModalsProps> = ({
174174
handleShowInstructions(formValues);
175175
} catch (error) {
176176
console.error("Failed to save SSO settings:", error);
177-
NotificationManager.fromBackend("Failed to save SSO settings");
177+
NotificationsManager.fromBackend("Failed to save SSO settings");
178178
}
179179
};
180180

181181
// Handle clearing SSO settings
182182
const handleClearSSO = async () => {
183183
if (!accessToken) {
184-
NotificationManager.fromBackend("No access token available");
184+
NotificationsManager.fromBackend("No access token available");
185185
return;
186186
}
187187

@@ -214,10 +214,10 @@ const SSOModals: React.FC<SSOModalsProps> = ({
214214
// Close the main SSO modal and trigger refresh
215215
handleAddSSOOk();
216216

217-
message.success("SSO settings cleared successfully");
217+
NotificationsManager.success("SSO settings cleared successfully");
218218
} catch (error) {
219219
console.error("Failed to clear SSO settings:", error);
220-
NotificationManager.fromBackend("Failed to clear SSO settings");
220+
NotificationsManager.fromBackend("Failed to clear SSO settings");
221221
}
222222
};
223223

ui/litellm-dashboard/src/components/TeamSSOSettings.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Typography, Spin, message, Switch, Select, Form } from "antd";
44
import { getDefaultTeamSettings, updateDefaultTeamSettings, modelAvailableCall } from "./networking";
55
import BudgetDurationDropdown, { getBudgetDurationLabel } from "./common_components/budget_duration_dropdown";
66
import { getModelDisplayName } from "./key_team_helpers/fetch_available_models_team_key";
7-
import NotificationManager from "./molecules/notifications_manager";
7+
import NotificationsManager from "./molecules/notifications_manager";
88

99
interface TeamSSOSettingsProps {
1010
accessToken: string | null;
@@ -48,7 +48,7 @@ const TeamSSOSettings: React.FC<TeamSSOSettingsProps> = ({ accessToken, userID,
4848
}
4949
} catch (error) {
5050
console.error("Error fetching team SSO settings:", error);
51-
NotificationManager.fromBackend("Failed to fetch team settings");
51+
NotificationsManager.fromBackend("Failed to fetch team settings");
5252
} finally {
5353
setLoading(false);
5454
}
@@ -65,10 +65,10 @@ const TeamSSOSettings: React.FC<TeamSSOSettingsProps> = ({ accessToken, userID,
6565
const updatedSettings = await updateDefaultTeamSettings(accessToken, editedValues);
6666
setSettings({...settings, values: updatedSettings.settings});
6767
setIsEditing(false);
68-
message.success("Default team settings updated successfully");
68+
NotificationsManager.success("Default team settings updated successfully");
6969
} catch (error) {
7070
console.error("Error updating team settings:", error);
71-
NotificationManager.fromBackend("Failed to update team settings");
71+
NotificationsManager.fromBackend("Failed to update team settings");
7272
} finally {
7373
setSaving(false);
7474
}

ui/litellm-dashboard/src/components/add_model/model_connection_test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Typography, Space, Button, Divider, message } from 'antd';
33
import { WarningOutlined, InfoCircleOutlined, CopyOutlined } from '@ant-design/icons';
44
import { testConnectionRequest } from "../networking";
55
import { prepareModelAddRequest } from "./handle_add_model_submit";
6-
6+
import NotificationsManager from '../molecules/notifications_manager';
77
const { Text } = Typography;
88

99
interface ModelConnectionTestProps {
@@ -59,7 +59,7 @@ const ModelConnectionTest: React.FC<ModelConnectionTestProps> = ({
5959

6060
const response = await testConnectionRequest(accessToken, litellmParamsObj, modelInfoObj?.mode);
6161
if (response.status === "success") {
62-
message.success("Connection test successful!");
62+
NotificationsManager.success("Connection test successful!");
6363
setError(null);
6464
setIsSuccess(true);
6565
} else {
@@ -231,7 +231,7 @@ ${formattedBody}
231231
icon={<CopyOutlined />}
232232
onClick={() => {
233233
navigator.clipboard.writeText(curlCommand || '');
234-
message.success('Copied to clipboard');
234+
NotificationsManager.success('Copied to clipboard');
235235
}}
236236
>
237237
Copy to Clipboard

ui/litellm-dashboard/src/components/add_pass_through.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { list } from "postcss";
2828
import KeyValueInput from "./key_value_input";
2929
import { passThroughItem } from "./pass_through_settings";
3030
import RoutePreview from "./route_preview";
31-
import NotificationManager from "./molecules/notifications_manager";
31+
import NotificationsManager from "./molecules/notifications_manager";
3232
const { Option } = Select2;
3333

3434
interface AddFallbacksProps {
@@ -81,22 +81,22 @@ const AddPassThroughEndpoint: React.FC<AddFallbacksProps> = ({
8181
const updatedPassThroughSettings = [...passThroughItems, createdEndpoint]
8282
setPassThroughItems(updatedPassThroughSettings)
8383

84-
message.success("Pass-through endpoint created successfully");
84+
NotificationsManager.success("Pass-through endpoint created successfully");
8585
form.resetFields();
8686
setPathValue("");
8787
setTargetValue("");
8888
setIncludeSubpath(true);
8989
setIsModalVisible(false);
9090
} catch (error) {
91-
NotificationManager.fromBackend("Error creating pass-through endpoint: " + error);
91+
NotificationsManager.fromBackend("Error creating pass-through endpoint: " + error);
9292
} finally {
9393
setIsLoading(false);
9494
}
9595
};
9696

9797
const copyToClipboard = (text: string) => {
9898
navigator.clipboard.writeText(text);
99-
message.success('Copied to clipboard!');
99+
NotificationsManager.success('Copied to clipboard!');
100100
};
101101

102102

ui/litellm-dashboard/src/components/admins.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import { ssoProviderConfigs } from './SSOModals';
4646
import SCIMConfig from "./SCIM";
4747
import UIAccessControlForm from "./UIAccessControlForm";
4848
import UsefulLinksManagement from "./useful_links_management";
49-
import NotificationManager from "./molecules/notifications_manager";
49+
import NotificationsManager from "./molecules/notifications_manager";
5050

5151
interface AdminPanelProps {
5252
searchParams: any;
@@ -151,7 +151,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
151151
const handleShowAllowedIPs = async () => {
152152
try {
153153
if (premiumUser !== true) {
154-
NotificationManager.fromBackend(
154+
NotificationsManager.fromBackend(
155155
"This feature is only available for premium users. Please upgrade your account."
156156
)
157157
return
@@ -164,7 +164,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
164164
}
165165
} catch (error) {
166166
console.error("Error fetching allowed IPs:", error);
167-
NotificationManager.fromBackend(`Failed to fetch allowed IPs ${error}`);
167+
NotificationsManager.fromBackend(`Failed to fetch allowed IPs ${error}`);
168168
setAllowedIPs([all_ip_address_allowed]);
169169
} finally {
170170
if (premiumUser === true) {
@@ -180,11 +180,11 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
180180
// Fetch the updated list of IPs
181181
const updatedIPs = await getAllowedIPs(accessToken);
182182
setAllowedIPs(updatedIPs);
183-
message.success('IP address added successfully');
183+
NotificationsManager.success('IP address added successfully');
184184
}
185185
} catch (error) {
186186
console.error("Error adding IP:", error);
187-
NotificationManager.fromBackend(`Failed to add IP address ${error}`);
187+
NotificationsManager.fromBackend(`Failed to add IP address ${error}`);
188188
} finally {
189189
setIsAddIPModalVisible(false);
190190
}
@@ -202,10 +202,10 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
202202
// Fetch the updated list of IPs
203203
const updatedIPs = await getAllowedIPs(accessToken);
204204
setAllowedIPs(updatedIPs.length > 0 ? updatedIPs : [all_ip_address_allowed]);
205-
message.success('IP address deleted successfully');
205+
NotificationsManager.success('IP address deleted successfully');
206206
} catch (error) {
207207
console.error("Error deleting IP:", error);
208-
NotificationManager.fromBackend(`Failed to delete IP address ${error}`);
208+
NotificationsManager.fromBackend(`Failed to delete IP address ${error}`);
209209
} finally {
210210
setIsDeleteIPModalVisible(false);
211211
setIPToDelete(null);
@@ -426,7 +426,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
426426
const handleMemberUpdate = async (formValues: Record<string, any>) => {
427427
try {
428428
if (accessToken != null && admins != null) {
429-
message.info("Making API Call");
429+
NotificationsManager.info("Making API Call");
430430
const response: any = await userUpdateUserCall(
431431
accessToken,
432432
formValues,
@@ -447,7 +447,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
447447
// If new user is found, update it
448448
setAdmins(admins); // Set the new state
449449
}
450-
message.success("Refresh tab to see updated user role");
450+
NotificationsManager.success("Refresh tab to see updated user role");
451451
setIsUpdateModalModalVisible(false);
452452
}
453453
} catch (error) {
@@ -458,7 +458,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
458458
const handleMemberCreate = async (formValues: Record<string, any>) => {
459459
try {
460460
if (accessToken != null && admins != null) {
461-
message.info("Making API Call");
461+
NotificationsManager.info("Making API Call");
462462
const response: any = await userUpdateUserCall(
463463
accessToken,
464464
formValues,
@@ -497,7 +497,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
497497
const handleAdminCreate = async (formValues: Record<string, any>) => {
498498
try {
499499
if (accessToken != null && admins != null) {
500-
message.info("Making API Call");
500+
NotificationsManager.info("Making API Call");
501501
const user_role: Member = {
502502
role: "user",
503503
user_email: formValues.user_email,
@@ -565,7 +565,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
565565
<div>
566566
<Button
567567
style={{ width: '150px' }}
568-
onClick={() => premiumUser === true ? setIsAddSSOModalVisible(true) : NotificationManager.fromBackend("Only premium users can add SSO")}
568+
onClick={() => premiumUser === true ? setIsAddSSOModalVisible(true) : NotificationsManager.fromBackend("Only premium users can add SSO")}
569569
>
570570
{ssoConfigured ? "Edit SSO Settings" : "Add SSO"}
571571
</Button>
@@ -581,7 +581,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
581581
<div>
582582
<Button
583583
style={{ width: '150px' }}
584-
onClick={() => premiumUser === true ? setIsUIAccessControlModalVisible(true) : NotificationManager.fromBackend("Only premium users can configure UI access control")}
584+
onClick={() => premiumUser === true ? setIsUIAccessControlModalVisible(true) : NotificationsManager.fromBackend("Only premium users can configure UI access control")}
585585
>
586586
UI Access Control
587587
</Button>
@@ -691,7 +691,7 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
691691
accessToken={accessToken}
692692
onSuccess={() => {
693693
handleUIAccessControlOk();
694-
message.success("UI Access Control settings updated successfully");
694+
NotificationsManager.success("UI Access Control settings updated successfully");
695695
}}
696696
/>
697697
</Modal>

ui/litellm-dashboard/src/components/alerting/alerting_settings.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { InputNumber, message } from "antd";
1818
import { alertingSettingsCall, updateConfigFieldSetting } from "../networking";
1919
import { TrashIcon, CheckCircleIcon } from "@heroicons/react/outline";
2020
import DynamicForm from "./dynamic_form";
21+
import NotificationsManager from "../molecules/notifications_manager";
2122
interface alertingSettingsItem {
2223
field_name: string;
2324
field_type: string;
@@ -96,7 +97,7 @@ const AlertingSettings: React.FC<AlertingSettingsProps> = ({
9697
}
9798
}
9899
// update value in state
99-
message.success("Wait 10s for proxy to update.");
100+
NotificationsManager.success("Wait 10s for proxy to update.");
100101
} catch (error) {
101102
// do something
102103
}

ui/litellm-dashboard/src/components/budgets/budget_modal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
message,
1919
} from "antd";
2020
import { budgetCreateCall } from "../networking";
21-
import NotificationManager from "../molecules/notifications_manager";
21+
import NotificationsManager from "../molecules/notifications_manager";
2222

2323
interface BudgetModalProps {
2424
isModalVisible: boolean;
@@ -48,18 +48,18 @@ const BudgetModal: React.FC<BudgetModalProps> = ({
4848
return;
4949
}
5050
try {
51-
message.info("Making API Call");
51+
NotificationsManager.info("Making API Call");
5252
// setIsModalVisible(true);
5353
const response = await budgetCreateCall(accessToken, formValues);
5454
console.log("key create Response:", response);
5555
setBudgetList((prevData) =>
5656
prevData ? [...prevData, response] : [response]
5757
); // Check if prevData is null
58-
message.success("Budget Created");
58+
NotificationsManager.success("Budget Created");
5959
form.resetFields();
6060
} catch (error) {
6161
console.error("Error creating the key:", error);
62-
NotificationManager.fromBackend(`Error creating the key: ${error}`);
62+
NotificationsManager.fromBackend(`Error creating the key: ${error}`);
6363
}
6464
};
6565

ui/litellm-dashboard/src/components/budgets/budget_panel.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import {
3939
} from "@heroicons/react/outline";
4040
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
4141
import { getBudgetList, budgetDeleteCall } from "../networking";
42-
import { message } from "antd";
42+
import NotificationsManager from "../molecules/notifications_manager";
43+
4344
interface BudgetSettingsPageProps {
4445
accessToken: string | null;
4546
}
@@ -84,15 +85,15 @@ const BudgetPanel: React.FC<BudgetSettingsPageProps> = ({ accessToken }) => {
8485
return;
8586
}
8687

87-
message.info("Request made");
88+
NotificationsManager.info("Request made");
8889

8990
await budgetDeleteCall(accessToken, budget_id);
9091

9192
const newBudgetList = [...budgetList];
9293
newBudgetList.splice(index, 1);
9394
setBudgetList(newBudgetList);
9495

95-
message.success("Budget Deleted.");
96+
NotificationsManager.success("Budget Deleted.");
9697
};
9798

9899
const handleUpdateCall = async () => {

0 commit comments

Comments
 (0)