Handle zero logs
This commit is contained in:
parent
1ffd031a06
commit
9b43450bc7
|
@ -142,7 +142,11 @@ const App = ({ ui, navigation, tuneData }: { ui: UIState, navigation: Navigation
|
|||
return (
|
||||
<>
|
||||
<Layout>
|
||||
<TopBar tuneId={navigation.tuneId} />
|
||||
<TopBar
|
||||
tuneId={navigation.tuneId}
|
||||
hasLogs={tuneData && (tuneData.logFiles || []).length > 0}
|
||||
hasToothLogs={tuneData && (tuneData.toothLogFiles || []).length > 0}
|
||||
/>
|
||||
<ReactRoutes>
|
||||
<Route path={Routes.HUB} element={<ContentFor element={<Hub />} />} />
|
||||
<Route path={Routes.TUNE_ROOT} element={<ContentFor element={<Info />} />} />
|
||||
|
|
|
@ -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'}
|
||||
</Space>
|
||||
</Radio.Button>
|
||||
<Radio.Button value={buildTuneUrl(Routes.TUNE_LOGS)}>
|
||||
<Radio.Button value={buildTuneUrl(Routes.TUNE_LOGS)} disabled={!hasLogs}>
|
||||
<Space>
|
||||
<FundOutlined />
|
||||
{lg && 'Logs'}
|
||||
</Space>
|
||||
</Radio.Button>
|
||||
<Radio.Button value={buildTuneUrl(Routes.TUNE_DIAGNOSE)}>
|
||||
<Radio.Button value={buildTuneUrl(Routes.TUNE_DIAGNOSE)} disabled={!hasToothLogs}>
|
||||
<Space>
|
||||
<SettingOutlined />
|
||||
{lg && 'Diagnose'}
|
||||
|
@ -133,7 +133,7 @@ const TopBar = ({ tuneId }: { tuneId: string | null }) => {
|
|||
</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Col>
|
||||
), [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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue