-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Centralize url path building #410
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
52 changes: 0 additions & 52 deletions
52
service/src/main/kotlin/app/cash/backfila/ui/components/NavBar.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,11 @@ class BackfillCreateServiceIndexAction @Inject constructor( | |
): Response<ResponseBody> { | ||
if (variantOrBlank.orEmpty().contains(".") || variantOrBlank.orEmpty().toIntOrNull() != null) { | ||
// This means variant is default and the value provided is the backfill name or backfill ID to clone, redirect accordingly | ||
val newPath = BackfillCreateAction.PATH | ||
.replace("{service}", service) | ||
.replace("{variantOrBackfillNameOrId}", variantOrBlank.orEmpty()) | ||
.replace("{backfillNameOrId}", "") | ||
val newPath = BackfillCreateAction.path( | ||
service = service, | ||
variantOrBackfillNameOrId = variantOrBlank.orEmpty(), | ||
backfillNameOrId = "" | ||
) | ||
return Response( | ||
body = "go to $newPath".toResponseBody(), | ||
statusCode = HttpURLConnection.HTTP_MOVED_TEMP, | ||
|
@@ -60,9 +61,7 @@ class BackfillCreateServiceIndexAction @Inject constructor( | |
Link("Services", ServiceIndexAction.PATH), | ||
Link( | ||
label, | ||
ServiceShowAction.PATH | ||
.replace("{service}", service) | ||
.replace("{variantOrBlank}", variantOrBlank ?: ""), | ||
ServiceShowAction.path(service, variantOrBlank), | ||
), | ||
Link( | ||
"Create", | ||
|
@@ -93,10 +92,11 @@ class BackfillCreateServiceIndexAction @Inject constructor( | |
registeredBackfills.backfills.map { | ||
a { | ||
val variantOrBackfillNameOrId = variantOrBlank.orEmpty().ifBlank { it.name } | ||
href = BackfillCreateAction.PATH | ||
.replace("{service}", service) | ||
.replace("{variantOrBackfillNameOrId}", variantOrBackfillNameOrId) | ||
.replace("{backfillNameOrId}", if (variantOrBackfillNameOrId == it.name) "" else it.name) | ||
href = BackfillCreateAction.path( | ||
service = service, | ||
variantOrBackfillNameOrId = variantOrBackfillNameOrId, | ||
backfillNameOrId = if (variantOrBackfillNameOrId == it.name) "" else it.name | ||
) | ||
|
||
[email protected]("registration col-span-1 divide-y divide-gray-200 rounded-lg bg-white shadow") { | ||
div("flex w-full items-center justify-between space-x-6 p-6") { | ||
|
@@ -124,22 +124,10 @@ class BackfillCreateServiceIndexAction @Inject constructor( | |
return Response(htmlResponseBody) | ||
} | ||
|
||
enum class BackfillCreateField(val fieldId: String) { | ||
SERVICE("service"), | ||
VARIANT("variant"), | ||
BACKFILL_NAME("backfillName"), | ||
DRY_RUN("dryRun"), | ||
RANGE_START("rangeStart"), | ||
RANGE_END("rangeEnd"), | ||
BATCH_SIZE("batchSize"), | ||
SCAN_SIZE("scanSize"), | ||
THREADS_PER_PARTITION("threadsPerPartition"), | ||
EXTRA_SLEEP_MS("extraSleepMs"), | ||
BACKOFF_SCHEDULE("backoffSchedule"), | ||
CUSTOM_PARAMETER_PREFIX("customParameter_"), | ||
} | ||
|
||
companion object { | ||
const val PATH = "/backfills/create/{service}/{variantOrBlank}" | ||
private const val PATH = "/backfills/create/{service}/{variantOrBlank}" | ||
fun path(service: String, variantOrBlank: String?) = PATH | ||
.replace("{service}", service) | ||
.replace("{variantOrBlank}", variantOrBlank ?: "") | ||
} | ||
} |
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ import kotlinx.html.button | |
import kotlinx.html.div | ||
import kotlinx.html.h3 | ||
import kotlinx.html.li | ||
import kotlinx.html.p | ||
import kotlinx.html.role | ||
import kotlinx.html.span | ||
import kotlinx.html.ul | ||
|
@@ -68,7 +69,7 @@ class BackfillIndexAction @Inject constructor( | |
|
||
backfills.map { backfill -> | ||
a { | ||
href = BackfillShowAction.PATH.replace("{id}", backfill.id.toString()) | ||
href = BackfillShowAction.path(backfill.id.toString()) | ||
|
||
[email protected]("registration col-span-1 divide-y divide-gray-200 rounded-lg bg-white shadow") { | ||
div("flex w-full items-center justify-between space-x-6 p-6") { | ||
|
@@ -92,53 +93,9 @@ class BackfillIndexAction @Inject constructor( | |
+backfill.state.name | ||
} | ||
} | ||
// p("mt-1 truncate text-sm text-gray-500") { +"""Regional Paradigm Technician""" } | ||
} | ||
} | ||
} | ||
// Buttons | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was code copied in from Tailwind but didn't end up using. |
||
// div { | ||
// div("-mt-px flex divide-x divide-gray-200") { | ||
// div("flex w-0 flex-1") { | ||
// a(classes = "relative -mr-px inline-flex w-0 flex-1 items-center justify-center gap-x-3 rounded-bl-lg border border-transparent py-4 text-sm font-semibold text-gray-900") { | ||
// href = "mailto:[email protected]" | ||
// // svg("size-5 text-gray-400") { | ||
// // viewbox = "0 0 20 20" | ||
// // fill = "currentColor" | ||
// // attributes["aria-hidden"] = "true" | ||
// // attributes["data-slot"] = "icon" | ||
// // path { | ||
// // d = | ||
// // "M3 4a2 2 0 0 0-2 2v1.161l8.441 4.221a1.25 1.25 0 0 0 1.118 0L19 7.162V6a2 2 0 0 0-2-2H3Z" | ||
// // } | ||
// // path { | ||
// // d = | ||
// // "m19 8.839-7.77 3.885a2.75 2.75 0 0 1-2.46 0L1 8.839V14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.839Z" | ||
// // } | ||
// // } | ||
// +"""Email""" | ||
// } | ||
// } | ||
// div("-ml-px flex w-0 flex-1") { | ||
// a(classes = "relative inline-flex w-0 flex-1 items-center justify-center gap-x-3 rounded-br-lg border border-transparent py-4 text-sm font-semibold text-gray-900") { | ||
// href = "tel:+1-202-555-0170" | ||
// // svg("size-5 text-gray-400") { | ||
// // viewbox = "0 0 20 20" | ||
// // fill = "currentColor" | ||
// // attributes["aria-hidden"] = "true" | ||
// // attributes["data-slot"] = "icon" | ||
// // path { | ||
// // attributes["fill-rule"] = "evenodd" | ||
// // d = | ||
// // "M2 3.5A1.5 1.5 0 0 1 3.5 2h1.148a1.5 1.5 0 0 1 1.465 1.175l.716 3.223a1.5 1.5 0 0 1-1.052 1.767l-.933.267c-.41.117-.643.555-.48.95a11.542 11.542 0 0 0 6.254 6.254c.395.163.833-.07.95-.48l.267-.933a1.5 1.5 0 0 1 1.767-1.052l3.223.716A1.5 1.5 0 0 1 18 15.352V16.5a1.5 1.5 0 0 1-1.5 1.5H15c-1.149 0-2.263-.15-3.326-.43A13.022 13.022 0 0 1 2.43 8.326 13.019 13.019 0 0 1 2 5V3.5Z" | ||
// // attributes["clip-rule"] = "evenodd" | ||
// // } | ||
// // } | ||
// +"""Call""" | ||
// } | ||
// } | ||
// } | ||
// } | ||
} | ||
} | ||
} | ||
|
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah unused