Skip to content

Commit 55949c3

Browse files
committed
Render quick links with normal HTML instead of JS
This basically reverts c7f618f, and applies the quick link refresh logic also for the runtime tab. I didn't realize before that using JS for the links makes it impossible to quickly open multiple metrics in a new tab, which is quite useful.
1 parent cd1af30 commit 55949c3

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

site/frontend/src/pages/compare/compile/compile-page.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@ function storeFilterToUrl(
161161
function updateFilter(newFilter: CompileBenchmarkFilter) {
162162
storeFilterToUrl(newFilter, defaultCompileFilter, getUrlParams());
163163
filter.value = newFilter;
164+
refreshQuickLinks();
165+
}
166+
167+
/**
168+
* When the filter changes, the URL is updated.
169+
* After that happens, we want to re-render the quick links component, because
170+
* it contains links that are "relative" to the current URL. Changing this
171+
* key ref will cause it to be re-rendered.
172+
*/
173+
function refreshQuickLinks() {
174+
quickLinksKey.value += 1;
164175
}
165176
166177
function exportData() {
@@ -169,6 +180,7 @@ function exportData() {
169180
170181
const urlParams = getUrlParams();
171182
183+
const quickLinksKey = ref(0);
172184
const filter = ref(loadFilterFromUrl(urlParams, defaultCompileFilter));
173185
174186
const benchmarkMap = createCompileBenchmarkMap(props.data);
@@ -187,6 +199,7 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
187199

188200
<template>
189201
<MetricSelector
202+
:key="quickLinksKey"
190203
:quick-links="importantCompileMetrics"
191204
:selected-metric="selector.stat"
192205
:metrics="benchmarkInfo.compile_metrics"

site/frontend/src/pages/compare/metric-selector.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ const props = defineProps<{
1212
metrics: string[];
1313
}>();
1414
15-
function navigateToMetric(metric: string) {
15+
function createUrlForMetric(metric: string): URL {
1616
const params = {stat: metric};
17-
const url = createUrlWithAppendedParams(params);
18-
navigateToUrlParams(url.searchParams);
17+
return createUrlWithAppendedParams(params);
1918
}
2019
2120
function changeMetric(e: Event) {
2221
const target = e.target as HTMLSelectElement;
2322
const metric = target.value;
24-
navigateToMetric(metric);
23+
navigateToUrlParams(createUrlForMetric(metric).searchParams);
2524
}
2625
</script>
2726

@@ -33,7 +32,7 @@ function changeMetric(e: Event) {
3332
:class="{active: props.selectedMetric === metric.metric}"
3433
:title="metric.description"
3534
>
36-
<a href="#" @click.prevent="() => navigateToMetric(metric.metric)">{{
35+
<a :href="createUrlForMetric(metric.metric).toString()">{{
3736
metric.label
3837
}}</a>
3938
</div>

site/frontend/src/pages/compare/runtime/runtime-page.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,22 @@ function storeFilterToUrl(
7373
function updateFilter(newFilter: RuntimeBenchmarkFilter) {
7474
storeFilterToUrl(newFilter, defaultRuntimeFilter, getUrlParams());
7575
filter.value = newFilter;
76+
refreshQuickLinks();
77+
}
78+
79+
/**
80+
* When the filter changes, the URL is updated.
81+
* After that happens, we want to re-render the quick links component, because
82+
* it contains links that are "relative" to the current URL. Changing this
83+
* key ref will cause it to be re-rendered.
84+
*/
85+
function refreshQuickLinks() {
86+
quickLinksKey.value += 1;
7687
}
7788
7889
const urlParams = getUrlParams();
90+
91+
const quickLinksKey = ref(0);
7992
const filter = ref(loadFilterFromUrl(urlParams, defaultRuntimeFilter));
8093
8194
const allComparisons = computed(() =>
@@ -92,6 +105,7 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
92105

93106
<template>
94107
<MetricSelector
108+
:key="quickLinksKey"
95109
:quick-links="importantRuntimeMetrics"
96110
:selected-metric="selector.stat"
97111
:metrics="benchmarkInfo.runtime_metrics"

0 commit comments

Comments
 (0)