Skip to content

Commit 943cb33

Browse files
committed
Extract a component for rendering benchmark request tag as commit SHA link
1 parent 9e2dffd commit 943cb33

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

site/frontend/src/pages/status_new/collector.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
<script setup lang="tsx">
22
import {h, ref, Ref} from "vue";
33
import {parseISO, differenceInHours} from "date-fns";
4-
import {formatISODate, shortenTag} from "../../utils/formatting";
5-
import {CollectorConfig, BenchmarkJobStatus, isJobComplete} from "./data";
4+
import {formatISODate} from "../../utils/formatting";
5+
import {
6+
CollectorConfig,
7+
BenchmarkJobStatus,
8+
isJobComplete,
9+
BenchmarkJob,
10+
} from "./data";
11+
import CommitSha from "./commit-sha.vue";
612
713
const props = defineProps<{
814
collector: CollectorConfig;
@@ -163,6 +169,7 @@ function toggleShowJobs() {
163169
<tr v-if="ACTIVE_FILTERS[job.status]">
164170
<td class="table-cell-padding">
165171
{{ shortenTag(job.requestTag) }}
172+
<CommitSha :tag="job.requestTag"></CommitSha>
166173
</td>
167174
<td class="table-cell-padding">
168175
{{ formatJobStatus(job.status) }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script setup lang="ts">
2+
import {computed} from "vue";
3+
4+
const props = defineProps<{
5+
tag: string;
6+
}>();
7+
8+
const looksLikeSha = computed(() => props.tag.length === 40);
9+
</script>
10+
11+
<template>
12+
<a
13+
v-if="looksLikeSha"
14+
:href="'https://github.com/rust-lang/rust/commit/' + tag"
15+
>
16+
{{ tag.substring(0, 13) }}
17+
</a>
18+
<template v-else>
19+
{{ tag }}
20+
</template>
21+
</template>

site/frontend/src/pages/status_new/page.vue

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
StatusResponse,
1515
} from "./data";
1616
import Collector from "./collector.vue";
17+
import CommitSha from "./commit-sha.vue";
1718
1819
const loading = ref(true);
1920
@@ -116,18 +117,6 @@ function PullRequestLink({request}: {request: BenchmarkRequest}) {
116117
);
117118
}
118119
119-
function CommitSha({request}: {request: BenchmarkRequest}): string {
120-
if (request.requestType === "Release") {
121-
return request.tag;
122-
}
123-
const sha = request.tag;
124-
return (
125-
<a href={`https://github.com/rust-lang/rust/commit/${sha}`}>
126-
{sha.substring(0, 13)}
127-
</a>
128-
);
129-
}
130-
131120
function RequestProgress({
132121
request,
133122
collectors,
@@ -197,7 +186,7 @@ loadStatusData(loading);
197186
<tr :class="getRequestRowClassName(req)">
198187
<td><PullRequestLink :request="req" /></td>
199188
<td>{{ req.requestType }}</td>
200-
<td><CommitSha :request="req" /></td>
189+
<td><CommitSha :tag="req.tag"></CommitSha></td>
201190
<td>
202191
{{ formatStatus(req.status)
203192
}}{{

site/frontend/src/utils/formatting.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,3 @@ export function formatISODate(dateString?: string): string {
2727
}
2828
return "";
2929
}
30-
31-
// Shorten a tag, only commit shas will be truncated
32-
export function shortenTag(tag: string): string {
33-
if (tag.length < 40) {
34-
return tag;
35-
}
36-
return tag.slice(0, 12);
37-
}

0 commit comments

Comments
 (0)