mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-07 05:50:41 +02:00
error toasts always show even when showNotifications is false
This commit is contained in:
parent
f5627e6a2f
commit
4746470aee
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ToastContainer, Toast } from 'react-bootstrap';
|
import { ToastContainer, Toast } from 'react-bootstrap';
|
||||||
|
|
||||||
export type LevelName = 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG'; // Added levelname
|
export type LevelName = 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
|
||||||
export type Notification = {
|
export type Notification = {
|
||||||
id: number;
|
id: number;
|
||||||
timeStamp: string;
|
timeStamp: string;
|
||||||
@ -20,8 +20,18 @@ export const Notifications = React.memo((props: NotificationProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ToastContainer className="navbarOffset toastContainer" position="top-end">
|
<ToastContainer className="navbarOffset toastContainer" position="top-end">
|
||||||
{showNotification &&
|
{notifications.map((notification) => {
|
||||||
notifications.map((notification) => (
|
// Determine if the toast should be shown
|
||||||
|
const shouldShow =
|
||||||
|
notification.levelname === 'ERROR' ||
|
||||||
|
(showNotification &&
|
||||||
|
['WARNING', 'INFO', 'DEBUG'].includes(notification.levelname));
|
||||||
|
|
||||||
|
if (!shouldShow) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
<Toast
|
<Toast
|
||||||
className={notification.levelname.toLowerCase() + 'Toast'}
|
className={notification.levelname.toLowerCase() + 'Toast'}
|
||||||
key={notification.id}
|
key={notification.id}
|
||||||
@ -53,7 +63,8 @@ export const Notifications = React.memo((props: NotificationProps) => {
|
|||||||
</Toast.Header>
|
</Toast.Header>
|
||||||
<Toast.Body>{notification.message}</Toast.Body>
|
<Toast.Body>{notification.message}</Toast.Body>
|
||||||
</Toast>
|
</Toast>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</ToastContainer>
|
</ToastContainer>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user