@@ -5,6 +5,7 @@ import app.cash.backfila.service.BackfilaConfig
5
5
import app.cash.backfila.service.persistence.BackfilaDb
6
6
import app.cash.backfila.service.persistence.BackfillRunQuery
7
7
import app.cash.backfila.service.persistence.BackfillState
8
+ import app.cash.backfila.ui.BackfilaDashboard
8
9
import app.cash.backfila.ui.pages.IndexAction
9
10
import jakarta.inject.Inject
10
11
import kotlinx.html.TagConsumer
@@ -30,6 +31,7 @@ import misk.tailwind.pages.MenuSection
30
31
import misk.tailwind.pages.Navbar
31
32
import misk.web.HttpCall
32
33
import misk.web.ResponseBody
34
+ import misk.web.dashboard.DashboardTab
33
35
import misk.web.dashboard.HtmlLayout
34
36
import okio.BufferedSink
35
37
import wisp.deployment.Deployment
@@ -47,6 +49,7 @@ class DashboardPageLayout @Inject constructor(
47
49
private val getBackfillRunsAction : GetBackfillRunsAction ,
48
50
@BackfilaDb private val transacter : Transacter ,
49
51
private val queryFactory : Query .Factory ,
52
+ private val allTabs : List <DashboardTab >,
50
53
) {
51
54
private var newBuilder = false
52
55
private var headBlock: TagConsumer <* >.() -> Unit = {}
@@ -57,6 +60,10 @@ class DashboardPageLayout @Inject constructor(
57
60
clientHttpCall.get().url.encodedPath
58
61
}
59
62
63
+ private val backfilaLinks by lazy {
64
+ allTabs.filter { it.dashboardAnnotationKClass == BackfilaDashboard ::class }
65
+ }
66
+
60
67
private fun setNewBuilder () = apply { newBuilder = true }
61
68
62
69
fun newBuilder (): DashboardPageLayout = DashboardPageLayout (
@@ -67,6 +74,7 @@ class DashboardPageLayout @Inject constructor(
67
74
getBackfillRunsAction = getBackfillRunsAction,
68
75
transacter = transacter,
69
76
queryFactory = queryFactory,
77
+ allTabs = allTabs,
70
78
).setNewBuilder()
71
79
72
80
fun title (title : String ) = apply {
@@ -181,9 +189,30 @@ class DashboardPageLayout @Inject constructor(
181
189
href = " /backfills/" ,
182
190
isSelected = currentPath == " /backfills/" ,
183
191
),
184
- ),
192
+ ) + backfilaLinks.filter { it.menuCategory == " Backfila" }.map { tab ->
193
+ Link (
194
+ label = tab.menuLabel,
195
+ href = tab.menuUrl,
196
+ isSelected = currentPath.startsWith(tab.menuUrl),
197
+ )
198
+ },
185
199
),
186
- ) + if (services.isNotEmpty()) {
200
+ ) + if (backfilaLinks.filterNot { it.menuCategory == " Backfila" }.isNotEmpty()) {
201
+ backfilaLinks.filterNot { it.menuCategory == " Backfila" }.groupBy { it.menuCategory }.map { (category, tabs) ->
202
+ MenuSection (
203
+ title = category,
204
+ links = tabs.map { tab ->
205
+ Link (
206
+ label = tab.menuLabel,
207
+ href = tab.menuUrl,
208
+ isSelected = currentPath.startsWith(tab.menuUrl),
209
+ )
210
+ },
211
+ )
212
+ }
213
+ } else {
214
+ listOf ()
215
+ } + if (services.isNotEmpty()) {
187
216
listOf (
188
217
MenuSection (
189
218
title = " Your Services" ,
0 commit comments