@@ -6,6 +6,7 @@ import com.jetbrains.toolbox.api.ui.components.CheckboxField
66import com.jetbrains.toolbox.api.ui.components.TextField
77import com.jetbrains.toolbox.api.ui.components.TextType
88import com.jetbrains.toolbox.api.ui.components.UiField
9+ import kotlinx.coroutines.Job
910import kotlinx.coroutines.channels.Channel
1011import kotlinx.coroutines.channels.ClosedSendChannelException
1112import kotlinx.coroutines.flow.MutableStateFlow
@@ -20,7 +21,7 @@ import kotlinx.coroutines.launch
2021 * TODO@JB: There is no scroll, and our settings do not fit. As a consequence,
2122 * I have not been able to test this page.
2223 */
23- class CoderSettingsPage (context : CoderToolboxContext , triggerSshConfig : Channel <Boolean >) :
24+ class CoderSettingsPage (private val context : CoderToolboxContext , triggerSshConfig : Channel <Boolean >) :
2425 CoderPage (MutableStateFlow (context.i18n.ptrl(" Coder Settings" )), false ) {
2526 private val settings = context.settingsStore.readOnly()
2627
@@ -33,6 +34,11 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
3334 TextField (context.i18n.ptrl(" Data directory" ), settings.dataDirectory ? : " " , TextType .General )
3435 private val enableDownloadsField =
3536 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+ )
3642 private val signatureFallbackStrategyField =
3743 CheckboxField (
3844 settings.fallbackOnCoderForSignatures.isAllowed(),
@@ -65,13 +71,14 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
6571 private val networkInfoDirField =
6672 TextField (context.i18n.ptrl(" SSH network metrics directory" ), settings.networkInfoDir, TextType .General )
6773
68-
74+ private lateinit var visibilityUpdateJob : Job
6975 override val fields: StateFlow <List <UiField >> = MutableStateFlow (
7076 listOf (
7177 binarySourceField,
7278 enableDownloadsField,
7379 binaryDirectoryField,
7480 enableBinaryDirectoryFallbackField,
81+ disableSignatureVerificationField,
7582 signatureFallbackStrategyField,
7683 dataDirectoryField,
7784 headerCommandField,
@@ -94,6 +101,7 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
94101 context.settingsStore.updateBinaryDirectory(binaryDirectoryField.contentState.value)
95102 context.settingsStore.updateDataDirectory(dataDirectoryField.contentState.value)
96103 context.settingsStore.updateEnableDownloads(enableDownloadsField.checkedState.value)
104+ context.settingsStore.updateDisableSignatureVerification(disableSignatureVerificationField.checkedState.value)
97105 context.settingsStore.updateSignatureFallbackStrategy(signatureFallbackStrategyField.checkedState.value)
98106 context.settingsStore.updateBinaryDirectoryFallback(enableBinaryDirectoryFallbackField.checkedState.value)
99107 context.settingsStore.updateHeaderCommand(headerCommandField.contentState.value)
@@ -182,5 +190,19 @@ class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<
182190 networkInfoDirField.contentState.update {
183191 settings.networkInfoDir
184192 }
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()
185207 }
186208}
0 commit comments