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:
co-authored by
Claude Fable 5
parent
2cb6b1598a
commit
a03f85bc17
@@ -80,6 +80,8 @@ data class BuildRowView(
|
|||||||
val branchUrl: String?,
|
val branchUrl: String?,
|
||||||
val commitUrl: String?,
|
val commitUrl: String?,
|
||||||
val latestGreenUrl: String? = null,
|
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 {
|
companion object {
|
||||||
fun from(
|
fun from(
|
||||||
@@ -96,6 +98,7 @@ data class BuildRowView(
|
|||||||
artifactKey = result.artifactKey,
|
artifactKey = result.artifactKey,
|
||||||
branchUrl = links.branchUrl(result.branch),
|
branchUrl = links.branchUrl(result.branch),
|
||||||
commitUrl = links.commitUrl(result.commit),
|
commitUrl = links.commitUrl(result.commit),
|
||||||
|
inProgress = !result.status.isTerminal,
|
||||||
)
|
)
|
||||||
|
|
||||||
/** A branches-view row; never-built branches have no timestamps and no artifact. */
|
/** 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),
|
branchUrl = links.branchUrl(entry.branch),
|
||||||
commitUrl = links.commitUrl(entry.commit),
|
commitUrl = links.commitUrl(entry.commit),
|
||||||
latestGreenUrl = entry.latestGreenUrl,
|
latestGreenUrl = entry.latestGreenUrl,
|
||||||
|
inProgress = entry.status == "running" || entry.status == "pending",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,9 +241,10 @@ function renderBuildRow(build, allowRestart) {
|
|||||||
const artifactsCell = elem("td");
|
const artifactsCell = elem("td");
|
||||||
artifactsCell.dataset.label = "Artifacts";
|
artifactsCell.dataset.label = "Artifacts";
|
||||||
if (build.artifactKey) {
|
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.href = "/builds/" + encodeURIComponent(build.artifactKey);
|
||||||
artifactLink.title = "Open artifacts";
|
artifactLink.title = inProgress ? "Open build log — no artifacts yet" : "Open artifacts";
|
||||||
artifactsCell.appendChild(artifactLink);
|
artifactsCell.appendChild(artifactLink);
|
||||||
}
|
}
|
||||||
if (build.latestGreenUrl) {
|
if (build.latestGreenUrl) {
|
||||||
|
|||||||
@@ -52,7 +52,9 @@
|
|||||||
<td class="duration-cell" data-label="Duration" th:text="${row.duration}">1:23</td>
|
<td class="duration-cell" data-label="Duration" th:text="${row.duration}">1:23</td>
|
||||||
<td data-label="Artifacts">
|
<td data-label="Artifacts">
|
||||||
<a th:if="${row.artifactKey != ''}" class="artifact-link"
|
<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"
|
<a th:if="${row.latestGreenUrl != null}" class="artifact-link"
|
||||||
th:href="${row.latestGreenUrl}"
|
th:href="${row.latestGreenUrl}"
|
||||||
title="Permanent link: artifacts of the latest green build">🔗</a>
|
title="Permanent link: artifacts of the latest green build">🔗</a>
|
||||||
|
|||||||
@@ -39,5 +39,27 @@ class UiViewsTest : FunSpec() {
|
|||||||
links.branchUrl("main") shouldBe null
|
links.branchUrl("main") shouldBe null
|
||||||
links.commitUrl("0123abc") 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user