Skip to content

Commit bd18c84

Browse files
authored
1 parent e17cace commit bd18c84

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

torchci/pages/failure.tsx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import dayjs from "dayjs";
22
import utc from "dayjs/plugin/utc";
33
dayjs.extend(utc);
44

5+
import { CSSProperties, useState } from "react";
56
import { useRouter } from "next/router";
67
import useSWR from "swr";
78
import { BarChart, Bar, CartesianGrid, Tooltip, XAxis, YAxis } from "recharts";
@@ -14,7 +15,6 @@ import { usePreference } from "lib/useGroupingPreference";
1415
import { ParamSelector } from "lib/ParamSelector";
1516

1617
const fetcher = (url: string) => fetch(url).then((res) => res.json());
17-
import { CSSProperties } from "react";
1818

1919
function FuzzySearchCheckBox({
2020
useFuzzySearch,
@@ -51,6 +51,11 @@ function FailureInfo({
5151
jobCount: { [jobName: string]: number };
5252
samples: JobData[];
5353
}) {
54+
const [jobsToShow, setJobsToShow] = useState(new Set<string>());
55+
const samplesToShow = samples.filter((sample) => {
56+
return jobsToShow.size == 0 || (sample.name && jobsToShow.has(sample.name));
57+
});
58+
5459
// Populate the last 14 days
5560
const dayBuckets: Map<
5661
string,
@@ -69,7 +74,7 @@ function FailureInfo({
6974
highlighted.add("main");
7075

7176
const branchNames = new Set<string>(highlighted);
72-
samples.forEach((job, i) => {
77+
samplesToShow.forEach((job, i) => {
7378
const time = dayjs(job.time!).local().format("MM/D");
7479
if (!dayBuckets.has(time)) {
7580
return;
@@ -208,7 +213,26 @@ function FailureInfo({
208213
return jobAName.localeCompare(jobBName);
209214
})
210215
.map(([job, count]) => (
211-
<tr key={job}>
216+
<tr
217+
key={job}
218+
onClick={() => {
219+
if (jobsToShow.has(job)) {
220+
const newSet = new Set(jobsToShow);
221+
newSet.delete(job);
222+
setJobsToShow(newSet);
223+
} else {
224+
setJobsToShow(new Set(jobsToShow).add(job));
225+
}
226+
}}
227+
>
228+
<td>
229+
<input
230+
type="checkbox"
231+
name={`show-${job}`}
232+
checked={jobsToShow.has(job)}
233+
onChange={() => {}}
234+
></input>
235+
</td>
212236
<td>{job}</td>
213237
<td>{count as number}</td>
214238
</tr>
@@ -218,7 +242,7 @@ function FailureInfo({
218242
</div>
219243
<h3>Failures ({totalCount} total)</h3>
220244
<ul>
221-
{samples
245+
{samplesToShow
222246
// Keep the most recent samples on top
223247
.sort(function (sampleA: JobData, sampleB: JobData) {
224248
if (sampleA.time == sampleB.time) {

0 commit comments

Comments
 (0)