From 0be4857c57613089279fd8d72f5aa5bd83f1cdc4 Mon Sep 17 00:00:00 2001 From: Jeff Hwang Date: Mon, 16 Jun 2025 12:53:10 -0400 Subject: [PATCH] immediate update for delete --- .../BackfillShowButtonHandlerAction.kt | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/service/src/main/kotlin/app/cash/backfila/ui/actions/BackfillShowButtonHandlerAction.kt b/service/src/main/kotlin/app/cash/backfila/ui/actions/BackfillShowButtonHandlerAction.kt index c2ba9da18..f12f7ec51 100644 --- a/service/src/main/kotlin/app/cash/backfila/ui/actions/BackfillShowButtonHandlerAction.kt +++ b/service/src/main/kotlin/app/cash/backfila/ui/actions/BackfillShowButtonHandlerAction.kt @@ -1,6 +1,7 @@ package app.cash.backfila.ui.actions import app.cash.backfila.dashboard.CancelBackfillAction +import app.cash.backfila.dashboard.GetBackfillStatusAction import app.cash.backfila.dashboard.SoftDeleteBackfillAction import app.cash.backfila.dashboard.StartBackfillAction import app.cash.backfila.dashboard.StartBackfillRequest @@ -49,6 +50,7 @@ class BackfillShowButtonHandlerAction @Inject constructor( private val updateBackfillAction: UpdateBackfillAction, private val cancelBackfillAction: CancelBackfillAction, private val softDeleteBackfillAction: SoftDeleteBackfillAction, + private val getBackfillStatusAction: GetBackfillStatusAction, ) : WebAction { @Get(PATH) @ResponseContentType(MediaTypes.TEXT_HTML) @@ -67,7 +69,7 @@ class BackfillShowButtonHandlerAction @Inject constructor( } return when (field_id) { - "state" -> handleStateFrameResponse(id, field_value) + "state" -> handleStateFrameResponse(id) else -> handleRedirectResponse(id) } } @@ -115,24 +117,20 @@ class BackfillShowButtonHandlerAction @Inject constructor( ) } - private fun handleStateFrameResponse(id: String, fieldValue: String?): Response { - val currentState = when (fieldValue) { - BackfillState.PAUSED.name -> BackfillState.PAUSED - BackfillState.RUNNING.name -> BackfillState.RUNNING - BackfillState.CANCELLED.name -> BackfillState.CANCELLED - "soft_delete" -> BackfillState.COMPLETE - else -> BackfillState.RUNNING - } + private fun handleStateFrameResponse(id: String): Response { + val backfillStatus = getBackfillStatusAction.status(id.toLong()) + val currentState = backfillStatus.state + val deletedAt = backfillStatus.deleted_at val frameContent = dashboardPageLayout.newBuilder() .buildHtmlResponseBody { turbo_frame("backfill-$id-state") { - div("flex items-start gap-3") { + div("flex items-start gap-2") { div("flex flex-col") { - renderStateButtons(id, currentState) + renderStateButtons(id, currentState, deletedAt) } div("flex items-center gap-2") { - span("text-sm font-medium text-gray-500") { +"State:" } + span("text-sm font-bold text-gray-500") { +"State:" } span("text-sm font-semibold text-gray-900") { +currentState.name } } }