From d25132ff552701b9fb21601624936eafcd5ce2c5 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Sun, 3 Apr 2022 19:21:01 -0400 Subject: [PATCH] Add component for outage notification --- client/modules/IDE/pages/IDEView.jsx | 2 ++ .../modules/User/components/Notification.jsx | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 client/modules/User/components/Notification.jsx diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index 04bbb2f9ad..a15577f83e 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -36,6 +36,7 @@ import Feedback from '../components/Feedback'; import { CollectionSearchbar } from '../components/Searchbar'; import { getIsUserOwner } from '../selectors/users'; import RootPage from '../../../components/RootPage'; +import Notification from '../../User/components/Notification'; function getTitle(props) { const { id } = props.project; @@ -252,6 +253,7 @@ class IDEView extends React.Component { render() { return ( + {getTitle(this.props)} diff --git a/client/modules/User/components/Notification.jsx b/client/modules/User/components/Notification.jsx new file mode 100644 index 0000000000..c7189c3af1 --- /dev/null +++ b/client/modules/User/components/Notification.jsx @@ -0,0 +1,22 @@ +import { useEffect } from 'react'; +import Cookies from 'js-cookie'; +import { useDispatch } from 'react-redux'; +import { showToast, setToastText } from '../../IDE/actions/toast'; + +function Notification() { + const dispatch = useDispatch(); + useEffect(() => { + const notification = Cookies.get('p5-notification'); + if (!notification) { + // show the toast + dispatch(showToast(30000)); + const text = `There is a scheduled outage on Sunday, April 9 3AM - 5AM UTC. + The entire site will be down, so please plan accordingly.`; + dispatch(setToastText(text)); + Cookies.set('p5-notification', true, { expires: 365 }); + } + }); + return null; +} + +export default Notification;