Skip to content

Commit 16837ed

Browse files
committed
redirect users to backfill page after success
1 parent d8f791d commit 16837ed

File tree

1 file changed

+7
-37
lines changed

1 file changed

+7
-37
lines changed

service/src/main/kotlin/app/cash/backfila/dashboard/EditPartitionCursorHandlerAction.kt

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ import app.cash.backfila.ui.components.DashboardPageLayout
77
import app.cash.backfila.ui.pages.BackfillShowAction
88
import javax.inject.Inject
99
import javax.inject.Singleton
10-
import kotlinx.html.div
11-
import kotlinx.html.h1
12-
import kotlinx.html.p
1310
import misk.exceptions.BadRequestException
1411
import misk.hibernate.Query
1512
import misk.hibernate.Transacter
1613
import misk.hibernate.newQuery
1714
import misk.scope.ActionScoped
1815
import misk.security.authz.Authenticated
19-
import misk.tailwind.Link
2016
import misk.web.Get
2117
import misk.web.HttpCall
2218
import misk.web.PathParam
@@ -25,6 +21,8 @@ import misk.web.ResponseBody
2521
import misk.web.ResponseContentType
2622
import misk.web.actions.WebAction
2723
import misk.web.mediatype.MediaTypes
24+
import misk.web.toResponseBody
25+
import okhttp3.Headers
2826
import okio.ByteString.Companion.encodeUtf8
2927

3028
@Singleton
@@ -44,7 +42,7 @@ class EditPartitionCursorHandlerAction @Inject constructor(
4442
@PathParam partitionName: String,
4543
): Response<ResponseBody> {
4644
val request = httpCall.get().asOkHttpRequest()
47-
val cursorSnapshot = request.url.queryParameter("cursor_snapshot")
45+
val cursorSnapshot = request.url.queryParameter("cursor_snapshot")?.takeIf { it.isNotBlank() }
4846
val newCursor = request.url.queryParameter("new_cursor")
4947

5048
// Validate UTF-8
@@ -78,39 +76,11 @@ class EditPartitionCursorHandlerAction @Inject constructor(
7876
} ?: throw BadRequestException("Partition not found")
7977
}
8078

81-
// Return success page with updated form
79+
// Redirect to backfill page
8280
return Response(
83-
dashboardPageLayout.newBuilder()
84-
.title("Edit Cursor - Partition $partitionName")
85-
.breadcrumbLinks(
86-
Link("Backfill #$id", BackfillShowAction.path(id)),
87-
Link("Edit Cursor", path(id, partitionName)),
88-
)
89-
.buildHtmlResponseBody {
90-
div("space-y-6 max-w-2xl mx-auto py-8") {
91-
// Success message
92-
div("rounded-md bg-green-50 p-4 mb-6") {
93-
div("flex") {
94-
div("flex-shrink-0") {
95-
// Success icon (checkmark)
96-
div("h-5 w-5 text-green-400") {
97-
+""
98-
}
99-
}
100-
div("ml-3") {
101-
h1("text-sm font-medium text-green-800") {
102-
+"Success"
103-
}
104-
div("mt-2 text-sm text-green-700") {
105-
p {
106-
+"Cursor has been updated successfully."
107-
}
108-
}
109-
}
110-
}
111-
}
112-
}
113-
},
81+
body = "go to ${BackfillShowAction.path(id)}".toResponseBody(),
82+
statusCode = 303,
83+
headers = Headers.headersOf("Location", BackfillShowAction.path(id)),
11484
)
11585
}
11686

0 commit comments

Comments
 (0)