github.com/grafana/pyroscope@v1.18.0/public/app/components/ServerNotifications.tsx (about) 1 import { useEffect } from 'react'; 2 import { useDispatch } from 'react-redux'; 3 import { addNotification } from '@pyroscope/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 }, [dispatch]); 28 29 return null; 30 }