Skip to content

Commit 244260b

Browse files
committed
Bug 1901066 - Make graph tooltip view link to treeherder filter to just the single job
1 parent 7f54826 commit 244260b

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

ui/perfherder/graphs/GraphTooltip.jsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useLayoutEffect, useRef, useState } from 'react';
1+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import countBy from 'lodash/countBy';
44
import { Button } from 'react-bootstrap';
@@ -27,6 +27,9 @@ import { notify } from '../../shared/stores/notificationStore';
2727
import { getAction } from '../../helpers/taskcluster';
2828
import { formatTaskclusterError } from '../../helpers/errorMessage';
2929

30+
// Cache job.searchStr so we can hover over multiple data points
31+
const jobSearchStrCache = new Map();
32+
3033
const GraphTooltip = ({
3134
testData,
3235
infraAffectedData,
@@ -115,11 +118,41 @@ const GraphTooltip = ({
115118
});
116119
}
117120

121+
const cacheKey = `${testDetails.repository_name}/${dataPointDetails.jobId}`;
122+
const [jobSearchStr, setJobSearchStr] = useState(
123+
dataPointDetails.jobId ? jobSearchStrCache.get(cacheKey) || '' : '',
124+
);
125+
126+
useEffect(() => {
127+
if (!dataPointDetails.jobId) return undefined;
128+
129+
if (jobSearchStrCache.has(cacheKey)) {
130+
setJobSearchStr(jobSearchStrCache.get(cacheKey));
131+
return undefined;
132+
}
133+
134+
let cancelled = false;
135+
JobModel.get(testDetails.repository_name, dataPointDetails.jobId)
136+
.then((job) => {
137+
const searchStr = job.searchStr || '';
138+
jobSearchStrCache.set(cacheKey, searchStr);
139+
if (!cancelled) setJobSearchStr(searchStr);
140+
})
141+
.catch(() => {
142+
if (!cancelled) setJobSearchStr('');
143+
});
144+
145+
return () => {
146+
cancelled = true;
147+
};
148+
}, [cacheKey, dataPointDetails.jobId, testDetails.repository_name]);
149+
118150
const jobsUrl = getJobsUrl({
119151
repo: testDetails.repository_name,
120152
revision: dataPointDetails.revision,
121153
selectedJob: dataPointDetails.jobId,
122154
group_state: 'expanded',
155+
...(jobSearchStr ? { searchStr: jobSearchStr.split(' ') } : {}),
123156
});
124157

125158
const createAlert = async () => {

0 commit comments

Comments
 (0)