@@ -6,6 +6,7 @@ import com.jetbrains.toolbox.api.ui.components.CheckboxField
6
6
import com.jetbrains.toolbox.api.ui.components.TextField
7
7
import com.jetbrains.toolbox.api.ui.components.TextType
8
8
import com.jetbrains.toolbox.api.ui.components.UiField
9
+ import kotlinx.coroutines.Job
9
10
import kotlinx.coroutines.channels.Channel
10
11
import kotlinx.coroutines.channels.ClosedSendChannelException
11
12
import kotlinx.coroutines.flow.MutableStateFlow
@@ -20,7 +21,7 @@ import kotlinx.coroutines.launch
20
21
* TODO@JB: There is no scroll, and our settings do not fit. As a consequence,
21
22
* I have not been able to test this page.
22
23
*/
23
- class CoderSettingsPage (context : CoderToolboxContext , triggerSshConfig : Channel <Boolean >) :
24
+ class CoderSettingsPage (private val context : CoderToolboxContext , triggerSshConfig : Channel <Boolean >) :
24
25
CoderPage (MutableStateFlow (context.i18n.ptrl(" Coder Settings" )), false ) {
25
26
private val settings = context.settingsStore.readOnly()
26
27
@@ -33,6 +34,11 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
33
34
TextField (context.i18n.ptrl(" Data directory" ), settings.dataDirectory ? : " " , TextType .General )
34
35
private val enableDownloadsField =
35
36
CheckboxField (settings.enableDownloads, context.i18n.ptrl(" Enable downloads" ))
37
+
38
+ private val disableSignatureVerificationField = CheckboxField (
39
+ settings.disableSignatureVerification,
40
+ context.i18n.ptrl(" Disable Coder CLI signature verification" )
41
+ )
36
42
private val signatureFallbackStrategyField =
37
43
CheckboxField (
38
44
settings.fallbackOnCoderForSignatures.isAllowed(),
@@ -65,13 +71,14 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
65
71
private val networkInfoDirField =
66
72
TextField (context.i18n.ptrl(" SSH network metrics directory" ), settings.networkInfoDir, TextType .General )
67
73
68
-
74
+ private lateinit var visibilityUpdateJob : Job
69
75
override val fields: StateFlow <List <UiField >> = MutableStateFlow (
70
76
listOf (
71
77
binarySourceField,
72
78
enableDownloadsField,
73
79
binaryDirectoryField,
74
80
enableBinaryDirectoryFallbackField,
81
+ disableSignatureVerificationField,
75
82
signatureFallbackStrategyField,
76
83
dataDirectoryField,
77
84
headerCommandField,
@@ -94,6 +101,7 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
94
101
context.settingsStore.updateBinaryDirectory(binaryDirectoryField.contentState.value)
95
102
context.settingsStore.updateDataDirectory(dataDirectoryField.contentState.value)
96
103
context.settingsStore.updateEnableDownloads(enableDownloadsField.checkedState.value)
104
+ context.settingsStore.updateDisableSignatureVerification(disableSignatureVerificationField.checkedState.value)
97
105
context.settingsStore.updateSignatureFallbackStrategy(signatureFallbackStrategyField.checkedState.value)
98
106
context.settingsStore.updateBinaryDirectoryFallback(enableBinaryDirectoryFallbackField.checkedState.value)
99
107
context.settingsStore.updateHeaderCommand(headerCommandField.contentState.value)
@@ -182,5 +190,19 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
182
190
networkInfoDirField.contentState.update {
183
191
settings.networkInfoDir
184
192
}
193
+
194
+ visibilityUpdateJob = context.cs.launch {
195
+ disableSignatureVerificationField.checkedState.collect { state ->
196
+ signatureFallbackStrategyField.visibility.update {
197
+ // the fallback checkbox should not be visible
198
+ // if signature verification is disabled
199
+ ! state
200
+ }
201
+ }
202
+ }
203
+ }
204
+
205
+ override fun afterHide () {
206
+ visibilityUpdateJob.cancel()
185
207
}
186
208
}
0 commit comments