11package com.coder.toolbox.views
22
33import com.coder.toolbox.CoderToolboxContext
4+ import com.coder.toolbox.settings.SignatureFallbackStrategy
45import com.coder.toolbox.util.toURL
56import com.coder.toolbox.views.state.CoderCliSetupContext
67import com.coder.toolbox.views.state.CoderCliSetupWizardState
8+ import com.jetbrains.toolbox.api.ui.components.CheckboxField
9+ import com.jetbrains.toolbox.api.ui.components.LabelField
10+ import com.jetbrains.toolbox.api.ui.components.LabelStyleType
711import com.jetbrains.toolbox.api.ui.components.RowGroup
812import com.jetbrains.toolbox.api.ui.components.TextField
913import com.jetbrains.toolbox.api.ui.components.TextType
@@ -24,12 +28,34 @@ class DeploymentUrlStep(
2428) :
2529 WizardStep {
2630 private val urlField = TextField (context.i18n.ptrl(" Deployment URL" ), " " , TextType .General )
27- private val errorField = ValidationErrorField (context.i18n.pnotr(" " ))
31+ private val emptyLine = LabelField (context.i18n.pnotr(" " ), LabelStyleType . Normal )
2832
29- override val panel : RowGroup = RowGroup (
30- RowGroup . RowField (urlField ),
31- RowGroup . RowField (errorField )
33+ private val signatureFallbackStrategyField = CheckboxField (
34+ context.settingsStore.fallbackOnCoderForSignatures.isAllowed( ),
35+ context.i18n.ptrl( " Fallback on releases.coder.com when CLI signatures can't be found " )
3236 )
37+ private val infoLine =
38+ LabelField (context.i18n.ptrl(" Can be reconfigured later on from the Settings page" ), LabelStyleType .Secondary )
39+
40+ private val errorField = ValidationErrorField (context.i18n.pnotr(" " ))
41+
42+ override val panel: RowGroup
43+ get() {
44+ if (context.settingsStore.fallbackOnCoderForSignatures == SignatureFallbackStrategy .NOT_CONFIGURED ) {
45+ return RowGroup (
46+ RowGroup .RowField (urlField),
47+ RowGroup .RowField (emptyLine),
48+ RowGroup .RowField (signatureFallbackStrategyField),
49+ RowGroup .RowField (infoLine),
50+ RowGroup .RowField (errorField)
51+ )
52+
53+ }
54+ return RowGroup (
55+ RowGroup .RowField (urlField),
56+ RowGroup .RowField (errorField)
57+ )
58+ }
3359
3460 override fun onVisible () {
3561 errorField.textState.update {
@@ -38,9 +64,14 @@ class DeploymentUrlStep(
3864 urlField.textState.update {
3965 context.secrets.lastDeploymentURL
4066 }
67+
68+ signatureFallbackStrategyField.checkedState.update {
69+ context.settingsStore.fallbackOnCoderForSignatures.isAllowed()
70+ }
4171 }
4272
4373 override fun onNext (): Boolean {
74+ context.settingsStore.updateSignatureFallbackStrategy(signatureFallbackStrategyField.checkedState.value)
4475 var url = urlField.textState.value
4576 if (url.isBlank()) {
4677 errorField.textState.update { context.i18n.ptrl(" URL is required" ) }
0 commit comments