Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions ui/perfherder/graphs/GraphsView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function GraphsView({ projects, frameworks, user }) {
repository_name: repositoryName,
signature_id: signatureId,
framework_id: frameworkId,
replicates: seriesReplicates,
} = series;

return {
Expand All @@ -111,7 +110,7 @@ function GraphsView({ projects, frameworks, user }) {
framework: frameworkId,
interval: timeRangeRef.current.value,
all_data: true,
replicates: seriesReplicates,
replicates: replicatesRef.current,
};
}, []);

Expand Down Expand Up @@ -319,6 +318,10 @@ function GraphsView({ projects, frameworks, user }) {
);

const updateStateParams = useCallback((state) => {
const replicatesChanged =
state.replicates !== undefined &&
state.replicates !== replicatesRef.current;

if (state.testData !== undefined) setTestData(state.testData);
if (state.selectedDataPoint !== undefined)
setSelectedDataPoint(state.selectedDataPoint);
Expand All @@ -335,11 +338,24 @@ function GraphsView({ projects, frameworks, user }) {
setHighlightedRevisions(state.highlightedRevisions);
if (state.visibilityChanged !== undefined)
setVisibilityChanged(state.visibilityChanged);
if (state.replicates !== undefined) setReplicates(state.replicates);
if (state.colors !== undefined) setColors(state.colors);
if (state.symbols !== undefined) setSymbols(state.symbols);
pendingChangeParams.current = true;
}, []);

if (state.replicates !== undefined) {
setReplicates(state.replicates);
replicatesRef.current = state.replicates;
}

if (replicatesChanged) {
setZoom({});
setSelectedDataPoint(null);
setColors([...graphColors]);
setSymbols([...graphSymbols]);
getTestData();
} else {
pendingChangeParams.current = true;
}
}, [getTestData]);

// componentDidMount - check query params
useEffect(() => {
Expand All @@ -357,6 +373,11 @@ function GraphsView({ projects, frameworks, user }) {

const updates = {};

if (replicatesParam) {
updates.replicates = Boolean(parseInt(replicatesParam, 10));
replicatesRef.current = updates.replicates;
}

if (series) {
const _series = typeof series === 'string' ? [series] : series;
const seriesParams = parseSeriesParam(
Expand All @@ -380,9 +401,6 @@ function GraphsView({ projects, frameworks, user }) {
parseInt(hlInitialDataPoints, 10),
);
}
if (replicatesParam) {
updates.replicates = Boolean(parseInt(replicatesParam, 10));
}
if (hlRevisions) {
updates.highlightedRevisions =
typeof hlRevisions === 'string' ? [hlRevisions] : hlRevisions;
Expand Down Expand Up @@ -423,24 +441,13 @@ function GraphsView({ projects, frameworks, user }) {

if (prevSearch === location.search) return;

const { replicates: currentReplicates } = queryString.parse(
location.search,
);
const { replicates: prevReplicates } = queryString.parse(prevSearch);

if (
location.search === '' &&
testDataRef.current.length !== 0 &&
!loading
) {
setTestData([]);
}

if (prevReplicates !== undefined) {
if (currentReplicates !== prevReplicates) {
window.location.reload(false);
}
}
}, [location.search, loading]);

const handleUpdateTimeRange = useCallback(
Expand Down