Skip to content

Commit 2672f74

Browse files
committed
refactor: remove unused code
- close page property is no longer needed by the wizard steps - getToken was moved into the context
1 parent 2b230c6 commit 2672f74

File tree

4 files changed

+2
-27
lines changed

4 files changed

+2
-27
lines changed

src/main/kotlin/com/coder/toolbox/views/ConnectStep.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class ConnectStep(
4141
)
4242

4343
override val nextButtonTitle: LocalizableString? = null
44-
override val closesWizard: Boolean = false
4544

4645
override fun onVisible() {
4746
val url = context.deploymentUrl?.first?.toURL()

src/main/kotlin/com/coder/toolbox/views/SignInStep.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class SignInStep(private val context: CoderToolboxContext) : WizardStep {
2929

3030
override val nextButtonTitle: LocalizableString? = context.i18n.ptrl("Sign In")
3131

32-
override val closesWizard: Boolean = false
33-
3432
override fun onVisible() {
3533
urlField.textState.update {
3634
context.deploymentUrl?.first ?: ""

src/main/kotlin/com/coder/toolbox/views/TokenStep.kt

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.coder.toolbox.views
22

33
import com.coder.toolbox.CoderToolboxContext
4-
import com.coder.toolbox.settings.SettingSource
54
import com.coder.toolbox.util.toURL
65
import com.coder.toolbox.util.withPath
76
import com.coder.toolbox.views.state.AuthWizardState
@@ -34,15 +33,14 @@ class TokenStep(private val context: CoderToolboxContext) : WizardStep {
3433
RowGroup.RowField(errorField)
3534
)
3635
override val nextButtonTitle: LocalizableString? = context.i18n.ptrl("Connect")
37-
override val closesWizard: Boolean = false
3836

3937
override fun onVisible() {
4038
tokenField.textState.update {
41-
getToken(context.deploymentUrl?.first)?.first ?: ""
39+
context.getToken(context.deploymentUrl?.first)?.first ?: ""
4240
}
4341
descriptionField.textState.update {
4442
context.i18n.pnotr(
45-
getToken(context.deploymentUrl?.first)?.second?.description("token")
43+
context.getToken(context.deploymentUrl?.first)?.second?.description("token")
4644
?: "No existing token for ${context.deploymentUrl} found."
4745
)
4846
}
@@ -66,23 +64,4 @@ class TokenStep(private val context: CoderToolboxContext) : WizardStep {
6664
override fun onBack() {
6765
AuthWizardState.goToPreviousStep()
6866
}
69-
70-
/**
71-
* Try to find a token.
72-
*
73-
* Order of preference:
74-
*
75-
* 1. Last used token, if it was for this deployment.
76-
* 2. Token on disk for this deployment.
77-
* 3. Global token for Coder, if it matches the deployment.
78-
*/
79-
private fun getToken(deploymentURL: String?): Pair<String, SettingSource>? = context.secrets.lastToken.let {
80-
if (it.isNotBlank() && context.secrets.lastDeploymentURL == deploymentURL) {
81-
it to SettingSource.LAST_USED
82-
} else {
83-
if (deploymentURL != null) {
84-
context.settingsStore.token(deploymentURL.toURL())
85-
} else null
86-
}
87-
}
8867
}

src/main/kotlin/com/coder/toolbox/views/WizardStep.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.jetbrains.toolbox.api.ui.components.RowGroup
66
interface WizardStep {
77
val panel: RowGroup
88
val nextButtonTitle: LocalizableString?
9-
val closesWizard: Boolean
109

1110
/**
1211
* Callback when step is visible

0 commit comments

Comments
 (0)