From 9b43450bc73a5d8e4c79c071c5678e4e64fa976a Mon Sep 17 00:00:00 2001 From: Piotr Rogowski Date: Wed, 19 Oct 2022 14:03:18 +0200 Subject: [PATCH] Handle zero logs --- src/App.tsx | 6 +++++- src/components/TopBar.tsx | 8 ++++---- src/pages/Logs.tsx | 7 +++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 3482b42..299155d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -142,7 +142,11 @@ const App = ({ ui, navigation, tuneData }: { ui: UIState, navigation: Navigation return ( <> - + 0} + hasToothLogs={tuneData && (tuneData.toothLogFiles || []).length > 0} + /> } />} /> } />} /> diff --git a/src/components/TopBar.tsx b/src/components/TopBar.tsx index bfca012..23bda9a 100644 --- a/src/components/TopBar.tsx +++ b/src/components/TopBar.tsx @@ -57,7 +57,7 @@ const { Header } = Layout; const { useBreakpoint } = Grid; const { SubMenu } = Menu; -const TopBar = ({ tuneId }: { tuneId: string | null }) => { +const TopBar = ({ tuneId, hasLogs, hasToothLogs }: { tuneId: string | null; hasLogs: boolean; hasToothLogs: boolean }) => { const { xs, sm, lg } = useBreakpoint(); const { pathname } = useLocation(); const { currentUser, logout } = useAuth(); @@ -119,13 +119,13 @@ const TopBar = ({ tuneId }: { tuneId: string | null }) => { {lg && 'Tune'} - + {lg && 'Logs'} - + {lg && 'Diagnose'} @@ -133,7 +133,7 @@ const TopBar = ({ tuneId }: { tuneId: string | null }) => { - ), [pathname, tuneTuneMatch?.pathnameBase, tabMatch?.pathname, tuneRootMatch?.pathname, hubPathMatch?.pathname, tuneLogMatch?.pathnameBase, buildTuneUrl, lg, navigate]); + ), [pathname, tuneLogMatch?.pathnameBase, tuneTuneMatch?.pathnameBase, tabMatch?.pathname, tuneRootMatch?.pathname, hubPathMatch?.pathname, buildTuneUrl, lg, hasLogs, hasToothLogs, navigate]); const rightMenuColProps = tuneId ? { span: 8, diff --git a/src/pages/Logs.tsx b/src/pages/Logs.tsx index d80625a..eb8a32e 100644 --- a/src/pages/Logs.tsx +++ b/src/pages/Logs.tsx @@ -218,6 +218,13 @@ const Logs = ({ } }; + // user didn't upload any logs + if (tuneData && (tuneData.logFiles || []).length === 0) { + navigate(Routes.HUB); + + return undefined; + } + // user navigated to logs root page if (!routeMatch?.params.fileName && tuneData.logFiles?.length) { // either redirect to the first log or to the latest selected