Skip to content

Commit 0be4857

Browse files
committed
immediate update for delete
1 parent 2ec7b08 commit 0be4857

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

service/src/main/kotlin/app/cash/backfila/ui/actions/BackfillShowButtonHandlerAction.kt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package app.cash.backfila.ui.actions
22

33
import app.cash.backfila.dashboard.CancelBackfillAction
4+
import app.cash.backfila.dashboard.GetBackfillStatusAction
45
import app.cash.backfila.dashboard.SoftDeleteBackfillAction
56
import app.cash.backfila.dashboard.StartBackfillAction
67
import app.cash.backfila.dashboard.StartBackfillRequest
@@ -49,6 +50,7 @@ class BackfillShowButtonHandlerAction @Inject constructor(
4950
private val updateBackfillAction: UpdateBackfillAction,
5051
private val cancelBackfillAction: CancelBackfillAction,
5152
private val softDeleteBackfillAction: SoftDeleteBackfillAction,
53+
private val getBackfillStatusAction: GetBackfillStatusAction,
5254
) : WebAction {
5355
@Get(PATH)
5456
@ResponseContentType(MediaTypes.TEXT_HTML)
@@ -67,7 +69,7 @@ class BackfillShowButtonHandlerAction @Inject constructor(
6769
}
6870

6971
return when (field_id) {
70-
"state" -> handleStateFrameResponse(id, field_value)
72+
"state" -> handleStateFrameResponse(id)
7173
else -> handleRedirectResponse(id)
7274
}
7375
}
@@ -115,24 +117,20 @@ class BackfillShowButtonHandlerAction @Inject constructor(
115117
)
116118
}
117119

118-
private fun handleStateFrameResponse(id: String, fieldValue: String?): Response<ResponseBody> {
119-
val currentState = when (fieldValue) {
120-
BackfillState.PAUSED.name -> BackfillState.PAUSED
121-
BackfillState.RUNNING.name -> BackfillState.RUNNING
122-
BackfillState.CANCELLED.name -> BackfillState.CANCELLED
123-
"soft_delete" -> BackfillState.COMPLETE
124-
else -> BackfillState.RUNNING
125-
}
120+
private fun handleStateFrameResponse(id: String): Response<ResponseBody> {
121+
val backfillStatus = getBackfillStatusAction.status(id.toLong())
122+
val currentState = backfillStatus.state
123+
val deletedAt = backfillStatus.deleted_at
126124

127125
val frameContent = dashboardPageLayout.newBuilder()
128126
.buildHtmlResponseBody {
129127
turbo_frame("backfill-$id-state") {
130-
div("flex items-start gap-3") {
128+
div("flex items-start gap-2") {
131129
div("flex flex-col") {
132-
renderStateButtons(id, currentState)
130+
renderStateButtons(id, currentState, deletedAt)
133131
}
134132
div("flex items-center gap-2") {
135-
span("text-sm font-medium text-gray-500") { +"State:" }
133+
span("text-sm font-bold text-gray-500") { +"State:" }
136134
span("text-sm font-semibold text-gray-900") { +currentState.name }
137135
}
138136
}

0 commit comments

Comments
 (0)