@@ -5,18 +5,27 @@ 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.pages.IndexAction
8
9
import jakarta.inject.Inject
9
10
import kotlinx.html.TagConsumer
11
+ import kotlinx.html.a
10
12
import kotlinx.html.div
13
+ import kotlinx.html.li
11
14
import kotlinx.html.main
15
+ import kotlinx.html.nav
16
+ import kotlinx.html.ol
17
+ import kotlinx.html.role
12
18
import kotlinx.html.script
19
+ import kotlinx.html.span
13
20
import misk.MiskCaller
14
21
import misk.hibernate.Query
15
22
import misk.hibernate.Transacter
16
23
import misk.hibernate.newQuery
17
24
import misk.hotwire.buildHtml
18
25
import misk.scope.ActionScoped
19
26
import misk.tailwind.Link
27
+ import misk.tailwind.icons.Heroicons
28
+ import misk.tailwind.icons.heroicon
20
29
import misk.tailwind.pages.MenuSection
21
30
import misk.tailwind.pages.Navbar
22
31
import misk.web.HttpCall
@@ -42,6 +51,7 @@ class DashboardPageLayout @Inject constructor(
42
51
private var newBuilder = false
43
52
private var headBlock: TagConsumer <* >.() -> Unit = {}
44
53
private var title: String = " Backfila"
54
+ private var breadcrumbLinks: List <Link > = listOf ()
45
55
46
56
private val path by lazy {
47
57
clientHttpCall.get().url.encodedPath
@@ -65,6 +75,8 @@ class DashboardPageLayout @Inject constructor(
65
75
66
76
fun headBlock (block : TagConsumer <* >.() -> Unit ) = apply { this .headBlock = block }
67
77
78
+ fun breadcrumbLinks (links : List <Link >) = apply { this .breadcrumbLinks = links }
79
+
68
80
@JvmOverloads
69
81
fun build (block : TagConsumer <* >.() -> Unit = { }): String {
70
82
check(newBuilder) {
@@ -112,6 +124,10 @@ class DashboardPageLayout @Inject constructor(
112
124
// TODO remove when new UI is stable and preferred
113
125
UseOldUIAlert ()
114
126
127
+ if (breadcrumbLinks.isNotEmpty()) {
128
+ Breadcrumbs (breadcrumbLinks)
129
+ }
130
+
115
131
block()
116
132
117
133
AlertSupport (config.support_button_label, config.support_button_url)
@@ -202,6 +218,37 @@ class DashboardPageLayout @Inject constructor(
202
218
}
203
219
}
204
220
221
+ private fun TagConsumer <* >.Breadcrumbs (links : List <Link >) {
222
+ nav(" flex" ) {
223
+ attributes[" aria-label" ] = " Breadcrumb"
224
+ ol(" flex items-center space-x-4" ) {
225
+ role = " list"
226
+ li {
227
+ div {
228
+ a(classes = " text-gray-400 hover:text-gray-500" ) {
229
+ href = IndexAction .PATH
230
+
231
+ heroicon(Heroicons .OUTLINE_HOME )
232
+ span(" sr-only" ) { + """ Home""" }
233
+ }
234
+ }
235
+ }
236
+ links.forEach {
237
+ li {
238
+ div(" flex items-center" ) {
239
+ // TODO upstream chevron_right and use instead
240
+ heroicon(Heroicons .MINI_ARROW_LONG_RIGHT )
241
+ a(classes = " ml-4 text-sm font-medium text-gray-500 hover:text-gray-700" ) {
242
+ href = it.href
243
+ + it.label
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
249
+ }
250
+ }
251
+
205
252
companion object {
206
253
}
207
254
}
0 commit comments