diff --git a/pages/index.js b/pages/index.js
index 03730ce..274abac 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -5,17 +5,20 @@ import Head from "next/head";
import { weatherTemplate, getWeatherIndex } from "../components/weatherTemplate";
import { OverlayPanel } from 'primereact/overlaypanel';
import MaintainerMapping from "../maintainers.yml";
+import { basePath } from "../next.config.js";
export default function Home() {
const [loading, setLoading] = useState(true);
const [checks, setChecks] = useState([]);
const [jobs, setJobs] = useState([]);
- const [rowsPR, setRowsPR] = useState([]);
- const [rowsNightly, setRowsNightly] = useState([]);
+ const [rowsSingle, setRowsSingle] = useState([]);
+ const [rowsPR, setRowsPR] = useState([]);
+ const [rowsNightly, setRowsNightly] = useState([]);
const [expandedRows, setExpandedRows] = useState([]);
const [requiredFilter, setRequiredFilter] = useState(false);
- const [display, setDisplay] = useState("nightly");
+ const [display, setDisplay] = useState("nightly");
+ const [selectedPR, setSelectedPR] = useState("");
useEffect(() => {
const fetchData = async () => {
@@ -53,6 +56,19 @@ export default function Home() {
fetchData();
}, []);
+ // Set the display based on the URL.
+ useEffect(() => {
+ const initialDisplay = new URLSearchParams(window.location.search).get("display");
+ if (initialDisplay) {
+ if(initialDisplay === "prsingle"){
+ const initialPR = new URLSearchParams(window.location.search).get("pr");
+ if(initialPR){
+ setSelectedPR(initialPR);
+ }
+ }
+ setDisplay(initialDisplay);
+ }
+ }, []);
// Filter based on required tag.
const filterRequired = (filteredJobs) => {
@@ -103,12 +119,47 @@ export default function Home() {
setLoading(false);
}, [checks, requiredFilter]);
+ // Filter and set the rows for Single PR view.
+ useEffect(() => {
+ setLoading(true);
+
+ let filteredData = filterRequired(checks);
+
+ filteredData = filteredData.map((check) => {
+ // Only if the check include the run number, add it to the data.
+ const index = check.run_nums.indexOf(Number(selectedPR));
+ return index !== -1
+ ? {
+ name: check.name,
+ required: check.required,
+ result: check.results[index],
+ runs: check.reruns[index] + 1,
+ }
+ : null;
+ }).filter(Boolean);
+
+ setRowsSingle(filteredData);
+ setLoading(false);
+ }, [checks, selectedPR, requiredFilter]);
+
// Close all rows on view switch.
// Needed because if view is switched, breaks expanded row toggling.
useEffect(() => {
setExpandedRows([])
}, [display]);
+ // Update the URL on display change
+ const updateUrl = (view, pr) => {
+ const path = new URLSearchParams();
+ path.append("display", view);
+ // Add PR number Single PR view and a PR is provided
+ if (view === "prsingle" && pr) {
+ path.append("pr", pr);
+ }
+ // Update the URL without reloading
+ window.history.pushState({}, '', `${basePath}/?${path.toString()}`);
+ };
+
const toggleRow = (rowData) => {
const isRowExpanded = expandedRows.includes(rowData);
@@ -432,6 +483,46 @@ export default function Home() {
);
+ // Make a list of all unique run numbers in the check data.
+ const runNumOptions = [...new Set(checks.flatMap(check => check.run_nums))].sort((a, b) => b - a);
+
+ // Render table for prsingle view
+ const renderSingleViewTable = () => (
+