diff --git a/src/main/kotlin/de/hoennig/gittally/server/UiViews.kt b/src/main/kotlin/de/hoennig/gittally/server/UiViews.kt index 1c19cbf..3d7f347 100644 --- a/src/main/kotlin/de/hoennig/gittally/server/UiViews.kt +++ b/src/main/kotlin/de/hoennig/gittally/server/UiViews.kt @@ -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", ) } } diff --git a/src/main/resources/static/gittally.js b/src/main/resources/static/gittally.js index acba770..72da677 100644 --- a/src/main/resources/static/gittally.js +++ b/src/main/resources/static/gittally.js @@ -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) { diff --git a/src/main/resources/templates/builds.html b/src/main/resources/templates/builds.html index 4947450..9722981 100644 --- a/src/main/resources/templates/builds.html +++ b/src/main/resources/templates/builds.html @@ -52,7 +52,9 @@ 1:23 📄 + th:href="'/builds/' + ${row.artifactKey}" + th:text="${row.inProgress} ? '⏳' : '📄'" + th:title="${row.inProgress} ? 'Open build log — no artifacts yet' : 'Open artifacts'">📄 🔗 diff --git a/src/test/kotlin/de/hoennig/gittally/server/UiViewsTest.kt b/src/test/kotlin/de/hoennig/gittally/server/UiViewsTest.kt index 6a6b446..3e932cc 100644 --- a/src/test/kotlin/de/hoennig/gittally/server/UiViewsTest.kt +++ b/src/test/kotlin/de/hoennig/gittally/server/UiViewsTest.kt @@ -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 + } } }