From fb902fddb316147e9ab93ac59287d422747310d9 Mon Sep 17 00:00:00 2001 From: Nathan LeClaire Date: Wed, 20 Jul 2022 10:51:08 -0400 Subject: [PATCH] Add a few validator page touch ups (#284) - Inspect container when loading and when promises resolve - Change around button disabled conditions a bit - Copy --- src/renderer/nav/Validator.tsx | 88 ++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/src/renderer/nav/Validator.tsx b/src/renderer/nav/Validator.tsx index 9a3ebd58..cd567983 100644 --- a/src/renderer/nav/Validator.tsx +++ b/src/renderer/nav/Validator.tsx @@ -19,14 +19,7 @@ import { } from '../data/ValidatorNetwork/validatorNetworkState'; import { useAppSelector, useInterval } from '../hooks'; import { logger } from '../common/globals'; - -const ipcDockerToast = (dockerIPCMethod: string) => { - return toast.promise(window.promiseIpc.send(`DOCKER-${dockerIPCMethod}`), { - pending: `${dockerIPCMethod} submitted`, - success: `${dockerIPCMethod} succeeded 👌`, - error: `${dockerIPCMethod} failed 🤯`, - }); -}; +import { NetStatus } from '../../types/types'; const ansiUp = new AnsiUp(); @@ -57,8 +50,7 @@ const Validator = () => { // TODO: not sure how to tell the user if we fail to get the list of image tags... // if (isLoading) return 'Loading...' // if (error) return 'An error has occurred: ' + error.message - - useInterval(() => { + const inspectContainer = () => { if (validator.net === Net.Localhost) { window.promiseIpc .send('DOCKER-GetContainerStatus', 'solana-test-validator') @@ -80,7 +72,20 @@ const Validator = () => { logger.silly(inspectError); }); } - }, 5000); + }; + + const ipcDockerToast = (dockerIPCMethod: string) => { + return toast + .promise(window.promiseIpc.send(`DOCKER-${dockerIPCMethod}`), { + pending: `${dockerIPCMethod} submitted`, + success: `${dockerIPCMethod} succeeded 👌`, + error: `${dockerIPCMethod} failed 🤯`, + }) + .then(inspectContainer); + }; + + useInterval(inspectContainer, 5000); + useEffect(inspectContainer, [validator.net]); useInterval(() => { window.electron.ipcRenderer.validatorLogs({ @@ -168,36 +173,42 @@ const Validator = () => {