1
1
package com.coder.toolbox.views
2
2
3
3
import com.coder.toolbox.CoderToolboxContext
4
- import com.coder.toolbox.settings.SettingSource
5
4
import com.coder.toolbox.util.toURL
6
5
import com.coder.toolbox.util.withPath
7
6
import com.coder.toolbox.views.state.AuthWizardState
@@ -34,15 +33,14 @@ class TokenStep(private val context: CoderToolboxContext) : WizardStep {
34
33
RowGroup .RowField (errorField)
35
34
)
36
35
override val nextButtonTitle: LocalizableString ? = context.i18n.ptrl(" Connect" )
37
- override val closesWizard: Boolean = false
38
36
39
37
override fun onVisible () {
40
38
tokenField.textState.update {
41
- getToken(context.deploymentUrl?.first)?.first ? : " "
39
+ context. getToken(context.deploymentUrl?.first)?.first ? : " "
42
40
}
43
41
descriptionField.textState.update {
44
42
context.i18n.pnotr(
45
- getToken(context.deploymentUrl?.first)?.second?.description(" token" )
43
+ context. getToken(context.deploymentUrl?.first)?.second?.description(" token" )
46
44
? : " No existing token for ${context.deploymentUrl} found."
47
45
)
48
46
}
@@ -66,23 +64,4 @@ class TokenStep(private val context: CoderToolboxContext) : WizardStep {
66
64
override fun onBack () {
67
65
AuthWizardState .goToPreviousStep()
68
66
}
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
- }
88
67
}
0 commit comments