github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/components/ServerNotifications.tsx (about) 1 import { useEffect } from 'react'; 2 import { useDispatch } from 'react-redux'; 3 import { addNotification } from '@webapp/redux/reducers/notifications'; 4 5 export default function ServerNotifications() { 6 const dispatch = useDispatch(); 7 8 useEffect(() => { 9 // the server is supposed to add this 10 // to the index.html 11 const { notificationText } = window as ShamefulAny; 12 13 if (notificationText) { 14 // TODO 15 // distinguish between notification types? 16 dispatch( 17 addNotification({ 18 message: notificationText, 19 type: 'danger', 20 dismiss: { 21 duration: 0, 22 showIcon: true, 23 }, 24 }) 25 ); 26 } 27 }, []); 28 29 return null; 30 }