Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ class GetBackfillRunsAction @Inject constructor(
@QueryParam pagination_token: String? = null,
@QueryParam backfill_name: String? = null,
@QueryParam created_by_user: String? = null,
@QueryParam show_deleted: Boolean = false,
): GetBackfillRunsResponse {
val filterArgs = FilterArgs(
backfillName = backfill_name,
createdByUser = created_by_user,
showDeleted = show_deleted,
)
return search(service, variant, pagination_token, filterArgs)
}
Expand All @@ -83,7 +85,7 @@ class GetBackfillRunsAction @Inject constructor(
val runningBackfills = queryFactory.newQuery<BackfillRunQuery>()
.serviceId(dbService.id)
.state(BackfillState.RUNNING)
.notSoftDeleted()
.apply { if (!filterArgs.showDeleted) notSoftDeleted() }
.orderByIdDesc()
.filterByArgs(filterArgs)
.list(session)
Expand All @@ -103,7 +105,7 @@ class GetBackfillRunsAction @Inject constructor(
val (pausedBackfills, nextOffset) = queryFactory.newQuery<BackfillRunQuery>()
.serviceId(dbService.id)
.stateNot(BackfillState.RUNNING)
.notSoftDeleted()
.apply { if (!filterArgs.showDeleted) notSoftDeleted() }
.filterByArgs(filterArgs)
.newPager(
idDescPaginator(),
Expand Down Expand Up @@ -220,5 +222,6 @@ class GetBackfillRunsAction @Inject constructor(
private data class FilterArgs(
val backfillName: String? = null,
val createdByUser: String? = null,
val showDeleted: Boolean = false,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,46 @@ package app.cash.backfila.ui.components

import app.cash.backfila.dashboard.UiBackfillRun
import app.cash.backfila.ui.pages.BackfillShowAction
import kotlinx.html.InputType
import kotlinx.html.TagConsumer
import kotlinx.html.a
import kotlinx.html.div
import kotlinx.html.form
import kotlinx.html.h1
import kotlinx.html.input
import kotlinx.html.label
import kotlinx.html.section
import kotlinx.html.table
import kotlinx.html.tbody
import kotlinx.html.td
import kotlinx.html.th
import kotlinx.html.thead
import kotlinx.html.tr

fun TagConsumer<*>.BackfillsTable(running: Boolean, backfills: List<UiBackfillRun>) {
fun TagConsumer<*>.BackfillsTable(
running: Boolean,
backfills: List<UiBackfillRun>,
showDeleted: Boolean = false,
) {
val title = if (running) "Running" else "Paused"

div("px-4 sm:px-6 lg:px-8 py-5") {
div("sm:flex sm:items-center") {
div("sm:flex-auto") {
h1("text-base font-semibold leading-6 text-gray-900") { +"""Backfills ($title)""" }
section("sm:flex sm:items-center justify-between") {
h1("text-base font-semibold leading-6 text-gray-900") { +"""Backfills ($title)""" }

if (!running) { // Only show toggle for Paused backfills
form {
label("text-sm font-medium text-gray-600 flex items-center") {
+"Show deleted"
input(classes = "ml-2 h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600") {
type = InputType.checkBox
name = "showDeleted"
value = "true"
if (showDeleted) attributes["checked"] = "checked"
attributes["onchange"] = "this.form.submit()"
}
}
}
}
}
div("mt-8 flow-root") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ServiceShowAction @Inject constructor(
@PathParam variantOrBlank: String? = "",
@QueryParam offset: String? = null,
@QueryParam lastOffset: String? = null,
@QueryParam showDeleted: Boolean = false,
): Response<ResponseBody> {
if (service.isNullOrBlank()) {
return Response(
Expand All @@ -55,7 +56,12 @@ class ServiceShowAction @Inject constructor(
}
val variant = variantOrBlank.orEmpty().ifBlank { "default" }

val backfillRuns = getBackfillRunsAction.backfillRuns(service, variant, offset)
val backfillRuns = getBackfillRunsAction.backfillRuns(
service = service,
variant = variant,
pagination_token = offset,
show_deleted = showDeleted,
)

// TODO show default if other variants and probably link to a switcher
val label = if (variant == "default") service else "$service ($variant)"
Expand All @@ -70,16 +76,15 @@ class ServiceShowAction @Inject constructor(
PageTitle("Service", label) {
a {
href = BackfillCreateServiceIndexAction.path(service, variantOrBlank)

button(classes = "rounded-full bg-indigo-600 px-3 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600") {
type = ButtonType.button
+"""Create"""
}
}
}

BackfillsTable(true, backfillRuns.running_backfills)
BackfillsTable(false, backfillRuns.paused_backfills)
BackfillsTable(true, backfillRuns.running_backfills, showDeleted)
BackfillsTable(false, backfillRuns.paused_backfills, showDeleted)
Pagination(backfillRuns.next_pagination_token, offset, lastOffset, path(service, variantOrBlank))
}
}
Expand Down