2019-09-09 23:19:04 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-03-04 03:11:59 +03:00
|
|
|
import { Button, Container, Col, Row } from 'reactstrap';
|
2019-09-09 23:19:04 +03:00
|
|
|
import unionBy from 'lodash/unionBy';
|
2019-09-26 01:15:37 +03:00
|
|
|
import queryString from 'query-string';
|
2019-09-09 23:19:04 +03:00
|
|
|
|
|
|
|
import { getData, processResponse, processErrors } from '../../helpers/http';
|
|
|
|
import {
|
|
|
|
createApiUrl,
|
2021-11-05 12:22:08 +03:00
|
|
|
createQueryParams,
|
|
|
|
getApiUrl,
|
2019-09-26 01:15:37 +03:00
|
|
|
parseQueryParams,
|
|
|
|
updateQueryParams,
|
2019-09-09 23:19:04 +03:00
|
|
|
} from '../../helpers/url';
|
|
|
|
import {
|
|
|
|
genericErrorMessage,
|
|
|
|
errorMessageClass,
|
|
|
|
} from '../../helpers/constants';
|
2021-05-20 17:31:19 +03:00
|
|
|
import { processSelectedParam, createGraphData } from '../perf-helpers/helpers';
|
2019-09-26 01:15:37 +03:00
|
|
|
import {
|
2022-02-22 18:35:57 +03:00
|
|
|
alertSummaryLimit,
|
2019-09-26 01:15:37 +03:00
|
|
|
endpoints,
|
|
|
|
graphColors,
|
2020-01-31 18:57:21 +03:00
|
|
|
graphSymbols,
|
2019-09-26 01:15:37 +03:00
|
|
|
phTimeRanges,
|
|
|
|
phDefaultTimeRangeValue,
|
2021-05-20 17:31:19 +03:00
|
|
|
} from '../perf-helpers/constants';
|
2019-09-09 23:19:04 +03:00
|
|
|
import ErrorMessages from '../../shared/ErrorMessages';
|
|
|
|
import ErrorBoundary from '../../shared/ErrorBoundary';
|
|
|
|
import LoadingSpinner from '../../shared/LoadingSpinner';
|
|
|
|
|
|
|
|
import LegendCard from './LegendCard';
|
|
|
|
import GraphsViewControls from './GraphsViewControls';
|
|
|
|
|
|
|
|
class GraphsView extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
timeRange: this.getDefaultTimeRange(),
|
|
|
|
zoom: {},
|
|
|
|
selectedDataPoint: null,
|
|
|
|
highlightAlerts: true,
|
2021-11-05 12:22:08 +03:00
|
|
|
highlightCommonAlerts: false,
|
2020-12-18 13:06:25 +03:00
|
|
|
highlightChangelogData: true,
|
2019-09-09 23:19:04 +03:00
|
|
|
highlightedRevisions: ['', ''],
|
|
|
|
testData: [],
|
|
|
|
errorMessages: [],
|
|
|
|
options: {},
|
|
|
|
loading: false,
|
|
|
|
colors: [...graphColors],
|
2020-01-31 18:57:21 +03:00
|
|
|
symbols: [...graphSymbols],
|
2019-09-09 23:19:04 +03:00
|
|
|
showModal: false,
|
2020-03-04 03:11:59 +03:00
|
|
|
showTable: false,
|
2019-09-17 01:02:19 +03:00
|
|
|
visibilityChanged: false,
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates: false,
|
2019-09-09 23:19:04 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async componentDidMount() {
|
|
|
|
this.checkQueryParams();
|
|
|
|
}
|
|
|
|
|
2021-09-08 14:48:41 +03:00
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
const { location } = this.props;
|
|
|
|
const { testData, loading } = this.state;
|
2023-12-12 17:14:43 +03:00
|
|
|
const { replicates } = queryString.parse(this.props.location.search);
|
|
|
|
const { replicates: prevReplicates } = queryString.parse(
|
|
|
|
prevProps.location.search,
|
|
|
|
);
|
|
|
|
|
2021-09-08 14:48:41 +03:00
|
|
|
if (
|
|
|
|
location.search === '' &&
|
|
|
|
testData.length !== 0 &&
|
|
|
|
loading !== true &&
|
|
|
|
location.search !== prevProps.location.search
|
|
|
|
) {
|
|
|
|
// eslint-disable-next-line react/no-did-update-set-state
|
|
|
|
this.setState({
|
|
|
|
testData: [],
|
|
|
|
});
|
|
|
|
}
|
2023-12-12 17:14:43 +03:00
|
|
|
|
|
|
|
if (prevReplicates !== undefined) {
|
|
|
|
if (replicates !== prevReplicates) {
|
|
|
|
window.location.reload(false);
|
|
|
|
}
|
|
|
|
}
|
2021-09-08 14:48:41 +03:00
|
|
|
}
|
|
|
|
|
2019-09-09 23:19:04 +03:00
|
|
|
getDefaultTimeRange = () => {
|
2019-09-26 01:15:37 +03:00
|
|
|
const { location } = this.props;
|
|
|
|
const { timerange } = parseQueryParams(location.search);
|
2019-09-09 23:19:04 +03:00
|
|
|
|
2019-09-26 01:15:37 +03:00
|
|
|
const defaultValue = timerange
|
|
|
|
? parseInt(timerange, 10)
|
2019-09-09 23:19:04 +03:00
|
|
|
: phDefaultTimeRangeValue;
|
2020-04-30 22:40:38 +03:00
|
|
|
return phTimeRanges.find((time) => time.value === defaultValue);
|
2019-09-09 23:19:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
checkQueryParams = () => {
|
|
|
|
const {
|
|
|
|
series,
|
|
|
|
zoom,
|
|
|
|
selected,
|
|
|
|
highlightAlerts,
|
2021-11-05 12:22:08 +03:00
|
|
|
highlightCommonAlerts,
|
2020-12-18 13:06:25 +03:00
|
|
|
highlightChangelogData,
|
2019-09-09 23:19:04 +03:00
|
|
|
highlightedRevisions,
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates,
|
2019-09-26 01:15:37 +03:00
|
|
|
} = queryString.parse(this.props.location.search);
|
2019-09-09 23:19:04 +03:00
|
|
|
|
|
|
|
const updates = {};
|
|
|
|
|
|
|
|
if (series) {
|
2023-12-12 17:14:43 +03:00
|
|
|
// TODO: Move series/test data fetch to after the params are parsed, and
|
|
|
|
// the component is updated. Here, it's using default settings even if
|
|
|
|
// the parameters are different.
|
2019-09-09 23:19:04 +03:00
|
|
|
const _series = typeof series === 'string' ? [series] : series;
|
2023-12-12 17:14:43 +03:00
|
|
|
const seriesParams = this.parseSeriesParam(
|
|
|
|
_series,
|
|
|
|
Boolean(parseInt(replicates, 10)),
|
|
|
|
);
|
2019-09-09 23:19:04 +03:00
|
|
|
this.getTestData(seriesParams, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (highlightAlerts) {
|
|
|
|
updates.highlightAlerts = Boolean(parseInt(highlightAlerts, 10));
|
|
|
|
}
|
|
|
|
|
2021-11-05 12:22:08 +03:00
|
|
|
if (highlightCommonAlerts) {
|
|
|
|
updates.highlightCommonAlerts = Boolean(
|
|
|
|
parseInt(highlightCommonAlerts, 10),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-12-18 13:06:25 +03:00
|
|
|
if (highlightChangelogData) {
|
|
|
|
updates.highlightChangelogData = Boolean(
|
|
|
|
parseInt(highlightChangelogData, 10),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-12 17:14:43 +03:00
|
|
|
if (replicates) {
|
|
|
|
updates.replicates = Boolean(parseInt(replicates, 10));
|
|
|
|
}
|
|
|
|
|
2019-09-09 23:19:04 +03:00
|
|
|
if (highlightedRevisions) {
|
|
|
|
updates.highlightedRevisions =
|
|
|
|
typeof highlightedRevisions === 'string'
|
|
|
|
? [highlightedRevisions]
|
|
|
|
: highlightedRevisions;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zoom) {
|
|
|
|
const zoomArray = zoom.replace(/[[{}\]"]+/g, '').split(',');
|
|
|
|
const zoomObject = {
|
2020-04-30 22:40:38 +03:00
|
|
|
x: zoomArray.map((x) => new Date(parseInt(x, 10))).slice(0, 2),
|
2019-09-09 23:19:04 +03:00
|
|
|
y: zoomArray.slice(2, 4),
|
|
|
|
};
|
|
|
|
updates.zoom = zoomObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selected) {
|
|
|
|
const tooltipArray = selected.replace(/[[]"]/g, '').split(',');
|
|
|
|
const tooltipValues = processSelectedParam(tooltipArray);
|
|
|
|
updates.selectedDataPoint = tooltipValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState(updates);
|
|
|
|
};
|
|
|
|
|
2020-04-30 22:40:38 +03:00
|
|
|
createSeriesParams = (series) => {
|
2019-11-09 02:25:09 +03:00
|
|
|
const {
|
|
|
|
repository_name: repositoryName,
|
|
|
|
signature_id: signatureId,
|
|
|
|
framework_id: frameworkId,
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates,
|
2019-11-09 02:25:09 +03:00
|
|
|
} = series;
|
2019-09-09 23:19:04 +03:00
|
|
|
const { timeRange } = this.state;
|
|
|
|
|
|
|
|
return {
|
2019-11-09 02:25:09 +03:00
|
|
|
repository: repositoryName,
|
|
|
|
signature: signatureId,
|
|
|
|
framework: frameworkId,
|
2019-09-09 23:19:04 +03:00
|
|
|
interval: timeRange.value,
|
|
|
|
all_data: true,
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates,
|
2019-09-09 23:19:04 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
getTestData = async (newDisplayedTests = [], init = false) => {
|
|
|
|
const { testData } = this.state;
|
|
|
|
const tests = newDisplayedTests.length ? newDisplayedTests : testData;
|
|
|
|
this.setState({ loading: true });
|
|
|
|
|
|
|
|
const responses = await Promise.all(
|
2020-04-30 22:40:38 +03:00
|
|
|
tests.map((series) =>
|
2019-09-09 23:19:04 +03:00
|
|
|
getData(
|
2020-01-22 15:46:14 +03:00
|
|
|
createApiUrl(endpoints.summary, this.createSeriesParams(series)),
|
2019-09-09 23:19:04 +03:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
const errorMessages = processErrors(responses);
|
|
|
|
|
|
|
|
if (errorMessages.length) {
|
|
|
|
this.setState({ errorMessages, loading: false });
|
|
|
|
} else {
|
|
|
|
// If the server returns an empty array instead of signature data with data: [],
|
|
|
|
// that test won't be shown in the graph or legend; this will prevent the UI from breaking
|
|
|
|
const data = responses
|
2020-04-30 22:40:38 +03:00
|
|
|
.filter((response) => response.data.length)
|
|
|
|
.map((reponse) => reponse.data[0]);
|
2019-09-09 23:19:04 +03:00
|
|
|
let newTestData = await this.createGraphObject(data);
|
|
|
|
|
|
|
|
if (newDisplayedTests.length) {
|
|
|
|
newTestData = [...testData, ...newTestData];
|
|
|
|
}
|
2019-09-17 01:02:19 +03:00
|
|
|
this.setState(
|
|
|
|
{ testData: newTestData, loading: false, visibilityChanged: false },
|
|
|
|
() => {
|
|
|
|
if (!init) {
|
|
|
|
// we don't need to change params when getData is called on initial page load
|
|
|
|
this.changeParams();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
2019-09-09 23:19:04 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-04-30 22:40:38 +03:00
|
|
|
createGraphObject = async (seriesData) => {
|
2023-12-12 17:14:43 +03:00
|
|
|
const { colors, symbols, timeRange, replicates } = this.state;
|
2020-01-09 00:56:57 +03:00
|
|
|
const alertSummaries = await Promise.all(
|
2020-04-30 22:40:38 +03:00
|
|
|
seriesData.map((series) =>
|
2019-09-09 23:19:04 +03:00
|
|
|
this.getAlertSummaries(series.signature_id, series.repository_id),
|
|
|
|
),
|
|
|
|
);
|
2021-11-05 12:22:08 +03:00
|
|
|
const commonAlerts = await Promise.all(
|
2022-02-22 18:35:57 +03:00
|
|
|
seriesData.map((series) =>
|
|
|
|
this.getCommonAlerts(series.framework_id, timeRange.value),
|
|
|
|
),
|
2021-11-05 12:22:08 +03:00
|
|
|
);
|
2019-09-09 23:19:04 +03:00
|
|
|
const newColors = [...colors];
|
2020-01-31 18:57:21 +03:00
|
|
|
const newSymbols = [...symbols];
|
|
|
|
|
2020-01-09 00:56:57 +03:00
|
|
|
const graphData = createGraphData(
|
|
|
|
seriesData,
|
|
|
|
alertSummaries.flat(),
|
|
|
|
newColors,
|
2020-01-31 18:57:21 +03:00
|
|
|
newSymbols,
|
2021-11-05 12:22:08 +03:00
|
|
|
commonAlerts,
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates,
|
2020-01-09 00:56:57 +03:00
|
|
|
);
|
2020-01-31 18:57:21 +03:00
|
|
|
|
|
|
|
this.setState({ colors: newColors, symbols: newSymbols });
|
2019-09-09 23:19:04 +03:00
|
|
|
return graphData;
|
|
|
|
};
|
|
|
|
|
2019-11-09 02:25:09 +03:00
|
|
|
getAlertSummaries = async (signatureId, repository) => {
|
2022-02-22 18:35:57 +03:00
|
|
|
const { errorMessages, timeRange } = this.state;
|
2019-09-09 23:19:04 +03:00
|
|
|
|
2020-01-22 15:46:14 +03:00
|
|
|
const data = await getData(
|
|
|
|
createApiUrl(endpoints.alertSummary, {
|
2019-11-09 02:25:09 +03:00
|
|
|
alerts__series_signature: signatureId,
|
2019-09-09 23:19:04 +03:00
|
|
|
repository,
|
2022-02-22 18:35:57 +03:00
|
|
|
limit: alertSummaryLimit,
|
|
|
|
timerange: timeRange.value,
|
2020-01-22 15:46:14 +03:00
|
|
|
}),
|
2019-09-09 23:19:04 +03:00
|
|
|
);
|
|
|
|
const response = processResponse(data, 'alertSummaries', errorMessages);
|
|
|
|
|
|
|
|
if (response.alertSummaries) {
|
|
|
|
return response.alertSummaries.results;
|
|
|
|
}
|
|
|
|
this.setState({ errorMessages: response.errorMessages });
|
|
|
|
return [];
|
|
|
|
};
|
|
|
|
|
2022-02-22 18:35:57 +03:00
|
|
|
getCommonAlerts = async (frameworkId, timeRange) => {
|
|
|
|
const params = {
|
|
|
|
framework: frameworkId,
|
|
|
|
limit: alertSummaryLimit,
|
|
|
|
timerange: timeRange,
|
|
|
|
};
|
2021-11-05 12:22:08 +03:00
|
|
|
const url = getApiUrl(
|
|
|
|
`${endpoints.alertSummary}${createQueryParams(params)}`,
|
|
|
|
);
|
|
|
|
const response = await getData(url);
|
|
|
|
const commonAlerts = [...response.data.results];
|
|
|
|
|
|
|
|
return commonAlerts;
|
|
|
|
};
|
|
|
|
|
2019-09-09 23:19:04 +03:00
|
|
|
updateData = async (
|
2019-11-09 02:25:09 +03:00
|
|
|
signatureId,
|
|
|
|
repositoryName,
|
2019-09-09 23:19:04 +03:00
|
|
|
alertSummaryId,
|
|
|
|
dataPointIndex,
|
|
|
|
) => {
|
|
|
|
const { testData } = this.state;
|
|
|
|
|
|
|
|
const updatedData = testData.find(
|
2020-04-30 22:40:38 +03:00
|
|
|
(test) => test.signature_id === signatureId,
|
2019-09-09 23:19:04 +03:00
|
|
|
);
|
|
|
|
const alertSummaries = await this.getAlertSummaries(
|
2019-11-09 02:25:09 +03:00
|
|
|
signatureId,
|
|
|
|
repositoryName,
|
2019-09-09 23:19:04 +03:00
|
|
|
);
|
|
|
|
const alertSummary = alertSummaries.find(
|
2020-04-30 22:40:38 +03:00
|
|
|
(result) => result.id === alertSummaryId,
|
2019-09-09 23:19:04 +03:00
|
|
|
);
|
|
|
|
updatedData.data[dataPointIndex].alertSummary = alertSummary;
|
|
|
|
const newTestData = unionBy([updatedData], testData, 'signature_id');
|
|
|
|
|
|
|
|
this.setState({ testData: newTestData });
|
|
|
|
};
|
|
|
|
|
2023-12-12 17:14:43 +03:00
|
|
|
parseSeriesParam = (series, replicates) =>
|
2020-04-30 22:40:38 +03:00
|
|
|
series.map((encodedSeries) => {
|
2019-09-26 01:15:37 +03:00
|
|
|
const partialSeriesArray = encodedSeries.split(',');
|
2019-09-09 23:19:04 +03:00
|
|
|
const partialSeriesObject = {
|
|
|
|
repository_name: partialSeriesArray[0],
|
|
|
|
// TODO deprecate signature_hash
|
|
|
|
signature_id:
|
|
|
|
partialSeriesArray[1] && partialSeriesArray[1].length === 40
|
|
|
|
? partialSeriesArray[1]
|
|
|
|
: parseInt(partialSeriesArray[1], 10),
|
|
|
|
// TODO partialSeriesArray[2] is for the 1 that's inserted in the url
|
|
|
|
// for visibility of test legend cards but isn't actually being used
|
|
|
|
// to control visibility so it should be removed at some point
|
|
|
|
framework_id: parseInt(partialSeriesArray[3], 10),
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates,
|
2019-09-09 23:19:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return partialSeriesObject;
|
|
|
|
});
|
|
|
|
|
2020-04-30 22:40:38 +03:00
|
|
|
toggle = (state) => {
|
|
|
|
this.setState((prevState) => ({
|
2019-09-09 23:19:04 +03:00
|
|
|
[state]: !prevState[state],
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
2020-04-30 22:40:38 +03:00
|
|
|
updateParams = (params) => {
|
2019-09-26 01:15:37 +03:00
|
|
|
const { location, history } = this.props;
|
|
|
|
let newQueryString = queryString.stringify(params);
|
|
|
|
newQueryString = newQueryString.replace(/%2C/g, ',');
|
2019-09-09 23:19:04 +03:00
|
|
|
|
2019-09-26 01:15:37 +03:00
|
|
|
updateQueryParams(newQueryString, history, location);
|
2019-09-09 23:19:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
changeParams = () => {
|
|
|
|
const {
|
|
|
|
testData,
|
|
|
|
selectedDataPoint,
|
|
|
|
zoom,
|
|
|
|
highlightAlerts,
|
2021-11-05 12:22:08 +03:00
|
|
|
highlightCommonAlerts,
|
2020-12-18 13:06:25 +03:00
|
|
|
highlightChangelogData,
|
2019-09-09 23:19:04 +03:00
|
|
|
highlightedRevisions,
|
|
|
|
timeRange,
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates,
|
2019-09-09 23:19:04 +03:00
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
const newSeries = testData.map(
|
2020-04-30 22:40:38 +03:00
|
|
|
(series) =>
|
2019-09-09 23:19:04 +03:00
|
|
|
`${series.repository_name},${series.signature_id},1,${series.framework_id}`,
|
|
|
|
);
|
|
|
|
const params = {
|
|
|
|
series: newSeries,
|
|
|
|
highlightAlerts: +highlightAlerts,
|
2021-11-05 12:22:08 +03:00
|
|
|
highlightCommonAlerts: +highlightCommonAlerts,
|
2020-12-18 13:06:25 +03:00
|
|
|
highlightChangelogData: +highlightChangelogData,
|
2019-09-09 23:19:04 +03:00
|
|
|
timerange: timeRange.value,
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates: +replicates,
|
2019-09-09 23:19:04 +03:00
|
|
|
zoom,
|
|
|
|
};
|
|
|
|
|
2019-09-26 01:15:37 +03:00
|
|
|
const newHighlightedRevisions = highlightedRevisions.filter(
|
2020-04-30 22:40:38 +03:00
|
|
|
(rev) => rev.length,
|
2019-09-26 01:15:37 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
if (newHighlightedRevisions.length) {
|
|
|
|
params.highlightedRevisions = newHighlightedRevisions;
|
|
|
|
}
|
|
|
|
|
2019-09-09 23:19:04 +03:00
|
|
|
if (!selectedDataPoint) {
|
2019-09-26 01:15:37 +03:00
|
|
|
delete params.selected;
|
2019-09-09 23:19:04 +03:00
|
|
|
} else {
|
2020-01-09 00:56:57 +03:00
|
|
|
const { signature_id: signatureId, dataPointId } = selectedDataPoint;
|
|
|
|
|
|
|
|
params.selected = [signatureId, dataPointId].join(',');
|
2019-09-09 23:19:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Object.keys(zoom).length === 0) {
|
2019-09-26 01:15:37 +03:00
|
|
|
delete params.zoom;
|
2019-09-09 23:19:04 +03:00
|
|
|
} else {
|
2020-04-30 22:40:38 +03:00
|
|
|
params.zoom = [...zoom.x.map((z) => z.getTime()), ...zoom.y].toString();
|
2019-09-09 23:19:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
this.updateParams(params);
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
timeRange,
|
|
|
|
testData,
|
|
|
|
highlightAlerts,
|
2021-11-05 12:22:08 +03:00
|
|
|
highlightCommonAlerts,
|
2020-12-18 13:06:25 +03:00
|
|
|
highlightChangelogData,
|
2019-09-09 23:19:04 +03:00
|
|
|
highlightedRevisions,
|
|
|
|
selectedDataPoint,
|
|
|
|
loading,
|
|
|
|
errorMessages,
|
|
|
|
zoom,
|
|
|
|
options,
|
|
|
|
colors,
|
2020-01-31 18:57:21 +03:00
|
|
|
symbols,
|
2019-09-09 23:19:04 +03:00
|
|
|
showModal,
|
2020-03-04 03:11:59 +03:00
|
|
|
showTable,
|
2019-09-17 01:02:19 +03:00
|
|
|
visibilityChanged,
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates,
|
2019-09-09 23:19:04 +03:00
|
|
|
} = this.state;
|
|
|
|
|
2019-10-04 21:05:29 +03:00
|
|
|
const { projects, frameworks, user } = this.props;
|
2019-09-09 23:19:04 +03:00
|
|
|
return (
|
|
|
|
<ErrorBoundary
|
|
|
|
errorClasses={errorMessageClass}
|
|
|
|
message={genericErrorMessage}
|
|
|
|
>
|
2020-03-04 03:11:59 +03:00
|
|
|
<Container fluid className="pt-5 pr-5 pl-5">
|
2019-09-09 23:19:04 +03:00
|
|
|
{loading && <LoadingSpinner />}
|
|
|
|
|
|
|
|
{errorMessages.length > 0 && (
|
|
|
|
<Container className="pb-4 px-0 max-width-default">
|
|
|
|
<ErrorMessages errorMessages={errorMessages} />
|
|
|
|
</Container>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Row className="justify-content-center">
|
2020-03-04 03:11:59 +03:00
|
|
|
{!showTable && (
|
|
|
|
<Col
|
|
|
|
className={`${testData.length ? 'graph-chooser' : 'col-12'}`}
|
|
|
|
>
|
|
|
|
<Button
|
|
|
|
className="sr-only"
|
|
|
|
onClick={() => this.setState({ showTable: !showTable })}
|
|
|
|
>
|
|
|
|
Table View
|
|
|
|
</Button>
|
|
|
|
<Container
|
|
|
|
role="region"
|
|
|
|
aria-label="Graph Legend"
|
|
|
|
className="graph-legend pl-0 pb-4"
|
|
|
|
>
|
|
|
|
{testData.length > 0 &&
|
2020-04-30 22:40:38 +03:00
|
|
|
testData.map((series) => (
|
2020-03-04 03:11:59 +03:00
|
|
|
<div
|
|
|
|
key={`${series.name} ${series.repository_name} ${series.platform}`}
|
|
|
|
>
|
|
|
|
<LegendCard
|
|
|
|
series={series}
|
|
|
|
testData={testData}
|
|
|
|
{...this.props}
|
2020-04-30 22:40:38 +03:00
|
|
|
updateState={(state) => this.setState(state)}
|
|
|
|
updateStateParams={(state) =>
|
2020-03-04 03:11:59 +03:00
|
|
|
this.setState(state, this.changeParams)
|
|
|
|
}
|
|
|
|
colors={colors}
|
|
|
|
symbols={symbols}
|
|
|
|
selectedDataPoint={selectedDataPoint}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</Container>
|
|
|
|
</Col>
|
|
|
|
)}
|
2019-09-09 23:19:04 +03:00
|
|
|
<Col
|
|
|
|
className={`pl-0 ${
|
|
|
|
testData.length ? 'custom-col-xxl-auto' : 'col-auto'
|
2020-03-04 03:11:59 +03:00
|
|
|
} ${showTable && 'w-100'}`}
|
2019-09-09 23:19:04 +03:00
|
|
|
>
|
|
|
|
<GraphsViewControls
|
2020-03-04 03:11:59 +03:00
|
|
|
colors={colors}
|
|
|
|
symbols={symbols}
|
2019-09-09 23:19:04 +03:00
|
|
|
timeRange={timeRange}
|
|
|
|
frameworks={frameworks}
|
2019-10-04 21:05:29 +03:00
|
|
|
user={user}
|
2019-09-09 23:19:04 +03:00
|
|
|
projects={projects}
|
|
|
|
options={options}
|
|
|
|
getTestData={this.getTestData}
|
|
|
|
testData={testData}
|
|
|
|
showModal={showModal}
|
2020-03-04 03:11:59 +03:00
|
|
|
showTable={showTable}
|
2019-10-04 21:05:29 +03:00
|
|
|
highlightAlerts={highlightAlerts}
|
2020-12-18 13:06:25 +03:00
|
|
|
highlightChangelogData={highlightChangelogData}
|
2019-10-04 21:05:29 +03:00
|
|
|
highlightedRevisions={highlightedRevisions}
|
2021-11-05 12:22:08 +03:00
|
|
|
highlightCommonAlerts={highlightCommonAlerts}
|
2019-10-04 21:05:29 +03:00
|
|
|
zoom={zoom}
|
|
|
|
selectedDataPoint={selectedDataPoint}
|
2020-04-30 22:40:38 +03:00
|
|
|
updateStateParams={(state) =>
|
2019-09-09 23:19:04 +03:00
|
|
|
this.setState(state, this.changeParams)
|
|
|
|
}
|
2019-10-04 21:05:29 +03:00
|
|
|
visibilityChanged={visibilityChanged}
|
|
|
|
updateData={this.updateData}
|
|
|
|
toggle={() => this.setState({ showModal: !showModal })}
|
2020-03-04 03:11:59 +03:00
|
|
|
toggleTableView={() => this.setState({ showTable: !showTable })}
|
2023-12-12 17:14:43 +03:00
|
|
|
replicates={replicates}
|
2021-01-22 15:48:14 +03:00
|
|
|
updateTimeRange={(newTimeRange) =>
|
2019-09-09 23:19:04 +03:00
|
|
|
this.setState(
|
|
|
|
{
|
2021-01-22 15:48:14 +03:00
|
|
|
timeRange: newTimeRange,
|
2019-09-09 23:19:04 +03:00
|
|
|
zoom: {},
|
|
|
|
selectedDataPoint: null,
|
|
|
|
colors: [...graphColors],
|
2020-01-31 18:57:21 +03:00
|
|
|
symbols: [...graphSymbols],
|
2019-09-09 23:19:04 +03:00
|
|
|
},
|
|
|
|
this.getTestData,
|
|
|
|
)
|
|
|
|
}
|
2021-01-22 15:48:14 +03:00
|
|
|
updateTestsAndTimeRange={(newDisplayedTests, newTimeRange) =>
|
|
|
|
this.setState(
|
|
|
|
{
|
|
|
|
timeRange: newTimeRange,
|
|
|
|
zoom: {},
|
|
|
|
selectedDataPoint: null,
|
|
|
|
colors: [...graphColors],
|
|
|
|
symbols: [...graphSymbols],
|
|
|
|
},
|
|
|
|
() => this.getTestData(newDisplayedTests),
|
|
|
|
)
|
|
|
|
}
|
2019-09-09 23:19:04 +03:00
|
|
|
hasNoData={!testData.length && !loading}
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Container>
|
|
|
|
</ErrorBoundary>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GraphsView.propTypes = {
|
2019-09-26 01:15:37 +03:00
|
|
|
location: PropTypes.shape({
|
2019-09-09 23:19:04 +03:00
|
|
|
zoom: PropTypes.string,
|
|
|
|
selected: PropTypes.string,
|
|
|
|
highlightAlerts: PropTypes.string,
|
|
|
|
highlightedRevisions: PropTypes.oneOfType([
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.arrayOf(PropTypes.string),
|
|
|
|
]),
|
|
|
|
series: PropTypes.oneOfType([
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.arrayOf(PropTypes.string),
|
|
|
|
]),
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
GraphsView.defaultProps = {
|
2019-09-26 01:15:37 +03:00
|
|
|
location: undefined,
|
2019-09-09 23:19:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default GraphsView;
|