1
1
package app.cash.backfila.ui.actions
2
2
3
3
import app.cash.backfila.dashboard.CancelBackfillAction
4
+ import app.cash.backfila.dashboard.GetBackfillStatusAction
4
5
import app.cash.backfila.dashboard.SoftDeleteBackfillAction
5
6
import app.cash.backfila.dashboard.StartBackfillAction
6
7
import app.cash.backfila.dashboard.StartBackfillRequest
@@ -49,6 +50,7 @@ class BackfillShowButtonHandlerAction @Inject constructor(
49
50
private val updateBackfillAction : UpdateBackfillAction ,
50
51
private val cancelBackfillAction : CancelBackfillAction ,
51
52
private val softDeleteBackfillAction : SoftDeleteBackfillAction ,
53
+ private val getBackfillStatusAction : GetBackfillStatusAction ,
52
54
) : WebAction {
53
55
@Get(PATH )
54
56
@ResponseContentType(MediaTypes .TEXT_HTML )
@@ -67,7 +69,7 @@ class BackfillShowButtonHandlerAction @Inject constructor(
67
69
}
68
70
69
71
return when (field_id) {
70
- " state" -> handleStateFrameResponse(id, field_value )
72
+ " state" -> handleStateFrameResponse(id)
71
73
else -> handleRedirectResponse(id)
72
74
}
73
75
}
@@ -115,24 +117,20 @@ class BackfillShowButtonHandlerAction @Inject constructor(
115
117
)
116
118
}
117
119
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
126
124
127
125
val frameContent = dashboardPageLayout.newBuilder()
128
126
.buildHtmlResponseBody {
129
127
turbo_frame(" backfill-$id -state" ) {
130
- div(" flex items-start gap-3 " ) {
128
+ div(" flex items-start gap-2 " ) {
131
129
div(" flex flex-col" ) {
132
- renderStateButtons(id, currentState)
130
+ renderStateButtons(id, currentState, deletedAt )
133
131
}
134
132
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:" }
136
134
span(" text-sm font-semibold text-gray-900" ) { + currentState.name }
137
135
}
138
136
}
0 commit comments