From 7546726ad9ebcfeea39a259a585dbcd031445279 Mon Sep 17 00:00:00 2001 From: Ioan Faur Date: Tue, 21 Jun 2022 23:48:33 +0300 Subject: [PATCH] Start auth flow when user hits ENTER in the url field --- .../gateway/views/CoderGatewayConnectorWizardView.kt | 2 +- .../com/coder/gateway/views/steps/CoderAuthStepView.kt | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/coder/gateway/views/CoderGatewayConnectorWizardView.kt b/src/main/kotlin/com/coder/gateway/views/CoderGatewayConnectorWizardView.kt index 7df2d6bd..72f29f2b 100644 --- a/src/main/kotlin/com/coder/gateway/views/CoderGatewayConnectorWizardView.kt +++ b/src/main/kotlin/com/coder/gateway/views/CoderGatewayConnectorWizardView.kt @@ -30,7 +30,7 @@ class CoderGatewayConnectorWizardView : BorderLayoutPanel(), Disposable { private fun setupWizard() { background = WelcomeScreenUIManager.getMainAssociatedComponentBackground() - registerStep(CoderAuthStepView()) + registerStep(CoderAuthStepView { next() }) registerStep(CoderWorkspacesStepView()) registerStep(CoderLocateRemoteProjectStepView()) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderAuthStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderAuthStepView.kt index 6a42bef0..4fcfdad9 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderAuthStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderAuthStepView.kt @@ -39,7 +39,7 @@ import kotlinx.coroutines.cancel import org.zeroturnaround.exec.ProcessExecutor import java.awt.Dimension -class CoderAuthStepView : CoderWorkspacesWizardStep, Disposable { +class CoderAuthStepView(private val nextAction: () -> Unit) : CoderWorkspacesWizardStep, Disposable { private val cs = CoroutineScope(Dispatchers.Main) private var model = CoderWorkspacesWizardModel() private val coderClient: CoderRestClientService = ApplicationManager.getApplication().getService(CoderRestClientService::class.java) @@ -59,7 +59,11 @@ class CoderAuthStepView : CoderWorkspacesWizardStep, Disposable { browserLink(CoderGatewayBundle.message("gateway.connector.view.login.documentation.action"), "https://coder.com/docs/coder/latest/workspaces") }.bottomGap(BottomGap.MEDIUM) row(CoderGatewayBundle.message("gateway.connector.view.login.url.label")) { - textField().resizableColumn().horizontalAlign(HorizontalAlign.FILL).gap(RightGap.SMALL).bindText(model::coderURL) + textField().resizableColumn().horizontalAlign(HorizontalAlign.FILL).gap(RightGap.SMALL).bindText(model::coderURL).applyToComponent { + addActionListener { + nextAction() + } + } cell() } }