1717 */
1818
1919import React from 'react' ;
20- import { useLocation } from 'react-router-dom' ;
20+ import { useHistory , useLocation } from 'react-router-dom' ;
2121import { Menu , MenuItem , Tag , Navbar , Intent , Alignment , Button } from '@blueprintjs/core' ;
2222
2323import { PageLoading , Logo , ExternalLink } from '@/components' ;
2424import { useRefreshData } from '@/hooks' ;
25- import { history } from '@/utils/history' ;
2625
2726import DashboardIcon from '@/images/icons/dashborad.svg' ;
2827import FileIcon from '@/images/icons/file.svg' ;
@@ -39,10 +38,11 @@ interface Props {
3938}
4039
4140export const BaseLayout = ( { children } : Props ) => {
42- const menu = useMenu ( ) ;
41+ const history = useHistory ( ) ;
4342 const { pathname } = useLocation ( ) ;
4443
45- const { ready, data } = useRefreshData < { version : string } > ( ( ) => API . getVersion ( ) , [ ] ) ;
44+ const menu = useMenu ( ) ;
45+ const { ready, data, error } = useRefreshData < { version : string } > ( ( ) => API . getVersion ( ) , [ ] ) ;
4646
4747 const token = window . localStorage . getItem ( 'accessToken' ) ;
4848
@@ -66,6 +66,10 @@ export const BaseLayout = ({ children }: Props) => {
6666 return import . meta. env . DEV ? `${ protocol } //${ hostname } :3002${ suffix } ` : `/grafana${ suffix } ` ;
6767 } ;
6868
69+ if ( error ) {
70+ history . push ( '/offline' ) ;
71+ }
72+
6973 if ( ! ready || ! data ) {
7074 return < PageLoading /> ;
7175 }
0 commit comments