perf: plumb repository into UI links

Change-Id: I8b50359ff887b35912143954f10fb03944318b2e
Reviewed-on: https://go-review.googlesource.com/c/build/+/462975
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
diff --git a/perf/app/dashboard/index.html b/perf/app/dashboard/index.html
index e21cc97..88779e0 100644
--- a/perf/app/dashboard/index.html
+++ b/perf/app/dashboard/index.html
@@ -122,7 +122,7 @@
 	loading.parentNode.removeChild(loading);
 }
 
-function addCharts(benchmarks) {
+function addCharts(benchmarks, repository) {
 	let dashboard = document.getElementById("dashboard");
 
 	removeLoadingMessage();
@@ -158,13 +158,14 @@
 		item.appendChild(BandChart(bench.Values, {
 			benchmark: bench.Name,
 			unit: bench.Unit,
+			repository: repository,
 			minViewDeltaPercent: minViewDeltaPercent,
 		}));
 		grid.appendChild(item);
 	}
 }
 
-function addTable(bench, unit) {
+function addTable(bench, unit, repository) {
 	let dashboard = document.getElementById("dashboard");
 
 	removeLoadingMessage();
@@ -245,7 +246,7 @@
 		// Commit hash.
 		const commitHash = createCell("", false);
 		const commitLink = document.createElement("a");
-		commitLink.href = "https://go.googlesource.com/go/+show/" + v.CommitHash;
+		commitLink.href = "https://go.googlesource.com/" + repository + "/+show/" + v.CommitHash;
 		commitLink.textContent = v.CommitHash.slice(0, 7);
 		commitHash.appendChild(commitLink);
 		commitHash.classList.add("Dashboard-table-commit")
@@ -331,6 +332,10 @@
 }
 prefillSearch()
 
+// Grab the repository so we can plumb it into UI elements.
+// prefillSearch set this up for us just now.
+const repository = document.getElementById('repository-select').value;
+
 // Fetch content.
 let benchmark = (new URLSearchParams(window.location.search)).get('benchmark');
 let unit = (new URLSearchParams(window.location.search)).get('unit');
@@ -357,9 +362,9 @@
 				failure(benchmark, "got more that one benchmark when a unit was specified");
 				throw new Error("Data fetch failed");
 			}
-			addTable(benchmarks[0], unit);
+			addTable(benchmarks[0], unit, repository);
 		} else {
-			addCharts(benchmarks);
+			addCharts(benchmarks, repository);
 		}
 	});
 </script>
diff --git a/third_party/bandchart/bandchart.js b/third_party/bandchart/bandchart.js
index 67e36e5..279d3fc 100644
--- a/third_party/bandchart/bandchart.js
+++ b/third_party/bandchart/bandchart.js
@@ -12,6 +12,7 @@
 	height = 240, // outer height, in pixels
 	benchmark,
 	unit,
+	repository,
 	minViewDeltaPercent,
 } = {}) {
 	// Compute values.
@@ -252,7 +253,7 @@
 		.selectAll("path")
 		.data(I)
 		.join("a")
-			.attr("xlink:href", (d, i) => "https://go.googlesource.com/go/+show/"+C[i])
+			.attr("xlink:href", (d, i) => "https://go.googlesource.com/"+repository+"/+show/"+C[i])
 			.append("rect")
 				.attr("pointer-events", "all")
 				.attr("x", (d, i) => {