@@ -2,8 +2,8 @@ import React, { Component } from 'react';
22import { HashRouter as Router , Switch , Route } from 'react-router-dom' ;
33import { TransitionGroup , CSSTransition } from 'react-transition-group' ;
44import { storage } from './helpers/webext' ;
5- import { isDevEnv } from './helpers/debug' ;
6- import { Panel , Settings , Logs , Background , Blocked , PasswordPrompt , AddWebsitePrompt } from './components' ;
5+ import { isDevEnv , isTestEnv } from './helpers/debug' ;
6+ import { Main , Panel , Settings , Timer , Logs , Background , Blocked , PasswordPrompt , AddWebsitePrompt } from './components' ;
77import { PasswordProtectedRoute } from './routes' ;
88
99export default class App extends Component {
@@ -16,6 +16,9 @@ export default class App extends Component {
1616 }
1717
1818 componentDidMount ( ) {
19+ if ( isTestEnv ) {
20+ return ;
21+ }
1922 storage . get ( {
2023 password : {
2124 isEnabled : false
@@ -31,25 +34,30 @@ export default class App extends Component {
3134 return (
3235 < Router >
3336 < Route render = { ( { location } ) => (
34- < TransitionGroup className = "page" >
35- < CSSTransition
36- key = { location . pathname }
37- classNames = "fade"
38- timeout = { 300 }
39- >
40- < Switch location = { location } >
41- < PasswordProtectedRoute exact path = "/" component = { Panel } accessAllowed = { this . state . accessAllowed } showPromptHeader = { true } showPromptFooter = { true } />
42- < PasswordProtectedRoute path = "/settings" component = { Settings } accessAllowed = { this . state . accessAllowed } />
43- < PasswordProtectedRoute path = "/logs" component = { Logs } accessAllowed = { this . state . accessAllowed } />
44- < Route path = "/background" component = { Background } />
45- < Route path = "/blocked" component = { Blocked } />
46- < Route path = "/addWebsitePrompt" component = { AddWebsitePrompt } />
47- { isDevEnv || ! this . state . accessAllowed ? (
48- < Route path = "/pwd" component = { PasswordPrompt } />
49- ) : null }
50- </ Switch >
51- </ CSSTransition >
52- </ TransitionGroup >
37+ < >
38+ { /* Routes that only does redirecting should be outside of the transition group */ }
39+ < Route exact path = "/" component = { Main } />
40+ < TransitionGroup className = "page" >
41+ < CSSTransition
42+ key = { location . pathname }
43+ classNames = "fade"
44+ timeout = { 300 }
45+ >
46+ < Switch location = { location } >
47+ < PasswordProtectedRoute path = "/panel" component = { Panel } accessAllowed = { this . state . accessAllowed } showPromptHeader = { true } showPromptFooter = { true } />
48+ < PasswordProtectedRoute path = "/timer" component = { Timer } accessAllowed = { this . state . accessAllowed } showPromptHeader = { true } showPromptFooter = { true } />
49+ < PasswordProtectedRoute path = "/settings" component = { Settings } accessAllowed = { this . state . accessAllowed } />
50+ < PasswordProtectedRoute path = "/logs" component = { Logs } accessAllowed = { this . state . accessAllowed } />
51+ < Route path = "/background" component = { Background } />
52+ < Route path = "/blocked" component = { Blocked } />
53+ < Route path = "/addWebsitePrompt" component = { AddWebsitePrompt } />
54+ { isDevEnv || ! this . state . accessAllowed ? (
55+ < Route path = "/pwd" component = { PasswordPrompt } />
56+ ) : null }
57+ </ Switch >
58+ </ CSSTransition >
59+ </ TransitionGroup >
60+ </ >
5361 ) } />
5462 </ Router >
5563 ) ;
0 commit comments