Show a log-only artifact icon while a build is running or pending

An in-progress build's artifact page only offers the build command and log —
the table now shows an hourglass instead of the document icon (server-rendered
rows and the JS-rendered rows alike) until the build finishes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
mhoennig
2026-08-10 15:48:30 +02:00
co-authored by Claude Fable 5
parent 2cb6b1598a
commit a03f85bc17
4 changed files with 32 additions and 3 deletions
@@ -80,6 +80,8 @@ data class BuildRowView(
val branchUrl: String?,
val commitUrl: String?,
val latestGreenUrl: String? = null,
/** True while the build has no artifacts yet — the artifact link then shows the log-only icon. */
val inProgress: Boolean = false,
) {
companion object {
fun from(
@@ -96,6 +98,7 @@ data class BuildRowView(
artifactKey = result.artifactKey,
branchUrl = links.branchUrl(result.branch),
commitUrl = links.commitUrl(result.commit),
inProgress = !result.status.isTerminal,
)
/** A branches-view row; never-built branches have no timestamps and no artifact. */
@@ -114,6 +117,7 @@ data class BuildRowView(
branchUrl = links.branchUrl(entry.branch),
commitUrl = links.commitUrl(entry.commit),
latestGreenUrl = entry.latestGreenUrl,
inProgress = entry.status == "running" || entry.status == "pending",
)
}
}
+3 -2
View File
@@ -241,9 +241,10 @@ function renderBuildRow(build, allowRestart) {
const artifactsCell = elem("td");
artifactsCell.dataset.label = "Artifacts";
if (build.artifactKey) {
const artifactLink = elem("a", "artifact-link", "📄");
const inProgress = build.status === "running" || build.status === "pending";
const artifactLink = elem("a", "artifact-link", inProgress ? "⏳" : "📄");
artifactLink.href = "/builds/" + encodeURIComponent(build.artifactKey);
artifactLink.title = "Open artifacts";
artifactLink.title = inProgress ? "Open build log — no artifacts yet" : "Open artifacts";
artifactsCell.appendChild(artifactLink);
}
if (build.latestGreenUrl) {
+3 -1
View File
@@ -52,7 +52,9 @@
<td class="duration-cell" data-label="Duration" th:text="${row.duration}">1:23</td>
<td data-label="Artifacts">
<a th:if="${row.artifactKey != ''}" class="artifact-link"
th:href="'/builds/' + ${row.artifactKey}" title="Open artifacts">📄</a>
th:href="'/builds/' + ${row.artifactKey}"
th:text="${row.inProgress} ? '⏳' : '📄'"
th:title="${row.inProgress} ? 'Open build log — no artifacts yet' : 'Open artifacts'">📄</a>
<a th:if="${row.latestGreenUrl != null}" class="artifact-link"
th:href="${row.latestGreenUrl}"
title="Permanent link: artifacts of the latest green build">🔗</a>
@@ -39,5 +39,27 @@ class UiViewsTest : FunSpec() {
links.branchUrl("main") shouldBe null
links.commitUrl("0123abc") shouldBe null
}
test("rows are in progress while running or pending, so the artifact link shows the log-only icon") {
val links = GiteaWebLinks(GiteaConfig())
fun row(status: String) =
BuildRowView.from(
BranchDto(
branch = "main",
commit = "0123abc",
status = status,
startedAt = null,
durationSeconds = null,
artifactKey = "some-key",
),
links,
)
row("running").inProgress shouldBe true
row("pending").inProgress shouldBe true
row("success").inProgress shouldBe false
row("failed").inProgress shouldBe false
}
}
}