@@ -4,8 +4,9 @@ import DeploymentOperator from './deployment/DeploymentOperator.js';
44import StorageOperator from './storage/StorageOperator.js' ;
55import NoOperator from './NoOperator.js' ;
66import Loading from './util/Loading.js' ;
7- import api from './api/api.js' ;
7+ import api , { IsUnauthorized } from './api/api.js' ;
88import { Container , Segment , Message } from 'semantic-ui-react' ;
9+ import { withAuth } from './auth/Auth.js' ;
910
1011const PodInfoView = ( { pod, namespace} ) => (
1112 < Segment basic >
@@ -46,25 +47,33 @@ class App extends Component {
4647 reloadOperators = async ( ) => {
4748 try {
4849 const operators = await api . get ( '/api/operators' ) ;
49- this . setState ( { operators, error : undefined } ) ;
50+ this . setState ( {
51+ operators,
52+ error : undefined
53+ } ) ;
5054 } catch ( e ) {
51- this . setState ( { error : e . message } ) ;
55+ this . setState ( {
56+ error : e . message
57+ } ) ;
58+ if ( IsUnauthorized ( e ) ) {
59+ this . props . doLogout ( ) ;
60+ }
5261 }
5362 this . props . setTimeout ( this . reloadOperators , 10000 ) ;
5463 }
5564
5665 render ( ) {
5766 if ( this . state . operators ) {
58- return < OperatorsView
67+ return < OperatorsView
5968 error = { this . state . error }
60- deployment = { this . state . operators . deployment }
61- storage = { this . state . operators . storage }
62- pod = { this . state . operators . pod }
63- namespace = { this . state . operators . namespace }
64- /> ;
69+ deployment = { this . state . operators . deployment }
70+ storage = { this . state . operators . storage }
71+ pod = { this . state . operators . pod }
72+ namespace = { this . state . operators . namespace }
73+ /> ;
6574 }
6675 return ( < LoadingView /> ) ;
6776 }
6877}
6978
70- export default ReactTimeout ( App ) ;
79+ export default ReactTimeout ( withAuth ( App ) ) ;
0 commit comments