2019-09-26 01:15:37 +03:00
|
|
|
import React from 'react';
|
2020-10-28 22:21:19 +03:00
|
|
|
import { Route, Switch, Redirect } from 'react-router-dom';
|
2019-09-26 01:15:37 +03:00
|
|
|
import { hot } from 'react-hot-loader/root';
|
|
|
|
import { Container } from 'reactstrap';
|
|
|
|
|
|
|
|
import { getData, processResponse } from '../helpers/http';
|
|
|
|
import { getApiUrl, repoEndpoint } from '../helpers/url';
|
2020-06-01 23:07:51 +03:00
|
|
|
import InfraCompareView from '../infra-compare/InfraCompare';
|
2019-09-26 01:15:37 +03:00
|
|
|
import ErrorMessages from '../shared/ErrorMessages';
|
|
|
|
|
2021-05-20 17:31:19 +03:00
|
|
|
import { endpoints } from './perf-helpers/constants';
|
2019-09-26 01:15:37 +03:00
|
|
|
import GraphsView from './graphs/GraphsView';
|
|
|
|
import AlertsView from './alerts/AlertsView';
|
2020-04-13 09:31:24 +03:00
|
|
|
import TestsView from './tests/TestsView';
|
2019-09-26 01:15:37 +03:00
|
|
|
import CompareView from './compare/CompareView';
|
|
|
|
import CompareSelectorView from './compare/CompareSelectorView';
|
|
|
|
import CompareSubtestsView from './compare/CompareSubtestsView';
|
|
|
|
import CompareSubtestDistributionView from './compare/CompareSubtestDistributionView';
|
|
|
|
import Navigation from './Navigation';
|
|
|
|
|
2020-10-28 22:21:19 +03:00
|
|
|
import 'react-table/react-table.css';
|
|
|
|
import '../css/perf.css';
|
|
|
|
|
2019-09-26 01:15:37 +03:00
|
|
|
class App extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2019-11-27 11:25:04 +03:00
|
|
|
// store alerts and compare view data so the API's won't be
|
2019-09-26 01:15:37 +03:00
|
|
|
// called again when navigating back from related views.
|
|
|
|
this.state = {
|
|
|
|
projects: [],
|
|
|
|
frameworks: [],
|
2019-11-27 11:25:04 +03:00
|
|
|
platforms: [],
|
2020-06-19 11:56:15 +03:00
|
|
|
performanceTags: [],
|
2019-09-26 01:15:37 +03:00
|
|
|
user: {},
|
|
|
|
errorMessages: [],
|
|
|
|
compareData: [],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async componentDidMount() {
|
2020-06-19 11:56:15 +03:00
|
|
|
const [projects, frameworks, performanceTags] = await Promise.all([
|
2019-09-26 01:15:37 +03:00
|
|
|
getData(getApiUrl(repoEndpoint)),
|
|
|
|
getData(getApiUrl(endpoints.frameworks)),
|
2020-06-19 11:56:15 +03:00
|
|
|
getData(getApiUrl(endpoints.performanceTags)),
|
2019-09-26 01:15:37 +03:00
|
|
|
]);
|
2020-01-31 11:06:38 +03:00
|
|
|
|
2019-09-26 01:15:37 +03:00
|
|
|
const errorMessages = [];
|
|
|
|
const updates = {
|
|
|
|
...processResponse(projects, 'projects', errorMessages),
|
|
|
|
...processResponse(frameworks, 'frameworks', errorMessages),
|
2020-06-19 11:56:15 +03:00
|
|
|
...processResponse(performanceTags, 'performanceTags', errorMessages),
|
2019-09-26 01:15:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
this.setState(updates);
|
|
|
|
}
|
|
|
|
|
2020-04-30 22:40:38 +03:00
|
|
|
updateAppState = (state) => {
|
2019-09-26 01:15:37 +03:00
|
|
|
this.setState(state);
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
user,
|
|
|
|
projects,
|
|
|
|
frameworks,
|
2020-06-19 11:56:15 +03:00
|
|
|
performanceTags,
|
2019-11-27 11:25:04 +03:00
|
|
|
platforms,
|
2019-09-26 01:15:37 +03:00
|
|
|
errorMessages,
|
|
|
|
compareData,
|
|
|
|
} = this.state;
|
2020-10-28 22:21:19 +03:00
|
|
|
const { path } = this.props.match;
|
2019-09-26 01:15:37 +03:00
|
|
|
|
|
|
|
return (
|
2020-10-28 22:21:19 +03:00
|
|
|
<React.Fragment>
|
2019-09-26 01:15:37 +03:00
|
|
|
<Navigation
|
|
|
|
user={user}
|
2020-04-30 22:40:38 +03:00
|
|
|
setUser={(user) => this.setState({ user })}
|
|
|
|
notify={(message) => this.setState({ errorMessages: [message] })}
|
2019-09-26 01:15:37 +03:00
|
|
|
/>
|
2020-06-19 11:56:15 +03:00
|
|
|
{projects.length > 0 &&
|
|
|
|
frameworks.length > 0 &&
|
|
|
|
performanceTags.length > 0 && (
|
|
|
|
<main className="pt-5">
|
|
|
|
{errorMessages.length > 0 && (
|
|
|
|
<Container className="pt-5 max-width-default">
|
|
|
|
<ErrorMessages errorMessages={errorMessages} />
|
|
|
|
</Container>
|
|
|
|
)}
|
|
|
|
<Switch>
|
|
|
|
<Route
|
2020-10-28 22:21:19 +03:00
|
|
|
path={`${path}/alerts`}
|
2020-06-19 11:56:15 +03:00
|
|
|
render={(props) => (
|
|
|
|
<AlertsView
|
|
|
|
{...props}
|
|
|
|
user={user}
|
|
|
|
projects={projects}
|
|
|
|
frameworks={frameworks}
|
|
|
|
performanceTags={performanceTags}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
2020-10-28 22:21:19 +03:00
|
|
|
path={`${path}/graphs`}
|
2020-06-19 11:56:15 +03:00
|
|
|
render={(props) => (
|
|
|
|
<GraphsView
|
|
|
|
{...props}
|
|
|
|
user={user}
|
|
|
|
projects={projects}
|
|
|
|
frameworks={frameworks}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
2020-10-28 22:21:19 +03:00
|
|
|
path={`${path}/comparechooser`}
|
2020-06-19 11:56:15 +03:00
|
|
|
render={(props) => (
|
|
|
|
<CompareSelectorView
|
|
|
|
{...props}
|
|
|
|
user={user}
|
|
|
|
projects={projects}
|
|
|
|
frameworks={frameworks}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
2020-10-28 22:21:19 +03:00
|
|
|
path={`${path}/compare`}
|
2020-06-19 11:56:15 +03:00
|
|
|
render={(props) => (
|
|
|
|
<CompareView
|
|
|
|
{...props}
|
|
|
|
user={user}
|
|
|
|
projects={projects}
|
|
|
|
frameworks={frameworks}
|
|
|
|
compareData={compareData}
|
|
|
|
updateAppState={this.updateAppState}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
2020-10-28 22:21:19 +03:00
|
|
|
path={`${path}/infracompare`}
|
2020-06-19 11:56:15 +03:00
|
|
|
render={(props) => (
|
|
|
|
<InfraCompareView
|
|
|
|
{...props}
|
|
|
|
user={user}
|
|
|
|
projects={projects}
|
|
|
|
frameworks={frameworks}
|
|
|
|
compareData={compareData}
|
|
|
|
updateAppState={this.updateAppState}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
2020-10-28 22:21:19 +03:00
|
|
|
path={`${path}/comparesubtest`}
|
2020-06-19 11:56:15 +03:00
|
|
|
render={(props) => (
|
|
|
|
<CompareSubtestsView
|
|
|
|
{...props}
|
|
|
|
user={user}
|
|
|
|
projects={projects}
|
|
|
|
frameworks={frameworks}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
2020-10-28 22:21:19 +03:00
|
|
|
path={`${path}/comparesubtestdistribution`}
|
2020-06-19 11:56:15 +03:00
|
|
|
render={(props) => (
|
|
|
|
<CompareSubtestDistributionView
|
|
|
|
{...props}
|
|
|
|
user={user}
|
|
|
|
projects={projects}
|
|
|
|
frameworks={frameworks}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
2020-10-28 22:21:19 +03:00
|
|
|
path={`${path}/tests`}
|
2020-06-19 11:56:15 +03:00
|
|
|
render={(props) => (
|
|
|
|
<TestsView
|
|
|
|
{...props}
|
|
|
|
projects={projects}
|
|
|
|
frameworks={frameworks}
|
|
|
|
platforms={platforms}
|
|
|
|
updateAppState={this.updateAppState}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
2020-10-28 22:21:19 +03:00
|
|
|
<Redirect
|
|
|
|
from={`${path}/`}
|
2020-11-10 00:01:14 +03:00
|
|
|
to={`${path}/alerts?hideDwnToInv=1&page=1`}
|
2020-10-28 22:21:19 +03:00
|
|
|
/>
|
2020-06-19 11:56:15 +03:00
|
|
|
</Switch>
|
|
|
|
</main>
|
|
|
|
)}
|
2020-10-28 22:21:19 +03:00
|
|
|
</React.Fragment>
|
2019-09-26 01:15:37 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default hot(App);
|