Skip to content

[WIP ]Toolbox ramp up #532

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

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
impl: direct access to observable properties
- without the need to go through a "field accessor"
- fixes some NPE when reading the url
  • Loading branch information
fioan89 committed Feb 17, 2025
commit 0d396f1f6652364ea1efd585039caf6e417f48fc
12 changes: 0 additions & 12 deletions src/main/kotlin/com/coder/gateway/views/CoderPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,6 @@ abstract class CoderPage(
notifier?.accept(ex) ?: errorBuffer.add(ex)
}

/**
* Get the value for a field.
*
* TODO@JB: Is this really meant to be used with casting? I kind of expected
* to be able to do `myField.value`.
*/
fun get(field: UiField): Any? {
//return stateAccessor?.get(field)
// TODO - check this later
return null
}

/**
* Immediately notify any pending errors and store for later errors.
*/
Expand Down
22 changes: 11 additions & 11 deletions src/main/kotlin/com/coder/gateway/views/CoderSettingsPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ class CoderSettingsPage(private val settings: CoderSettingsService) : CoderPage(

override fun getActionButtons(): MutableList<RunnableActionDescription> = mutableListOf(
Action("Save", closesPage = true) {
settings.binarySource = get(binarySourceField) as String
settings.binaryDirectory = get(binaryDirectoryField) as String
settings.dataDirectory = get(dataDirectoryField) as String
settings.enableDownloads = get(enableDownloadsField) as Boolean
settings.enableBinaryDirectoryFallback = get(enableBinaryDirectoryFallbackField) as Boolean
settings.headerCommand = get(headerCommandField) as String
settings.tlsCertPath = get(tlsCertPathField) as String
settings.tlsKeyPath = get(tlsKeyPathField) as String
settings.tlsCAPath = get(tlsCAPathField) as String
settings.tlsAlternateHostname = get(tlsAlternateHostnameField) as String
settings.disableAutostart = get(disableAutostartField) as Boolean
settings.binarySource = binarySourceField.text.value
settings.binaryDirectory = binaryDirectoryField.text.value
settings.dataDirectory = dataDirectoryField.text.value
settings.enableDownloads = enableDownloadsField.checked.value
settings.enableBinaryDirectoryFallback = enableBinaryDirectoryFallbackField.checked.value
settings.headerCommand = headerCommandField.text.value
settings.tlsCertPath = tlsCertPathField.text.value
settings.tlsKeyPath = tlsKeyPathField.text.value
settings.tlsCAPath = tlsCAPathField.text.value
settings.tlsAlternateHostname = tlsAlternateHostnameField.text.value
settings.disableAutostart = disableAutostartField.checked.value
},
)
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/coder/gateway/views/SignInPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SignInPage(
* Call onSignIn with the URL, or error if blank.
*/
private fun submit() {
val urlRaw = get(urlField) as String
val urlRaw = urlField.text.value
// Ensure the URL can be parsed.
try {
if (urlRaw.isBlank()) {
Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/com/coder/gateway/views/TokenPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package com.coder.gateway.views
import com.coder.gateway.settings.Source
import com.coder.gateway.util.withPath
import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription
import com.jetbrains.toolbox.api.ui.components.*
import com.jetbrains.toolbox.api.ui.components.LabelField
import com.jetbrains.toolbox.api.ui.components.LinkField
import com.jetbrains.toolbox.api.ui.components.TextField
import com.jetbrains.toolbox.api.ui.components.TextType
import com.jetbrains.toolbox.api.ui.components.UiField
import java.net.URL

/**
Expand Down Expand Up @@ -42,7 +46,7 @@ class TokenPage(
* Buttons displayed at the bottom of the page.
*/
override fun getActionButtons(): MutableList<RunnableActionDescription> = mutableListOf(
Action("Connect", closesPage = false) { submit(get(tokenField) as String) },
Action("Connect", closesPage = false) { submit(tokenField.text.value) },
)

/**
Expand Down
Loading