2018-03-13 16:52:17 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { HashRouter, Route, Switch, Redirect } from 'react-router-dom';
|
2020-03-04 03:20:19 +03:00
|
|
|
import { Container } from 'reactstrap';
|
2019-01-02 16:36:07 +03:00
|
|
|
import { hot } from 'react-hot-loader/root';
|
2018-03-13 16:52:17 +03:00
|
|
|
|
2020-03-04 03:20:19 +03:00
|
|
|
import ErrorMessages from '../shared/ErrorMessages';
|
|
|
|
|
2018-03-13 16:52:17 +03:00
|
|
|
import MainView from './MainView';
|
|
|
|
import BugDetailsView from './BugDetailsView';
|
|
|
|
|
2018-10-09 22:38:14 +03:00
|
|
|
class App extends React.Component {
|
2018-11-16 11:28:34 +03:00
|
|
|
constructor(props) {
|
2018-10-09 22:38:14 +03:00
|
|
|
super(props);
|
|
|
|
|
2018-10-29 22:18:37 +03:00
|
|
|
// keep track of the mainviews graph and table data so the API won't be
|
|
|
|
// called again when navigating back from bugdetailsview.
|
|
|
|
this.state = {
|
2018-11-16 11:28:34 +03:00
|
|
|
graphData: null,
|
|
|
|
tableData: null,
|
2020-03-04 03:20:19 +03:00
|
|
|
user: {},
|
|
|
|
errorMessages: [],
|
2018-11-16 11:28:34 +03:00
|
|
|
};
|
2018-10-09 22:38:14 +03:00
|
|
|
}
|
|
|
|
|
2020-04-30 22:40:38 +03:00
|
|
|
updateAppState = (state) => {
|
2018-10-09 22:38:14 +03:00
|
|
|
this.setState(state);
|
2018-12-13 21:31:30 +03:00
|
|
|
};
|
2018-10-09 22:38:14 +03:00
|
|
|
|
|
|
|
render() {
|
2020-03-04 03:20:19 +03:00
|
|
|
const { user, graphData, tableData, errorMessages } = this.state;
|
2018-10-09 22:38:14 +03:00
|
|
|
return (
|
2018-03-13 16:52:17 +03:00
|
|
|
<HashRouter>
|
|
|
|
<main>
|
2020-03-04 03:20:19 +03:00
|
|
|
{errorMessages.length > 0 && (
|
|
|
|
<Container className="pt-5 max-width-default">
|
|
|
|
<ErrorMessages errorMessages={errorMessages} />
|
|
|
|
</Container>
|
|
|
|
)}
|
2018-03-13 16:52:17 +03:00
|
|
|
<Switch>
|
2018-11-16 11:28:34 +03:00
|
|
|
<Route
|
2018-10-09 22:38:14 +03:00
|
|
|
exact
|
|
|
|
path="/main"
|
2020-04-30 22:40:38 +03:00
|
|
|
render={(props) => (
|
2018-11-16 11:28:34 +03:00
|
|
|
<MainView
|
|
|
|
{...props}
|
2020-03-04 03:20:19 +03:00
|
|
|
mainGraphData={graphData}
|
|
|
|
mainTableData={tableData}
|
2018-11-16 11:28:34 +03:00
|
|
|
updateAppState={this.updateAppState}
|
2020-03-04 03:20:19 +03:00
|
|
|
user={user}
|
2020-04-30 22:40:38 +03:00
|
|
|
setUser={(user) => this.setState({ user })}
|
|
|
|
notify={(message) =>
|
2020-03-04 03:20:19 +03:00
|
|
|
this.setState({ errorMessages: [message] })
|
|
|
|
}
|
2018-11-16 11:28:34 +03:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
2018-10-09 22:38:14 +03:00
|
|
|
path="/main?startday=:startday&endday=:endday&tree=:tree"
|
2020-04-30 22:40:38 +03:00
|
|
|
render={(props) => (
|
2018-11-16 11:28:34 +03:00
|
|
|
<MainView
|
2018-10-09 22:38:14 +03:00
|
|
|
{...props}
|
2020-03-04 03:20:19 +03:00
|
|
|
mainGraphData={graphData}
|
|
|
|
mainTableData={tableData}
|
2018-10-09 22:38:14 +03:00
|
|
|
updateAppState={this.updateAppState}
|
2018-11-16 11:28:34 +03:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
2018-03-13 16:52:17 +03:00
|
|
|
<Route path="/bugdetails" component={BugDetailsView} />
|
2018-11-16 11:28:34 +03:00
|
|
|
<Route
|
|
|
|
path="/bugdetails?startday=:startday&endday=:endday&tree=:tree&bug=bug"
|
|
|
|
component={BugDetailsView}
|
|
|
|
/>
|
2018-03-13 16:52:17 +03:00
|
|
|
<Redirect from="/" to="/main" />
|
|
|
|
</Switch>
|
|
|
|
</main>
|
|
|
|
</HashRouter>
|
2018-10-09 22:38:14 +03:00
|
|
|
);
|
|
|
|
}
|
2018-03-13 16:52:17 +03:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:36:07 +03:00
|
|
|
export default hot(App);
|