From 8e7e511e8fdfcd979220e781bb3b2043c59f9817 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Thu, 19 Oct 2023 01:19:46 +0200 Subject: [PATCH] dev(logs): show log button and add hint in dev mode --- src/components/LogOverlay.tsx | 19 ++++++++++++++++--- src/components/Settings.tsx | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/components/LogOverlay.tsx b/src/components/LogOverlay.tsx index 29e30efb..22d4235d 100644 --- a/src/components/LogOverlay.tsx +++ b/src/components/LogOverlay.tsx @@ -7,6 +7,7 @@ import { useSettings } from '../context/SettingsContext' import { CurrentWallet } from '../context/WalletContext' import Sprite from './Sprite' import styles from './LogOverlay.module.css' +import { isDevMode } from '../constants/debugFeatures' const JMWALLETD_LOG_FILE_NAME = 'jmwalletd_stdout.log' @@ -74,7 +75,7 @@ export function LogOverlay({ currentWallet, show, onHide }: LogOverlayProps) { const [alert, setAlert] = useState() const [isInitialized, setIsInitialized] = useState(false) const [isLoading, setIsLoading] = useState(true) - const [content, setContent] = useState(null) + const [content, setContent] = useState() const refresh = useCallback( (signal: AbortSignal) => { @@ -85,9 +86,14 @@ export function LogOverlay({ currentWallet, show, onHide }: LogOverlayProps) { setAlert(undefined) setContent(data) }) - .catch((err) => { + .catch((e) => { if (signal.aborted) return - setAlert({ variant: 'danger', message: t('logs.error_loading_logs_failed') }) + setAlert({ + variant: 'danger', + message: t('logs.error_loading_logs_failed', { + reason: e.message || t('global.errors.reason_unknown'), + }), + }) }) .finally(() => { if (signal.aborted) return @@ -149,6 +155,13 @@ export function LogOverlay({ currentWallet, show, onHide }: LogOverlayProps) { }) ) : ( <> + {alert && !content && isDevMode() && ( +
+ dev + In order to test the log file feature, start the application with + npm run dev:start:secondary. +
+ )} {alert && {alert.message}} {content && ( diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index b4541097..d9801e65 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -16,7 +16,7 @@ import languages from '../i18n/languages' import styles from './Settings.module.css' import SeedModal from './settings/SeedModal' import FeeConfigModal from './settings/FeeConfigModal' -import { isDebugFeatureEnabled } from '../constants/debugFeatures' +import { isDebugFeatureEnabled, isDevMode } from '../constants/debugFeatures' import { isFeatureEnabled } from '../constants/features' import { CurrentWallet } from '../context/WalletContext' @@ -93,7 +93,7 @@ export default function Settings({ wallet, stopWallet }: SettingsProps) { }) .catch((_) => { if (abortCtrl.signal.aborted) return - setShowLogsEnabled(false) + setShowLogsEnabled(isDevMode()) }) return () => {