-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/user-attachments/assets/10bf8ccb-2109-4ec5-bf05-60d2b9a08a46 # Coming in follow up PRs - [ ] Fix auto-reload using turbo frame src instead of full page reload - [ ] Add service filter for only services that have running backfills - [ ] Add button to stop all backfills - [ ] Show custom parameters on backfill show screen - [ ] Make clone/create screen more dense, everything above the fold - [ ] Make backfill show table no scrolling (full width configuration, then partitions, then logs) - [ ] Upstream common elements to Misk
- Loading branch information
Showing
34 changed files
with
1,734 additions
and
799 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
service/src/main/kotlin/app/cash/backfila/ui/DashboardUrls.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package app.cash.backfila.ui | ||
|
||
object DashboardUrls { | ||
fun app(appName: String) = "/app/$appName" | ||
fun createDeploy(appName: String) = "/app/$appName/deploy" | ||
fun deploy(appName: String, deployName: String) = "/app/$appName/deploy/$deployName" | ||
fun setMinimalCommitTimestamp(appName: String) = "/app/$appName/set-minimal-commit-timestamp" | ||
} |
69 changes: 0 additions & 69 deletions
69
service/src/main/kotlin/app/cash/backfila/ui/PathBuilder.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
service/src/main/kotlin/app/cash/backfila/ui/actions/BackfillCreateHandlerAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package app.cash.backfila.ui.actions | ||
|
||
import app.cash.backfila.dashboard.CreateBackfillAction | ||
import app.cash.backfila.protos.service.CreateBackfillRequest | ||
import app.cash.backfila.ui.pages.BackfillCreateAction.BackfillCreateField | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
import misk.scope.ActionScoped | ||
import misk.security.authz.Authenticated | ||
import misk.web.Get | ||
import misk.web.HttpCall | ||
import misk.web.Response | ||
import misk.web.ResponseBody | ||
import misk.web.ResponseContentType | ||
import misk.web.actions.WebAction | ||
import misk.web.mediatype.MediaTypes | ||
import misk.web.toResponseBody | ||
import okhttp3.Headers | ||
import okio.ByteString.Companion.encodeUtf8 | ||
|
||
@Singleton | ||
class BackfillCreateHandlerAction @Inject constructor( | ||
private val createBackfillAction: CreateBackfillAction, | ||
private val httpCall: ActionScoped<HttpCall>, | ||
) : WebAction { | ||
@Get(PATH) | ||
@ResponseContentType(MediaTypes.TEXT_HTML) | ||
@Authenticated(capabilities = ["users"]) | ||
fun get(): Response<ResponseBody> { | ||
// Parse form | ||
val formFieldNames = this.httpCall.get().asOkHttpRequest().url.queryParameterNames | ||
val formFields = formFieldNames.associateWith { this.httpCall.get().asOkHttpRequest().url.queryParameter(it) } | ||
|
||
// Submit create call | ||
val createRequestBuilder = CreateBackfillRequest.Builder() | ||
formFields[BackfillCreateField.BACKFILL_NAME.fieldId]?.ifNotBlank { createRequestBuilder.backfill_name(it) } | ||
createRequestBuilder.dry_run( | ||
when (formFields[BackfillCreateField.DRY_RUN.fieldId]) { | ||
// Unchecked box in UI will not send a value | ||
"off", null -> false | ||
else -> true | ||
}, | ||
) | ||
formFields[BackfillCreateField.RANGE_START.fieldId]?.ifNotBlank { createRequestBuilder.pkey_range_start(it.encodeUtf8()) } | ||
formFields[BackfillCreateField.RANGE_END.fieldId]?.ifNotBlank { createRequestBuilder.pkey_range_end(it.encodeUtf8()) } | ||
formFields[BackfillCreateField.BATCH_SIZE.fieldId]?.ifNotBlank { createRequestBuilder.batch_size(it.toLongOrNull()) } | ||
formFields[BackfillCreateField.SCAN_SIZE.fieldId]?.ifNotBlank { createRequestBuilder.scan_size(it.toLongOrNull()) } | ||
formFields[BackfillCreateField.THREADS_PER_PARTITION.fieldId]?.ifNotBlank { createRequestBuilder.num_threads(it.toIntOrNull()) } | ||
formFields[BackfillCreateField.EXTRA_SLEEP_MS.fieldId]?.ifNotBlank { createRequestBuilder.extra_sleep_ms(it.toLongOrNull()) } | ||
formFields[BackfillCreateField.BACKOFF_SCHEDULE.fieldId]?.ifNotBlank { createRequestBuilder.backoff_schedule(it) } | ||
val customParameters = formFields.filter { it.key.startsWith(BackfillCreateField.CUSTOM_PARAMETER_PREFIX.fieldId) } | ||
.mapValues { it.value?.encodeUtf8() } | ||
if (customParameters.isNotEmpty()) { | ||
createRequestBuilder.parameter_map(customParameters) | ||
} | ||
|
||
val response = createBackfillAction.create( | ||
service = formFields[BackfillCreateField.SERVICE.fieldId]!!, | ||
variant = formFields[BackfillCreateField.VARIANT.fieldId]!!, | ||
request = createRequestBuilder.build(), | ||
) | ||
|
||
val id = response.backfill_run_id | ||
|
||
return Response( | ||
body = "go to /backfills/$id".toResponseBody(), | ||
statusCode = 303, | ||
headers = Headers.headersOf("Location", "/backfills/$id"), | ||
) | ||
} | ||
|
||
companion object { | ||
const val PATH = "/api/backfill/create" | ||
|
||
private fun <T>String?.ifNotBlank(block: (String) -> T) = if (this.isNullOrBlank()) null else block(this) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
service/src/main/kotlin/app/cash/backfila/ui/actions/ServiceAutocompleteAction.kt
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
service/src/main/kotlin/app/cash/backfila/ui/actions/ServiceDataHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package app.cash.backfila.ui.actions | ||
|
||
import app.cash.backfila.dashboard.GetServicesAction | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class ServiceDataHelper @Inject constructor( | ||
private val getServicesAction: GetServicesAction, | ||
) { | ||
fun getFlattenedServices(): Map<String, GetServicesAction.UiService> { | ||
val services = getServicesAction.services().services | ||
return services.flatMap { service -> | ||
service.variants.map { variant -> "${service.name}/$variant" to service } | ||
}.toMap() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
service/src/main/kotlin/app/cash/backfila/ui/components/AutoReload.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package app.cash.backfila.ui.components | ||
|
||
import kotlinx.html.TagConsumer | ||
import kotlinx.html.div | ||
|
||
// TODO | ||
// Currently this reloads the whole page every 10s | ||
// We want to ideally only update within a turbo frame so the rest of the UI is stable | ||
// (ie. update form for backfill show page) | ||
fun TagConsumer<*>.AutoReload(block: TagConsumer<*>.() -> Unit) { | ||
div { | ||
attributes["data-controller"] = "auto-reload" | ||
attributes["data-auto-reload-target"] = "frame" | ||
|
||
block() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.