From bdaaaf68a2353887b2af06a7a56b2247da4d3b5f Mon Sep 17 00:00:00 2001 From: Dmitry Filimonov Date: Thu, 12 Aug 2021 18:06:28 -0700 Subject: [PATCH] Adds frontend support for notifications (#334) * adds frontend support for notifications * js lint fixes --- pkg/server/handler.go | 6 +++ .../javascript/components/Notifications.jsx | 35 +++++++++++++++++ webapp/javascript/index.jsx | 2 + webapp/sass/profile.scss | 39 +++++++++++++++++++ webapp/templates/index.html | 1 + 5 files changed, 83 insertions(+) create mode 100644 webapp/javascript/components/Notifications.jsx diff --git a/pkg/server/handler.go b/pkg/server/handler.go index cdb684e8c0..3e12305211 100644 --- a/pkg/server/handler.go +++ b/pkg/server/handler.go @@ -386,9 +386,15 @@ func (ctrl *Controller) renderIndexPage(w http.ResponseWriter, _ *http.Request) "LatestVersionInfo": updates.LatestVersionJSON(), "ExtraMetadata": extraMetadataStr, "BaseURL": ctrl.config.BaseURL, + "NotificationText": ctrl.NotificationText(), }) } +func (ctrl *Controller) NotificationText() string { + // TODO: implement backend support for alert text + return "" +} + func mustExecute(t *template.Template, w io.Writer, v interface{}) { if err := t.Execute(w, v); err != nil { panic(err) diff --git a/webapp/javascript/components/Notifications.jsx b/webapp/javascript/components/Notifications.jsx new file mode 100644 index 0000000000..c1a6807fef --- /dev/null +++ b/webapp/javascript/components/Notifications.jsx @@ -0,0 +1,35 @@ +import React, { useState, useEffect } from "react"; +import { connect } from "react-redux"; +import "react-dom"; + +import { withShortcut } from "react-keybind"; +import Modal from "react-modal"; +import clsx from "clsx"; + +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons"; + +function Notifications(props) { + const { notificationText } = window; + + const [hidden, setHidden] = useState(notificationText === ""); + + return ( +