aboutsummaryrefslogtreecommitdiff
path: root/src/App.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/App.js')
-rw-r--r--src/App.js81
1 files changed, 42 insertions, 39 deletions
diff --git a/src/App.js b/src/App.js
index 6988105..bd17cec 100644
--- a/src/App.js
+++ b/src/App.js
@@ -11,7 +11,7 @@ import Paper from '@material-ui/core/Paper';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import Grid from '@material-ui/core/Grid';
-import { HashRouter as Router, Route, Link, Redirect, Switch } from "react-router-dom";
+import { HashRouter as Router, withRouter, Route, Link, Redirect, Switch } from "react-router-dom";
import { hashHistory } from 'react-router';
import Logo from './Logo';
import theme from './theme';
@@ -45,52 +45,55 @@ const styles = theme => ({
}
});
-class Dashboard extends React.Component {
- state = {
- currentTab: 0
- };
-
+class DashboardTabs extends React.Component {
handleChangeTab = (event, currentTab) => {
- this.setState({ currentTab });
+ this.props.history.push(currentTab);
}
-
render() {
const { classes } = this.props;
-
return (
- <MuiThemeProvider theme={theme}>
- <Router>
- <div className={classes.root}>
- <AppBar
- position="absolute"
- className={classes.appBar}>
- <Toolbar className={classes.toolbar}>
- <Typography component="h1" variant="h6" color="inherit" noWrap className={classes.title}>
- <Logo style={{width: '2em', verticalAlign: 'bottom', marginRight: '0.2em'}}/>Chromicle
- </Typography>
- <Tabs styles={{ display: 'inline-block '}}
- classes={{ indicator: classes.indicator }}
- value={this.state.currentTab}
- onChange={this.handleChangeTab}>
- <Tab label="Settings" component={Link} to="/settings" />
- <Tab label="Analyze" component={Link} to="/analyze" />
- </Tabs>
- </Toolbar>
- </AppBar>
- <CssBaseline />
- <main className={classes.content}>
- <div className={classes.appBarSpacer} />
- <Route exact path="/settings" component={Settings} />
- <Route exact path="/analyze" component={CustomAnalyzer} />
- </main>
- </div>
- </Router>
- </MuiThemeProvider>);
+ <div className={classes.root}>
+ <AppBar
+ position="absolute"
+ className={classes.appBar}>
+ <Toolbar className={classes.toolbar}>
+ <Typography component="h1" variant="h6" color="inherit" noWrap className={classes.title}>
+ <Logo style={{width: '2em', verticalAlign: 'bottom', marginRight: '0.2em'}}/>Chromicle
+ </Typography>
+ <Tabs styles={{ display: 'inline-block '}}
+ classes={{ indicator: classes.indicator }}
+ value={this.props.history.location.pathname}
+ onChange={this.handleChangeTab}>
+ <Tab label="Settings" component={Link} to="/settings" value="/settings" />
+ <Tab label="Analyze" component={Link} to="/analyze" value="/analyze" />
+ </Tabs>
+ </Toolbar>
+ </AppBar>
+ <CssBaseline />
+ <main className={classes.content}>
+ <div className={classes.appBarSpacer} />
+ <Route exact path="/settings" component={Settings} />
+ <Route exact path="/analyze" component={CustomAnalyzer} />
+ <Route exact path="/" render={() => <Redirect to="/settings" />}/>
+ </main>
+ </div>
+ );
}
}
-Dashboard.propTypes = {
+DashboardTabs.propTypes = {
classes: PropTypes.object.isRequired,
};
-export default withStyles(styles)(Dashboard);
+class Dashboard extends React.Component {
+ render() {
+ const { classes } = this.props;
+ let Tabs = withRouter(withStyles(styles)(DashboardTabs));
+ return (
+ <MuiThemeProvider theme={theme}>
+ <Router><Tabs /></Router>
+ </MuiThemeProvider>);
+ }
+}
+
+export default Dashboard;