@ -1,4 +1,5 @@
import * as React from 'react' ;
import * as React from 'react' ;
import { List as ImmutableList } from 'immutable' ;
import { connect } from 'react-redux' ;
import { connect } from 'react-redux' ;
import { withRouter } from 'react-router' ;
import { withRouter } from 'react-router' ;
import { BrowserRouter } from 'react-router-dom' ;
import { BrowserRouter } from 'react-router-dom' ;
@ -10,13 +11,18 @@ import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar' ;
import Toolbar from '@material-ui/core/Toolbar' ;
import Drawer from '@material-ui/core/Drawer' ;
import Drawer from '@material-ui/core/Drawer' ;
import IconButton from '@material-ui/core/IconButton' ;
import IconButton from '@material-ui/core/IconButton' ;
import Badge from '@material-ui/core/Badge' ;
import NavigationMenu from '@material-ui/icons/Menu' ;
import NavigationMenu from '@material-ui/icons/Menu' ;
import NavigationBack from '@material-ui/icons/ArrowBack' ;
import NavigationBack from '@material-ui/icons/ArrowBack' ;
import NavigationRefresh from '@material-ui/icons/Refresh' ;
import NavigationRefresh from '@material-ui/icons/Refresh' ;
import ErrorsIcon from '@material-ui/icons/Error' ;
import './App.css' ;
import './App.css' ;
import ConfirmationDialog from './widgets/ConfirmationDialog' ;
import PrettyError from './widgets/PrettyError' ;
import { List , ListItem } from './widgets/List' ;
import withSpin from './widgets/withSpin' ;
import withSpin from './widgets/withSpin' ;
import ErrorBoundary from './components/ErrorBoundary' ;
import ErrorBoundary from './components/ErrorBoundary' ;
import SideMenu from './SideMenu' ;
import SideMenu from './SideMenu' ;
@ -160,17 +166,19 @@ const IconRefreshWithSpin = withSpin(NavigationRefresh);
class App extends React . PureComponent {
class App extends React . PureComponent {
public state : {
public state : {
drawerOpen : boolean ;
drawerOpen : boolean ;
errorsDialog : boolean ;
} ;
} ;
public props : {
public props : {
credentials : store.CredentialsType ;
credentials : store.CredentialsType ;
entries : store.EntriesType ;
entries : store.EntriesType ;
fetchCount : number ;
fetchCount : number ;
errors : ImmutableList < Error > ;
} ;
} ;
constructor ( props : any ) {
constructor ( props : any ) {
super ( props ) ;
super ( props ) ;
this . state = { drawerOpen : false } ;
this . state = { drawerOpen : false , errorsDialog : false } ;
this . toggleDrawer = this . toggleDrawer . bind ( this ) ;
this . toggleDrawer = this . toggleDrawer . bind ( this ) ;
this . closeDrawer = this . closeDrawer . bind ( this ) ;
this . closeDrawer = this . closeDrawer . bind ( this ) ;
@ -180,6 +188,7 @@ class App extends React.PureComponent {
public render() {
public render() {
const credentials = ( this . props . credentials ) ? this . props.credentials.value : null ;
const credentials = ( this . props . credentials ) ? this . props.credentials.value : null ;
const errors = this . props . errors ;
const fetching = this . props . fetchCount > 0 ;
const fetching = this . props . fetchCount > 0 ;
const styles = {
const styles = {
@ -197,11 +206,43 @@ class App extends React.PureComponent {
< AppBarWitHistory
< AppBarWitHistory
toggleDrawerIcon = { < IconButton onClick = { this . toggleDrawer } > < NavigationMenu / > < / IconButton > }
toggleDrawerIcon = { < IconButton onClick = { this . toggleDrawer } > < NavigationMenu / > < / IconButton > }
iconElementRight = {
iconElementRight = {
< >
{ ( errors . size > 0 ) && (
< IconButton onClick = { ( ) = > this . setState ( { errorsDialog : true } ) } title = "Parse Errors" >
< Badge badgeContent = { errors . size } color = "error" >
< ErrorsIcon / >
< / Badge >
< / IconButton >
) }
< IconButton disabled = { ! credentials || fetching } onClick = { this . refresh } title = "Refresh" >
< IconButton disabled = { ! credentials || fetching } onClick = { this . refresh } title = "Refresh" >
< IconRefreshWithSpin spin = { fetching } / >
< IconRefreshWithSpin spin = { fetching } / >
< / IconButton > }
< / IconButton >
< / >
}
/ >
/ >
< ConfirmationDialog
title = "Parse Errors"
open = { this . state . errorsDialog }
labelOk = "OK"
onCancel = { ( ) = > this . setState ( { errorsDialog : false } ) }
onOk = { ( ) = > this . setState ( { errorsDialog : false } ) }
>
< h4 >
This should not happen , please contact developers !
< / h4 >
< List >
{ errors . map ( ( error , index ) = > (
< ListItem
key = { index }
style = { { height : 'unset' } }
onClick = { ( ) = > ( window as any ) . navigator . clipboard . writeText ( ` ${ error . message } \ n \ n ${ error . stack } ` ) }
>
< PrettyError error = { error } / >
< / ListItem >
) ) }
< / List >
< / ConfirmationDialog >
< Drawer
< Drawer
open = { this . state . drawerOpen }
open = { this . state . drawerOpen }
onClose = { this . toggleDrawer }
onClose = { this . toggleDrawer }
@ -257,6 +298,7 @@ const mapStateToProps = (state: store.StoreState) => {
credentials : credentialsSelector ( state ) ,
credentials : credentialsSelector ( state ) ,
entries : state.cache.entries ,
entries : state.cache.entries ,
fetchCount : state.fetchCount ,
fetchCount : state.fetchCount ,
errors : state.errors ,
} ;
} ;
} ;
} ;