From 9759139afd92b6aec086b472442e4a6d13093109 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Thu, 19 Oct 2023 00:43:59 +0200 Subject: [PATCH 1/4] chore(settings): move logs button from market to wallet section --- src/components/Settings.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index 0577b547..4f2e2a82 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -179,15 +179,6 @@ export default function Settings({ wallet, stopWallet }: SettingsProps) { {showingFeeConfig && setShowingFeeConfig(false)} />} - {showLogsEnabled && ( - <> - setShowingLogs(true)}> - - {t('settings.show_logs')} - - setShowingLogs(false)} /> - - )}
{t('settings.section_title_wallet')}
setShowingSeed(true)}> @@ -230,6 +221,16 @@ export default function Settings({ wallet, stopWallet }: SettingsProps) { )} + + {showLogsEnabled && ( + <> + setShowingLogs(true)}> + + {t('settings.show_logs')} + + setShowingLogs(false)} /> + + )}
{t('settings.section_title_community')}
From 49e78a32ce64e7b903dc4510cb44ccc309e36e4e Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Thu, 19 Oct 2023 00:45:06 +0200 Subject: [PATCH 2/4] chore: support rich features array format --- src/components/Settings.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index 4f2e2a82..b4541097 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -86,7 +86,10 @@ export default function Settings({ wallet, stopWallet }: SettingsProps) { .then((data) => data && data.features) .then((features) => { if (abortCtrl.signal.aborted) return - setShowLogsEnabled(features && features.logs === true) + const hasLogsFeatureOld = features && features.logs === true + const hasLogsFeature = + features && Array.isArray(features) && features.some((it) => it.name === 'logs' && it.enabled === true) + setShowLogsEnabled(hasLogsFeatureOld || hasLogsFeature) }) .catch((_) => { if (abortCtrl.signal.aborted) return From 8e7e511e8fdfcd979220e781bb3b2043c59f9817 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Thu, 19 Oct 2023 01:19:46 +0200 Subject: [PATCH 3/4] 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 () => { From ba3442f9bc7b73a0c144f647159e7552209cd244 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Fri, 20 Oct 2023 12:02:20 +0200 Subject: [PATCH 4/4] dev(logs): harmonize loading indicators --- src/components/LogOverlay.module.css | 2 +- src/components/LogOverlay.tsx | 2 +- src/components/Orderbook.module.css | 2 +- src/components/Orderbook.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/LogOverlay.module.css b/src/components/LogOverlay.module.css index c3b78430..99e66bd1 100644 --- a/src/components/LogOverlay.module.css +++ b/src/components/LogOverlay.module.css @@ -1,5 +1,5 @@ .logContentPlaceholder { - height: 1rem; + height: 2.625rem; margin: 1px 0; } diff --git a/src/components/LogOverlay.tsx b/src/components/LogOverlay.tsx index 22d4235d..7921d0b1 100644 --- a/src/components/LogOverlay.tsx +++ b/src/components/LogOverlay.tsx @@ -144,7 +144,7 @@ export function LogOverlay({ currentWallet, show, onHide }: LogOverlayProps) { {!isInitialized && isLoading ? ( - Array(12) + Array(5) .fill('') .map((_, index) => { return ( diff --git a/src/components/Orderbook.module.css b/src/components/Orderbook.module.css index 0e98de8e..eecfd953 100644 --- a/src/components/Orderbook.module.css +++ b/src/components/Orderbook.module.css @@ -1,4 +1,4 @@ -.orderbook-line-placeholder { +.orderbookContentPlaceholder { height: 2.625rem; margin: 1px 0; } diff --git a/src/components/Orderbook.tsx b/src/components/Orderbook.tsx index 5e192d12..6b837f3d 100644 --- a/src/components/Orderbook.tsx +++ b/src/components/Orderbook.tsx @@ -461,7 +461,7 @@ export function OrderbookOverlay({ nickname, show, onHide }: OrderbookOverlayPro .map((_, index) => { return ( - + ) })