11package com.coder.toolbox.views
22
33import com.coder.toolbox.CoderToolboxContext
4- import com.coder.toolbox.settings.SettingSource
54import com.coder.toolbox.util.toURL
65import com.coder.toolbox.util.withPath
76import 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}
0 commit comments