diff --git a/ui/src/CurrentUser.ts b/ui/src/CurrentUser.ts index 82b901d..683f9fd 100644 --- a/ui/src/CurrentUser.ts +++ b/ui/src/CurrentUser.ts @@ -15,6 +15,8 @@ export class CurrentUser { public authenticating = false; @observable public user: IUser = {name: 'unknown', admin: false, id: -1}; + @observable + public hasNetwork = true; public constructor(private readonly snack: SnackReporter) {} @@ -82,15 +84,18 @@ export class CurrentUser { .then((passThrough) => { this.user = passThrough.data; this.loggedIn = true; + this.hasNetwork = true; return passThrough; }) .catch((error: AxiosError) => { - if ( - error && - error.response && - error.response.status >= 400 && - error.response.status < 500 - ) { + if (!error || !error.response) { + this.hasNetwork = false; + return Promise.reject(error); + } + + this.hasNetwork = true; + + if (error.response.status >= 400 && error.response.status < 500) { this.logout(); } return Promise.reject(error); diff --git a/ui/src/common/NetworkLostBanner.tsx b/ui/src/common/NetworkLostBanner.tsx new file mode 100644 index 0000000..a6cad16 --- /dev/null +++ b/ui/src/common/NetworkLostBanner.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import Button from '@material-ui/core/Button'; +import Typography from '@material-ui/core/Typography'; + +interface NetworkLostBannerProps { + height: number; + retry: () => void; +} + +export const NetworkLostBanner = ({height, retry}: NetworkLostBannerProps) => { + return ( +