From 57e30de489f90b6e6eb09451aababce99f3b88f6 Mon Sep 17 00:00:00 2001 From: JatinBumbra Date: Wed, 1 Jun 2022 14:20:48 +0530 Subject: [PATCH] Add a restart button for node and show an alert if node is not running --- src/dashboard/ui/App.tsx | 9 +++-- .../ui/components/NodeRestartAlert.tsx | 34 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/dashboard/ui/components/NodeRestartAlert.tsx diff --git a/src/dashboard/ui/App.tsx b/src/dashboard/ui/App.tsx index 72c7952..aa9beed 100644 --- a/src/dashboard/ui/App.tsx +++ b/src/dashboard/ui/App.tsx @@ -13,6 +13,7 @@ import DashboardTitle from './components/DashboardTitle' import WalletInfo from './components/WalletInfo' import UpdateProgress from './components/UpdateProgress' import DefaultLoader from './components/DefaultLoader' +import NodeRestartAlert from './components/NodeRestartAlert' export default function App() { const [isLoading, setIsLoading] = useState(true) @@ -216,6 +217,7 @@ export default function App() { + } - buttonLabel="Check Status" - isLoading={isLoading || isNodeUpdating || isFirefoxUpdating} + buttonLabel="Restart Node" + isLoading={ + isLoading || isNodeUpdating || isFirefoxUpdating || !!nodeVersion + } version={nodeVersion} /> diff --git a/src/dashboard/ui/components/NodeRestartAlert.tsx b/src/dashboard/ui/components/NodeRestartAlert.tsx new file mode 100644 index 0000000..cd38d3c --- /dev/null +++ b/src/dashboard/ui/components/NodeRestartAlert.tsx @@ -0,0 +1,34 @@ +import { useState, ReactEventHandler, useEffect } from 'react' +import Alert from '@mui/material/Alert' +import Typography from '@mui/material/Typography' + +const NodeRestartAlert = ({ isNodeRunning }: { isNodeRunning: boolean }) => { + const [showAlert, setShowAlert] = useState(false) + + useEffect(() => { + setShowAlert(!isNodeRunning) + }, [isNodeRunning]) + + const handleCloseAlert: ReactEventHandler = () => setShowAlert(false) + + return showAlert ? ( + + Point Node is not running + + Try restarting the Point Node by clicking the 'Restart Node' button + + + ) : null +} + +export default NodeRestartAlert