Skip to content

Commit 0d396f1

Browse files
committed
impl: direct access to observable properties
- without the need to go through a "field accessor" - fixes some NPE when reading the url
1 parent fb68191 commit 0d396f1

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

src/main/kotlin/com/coder/gateway/views/CoderPage.kt

-12
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,6 @@ abstract class CoderPage(
6161
notifier?.accept(ex) ?: errorBuffer.add(ex)
6262
}
6363

64-
/**
65-
* Get the value for a field.
66-
*
67-
* TODO@JB: Is this really meant to be used with casting? I kind of expected
68-
* to be able to do `myField.value`.
69-
*/
70-
fun get(field: UiField): Any? {
71-
//return stateAccessor?.get(field)
72-
// TODO - check this later
73-
return null
74-
}
75-
7664
/**
7765
* Immediately notify any pending errors and store for later errors.
7866
*/

src/main/kotlin/com/coder/gateway/views/CoderSettingsPage.kt

+11-11
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ class CoderSettingsPage(private val settings: CoderSettingsService) : CoderPage(
4848

4949
override fun getActionButtons(): MutableList<RunnableActionDescription> = mutableListOf(
5050
Action("Save", closesPage = true) {
51-
settings.binarySource = get(binarySourceField) as String
52-
settings.binaryDirectory = get(binaryDirectoryField) as String
53-
settings.dataDirectory = get(dataDirectoryField) as String
54-
settings.enableDownloads = get(enableDownloadsField) as Boolean
55-
settings.enableBinaryDirectoryFallback = get(enableBinaryDirectoryFallbackField) as Boolean
56-
settings.headerCommand = get(headerCommandField) as String
57-
settings.tlsCertPath = get(tlsCertPathField) as String
58-
settings.tlsKeyPath = get(tlsKeyPathField) as String
59-
settings.tlsCAPath = get(tlsCAPathField) as String
60-
settings.tlsAlternateHostname = get(tlsAlternateHostnameField) as String
61-
settings.disableAutostart = get(disableAutostartField) as Boolean
51+
settings.binarySource = binarySourceField.text.value
52+
settings.binaryDirectory = binaryDirectoryField.text.value
53+
settings.dataDirectory = dataDirectoryField.text.value
54+
settings.enableDownloads = enableDownloadsField.checked.value
55+
settings.enableBinaryDirectoryFallback = enableBinaryDirectoryFallbackField.checked.value
56+
settings.headerCommand = headerCommandField.text.value
57+
settings.tlsCertPath = tlsCertPathField.text.value
58+
settings.tlsKeyPath = tlsKeyPathField.text.value
59+
settings.tlsCAPath = tlsCAPathField.text.value
60+
settings.tlsAlternateHostname = tlsAlternateHostnameField.text.value
61+
settings.disableAutostart = disableAutostartField.checked.value
6262
},
6363
)
6464
}

src/main/kotlin/com/coder/gateway/views/SignInPage.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class SignInPage(
4545
* Call onSignIn with the URL, or error if blank.
4646
*/
4747
private fun submit() {
48-
val urlRaw = get(urlField) as String
48+
val urlRaw = urlField.text.value
4949
// Ensure the URL can be parsed.
5050
try {
5151
if (urlRaw.isBlank()) {

src/main/kotlin/com/coder/gateway/views/TokenPage.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ package com.coder.gateway.views
33
import com.coder.gateway.settings.Source
44
import com.coder.gateway.util.withPath
55
import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription
6-
import com.jetbrains.toolbox.api.ui.components.*
6+
import com.jetbrains.toolbox.api.ui.components.LabelField
7+
import com.jetbrains.toolbox.api.ui.components.LinkField
8+
import com.jetbrains.toolbox.api.ui.components.TextField
9+
import com.jetbrains.toolbox.api.ui.components.TextType
10+
import com.jetbrains.toolbox.api.ui.components.UiField
711
import java.net.URL
812

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

4852
/**

0 commit comments

Comments
 (0)