Skip to content

Commit 2a7eba9

Browse files
ssh configuration changes notification (#224)
--------- Co-authored-by: Danil Ovchinnikov <Danil42Worker@gmail.com>
1 parent 6425780 commit 2a7eba9

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

src/main/kotlin/com/vk/admstorm/AdmStormStartupActivity.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.vk.admstorm.notifications.AdmNotification
1717
import com.vk.admstorm.services.SentryService
1818
import com.vk.admstorm.settings.AdmStormSettingsState
1919
import com.vk.admstorm.ssh.SshConnectionService
20+
import com.vk.admstorm.startup.ChangeSshBackendStartup
2021
import com.vk.admstorm.utils.MyUtils.measureTime
2122
import com.vk.admstorm.utils.ServerNameProvider
2223
import com.vk.admstorm.utils.extensions.pluginEnabled
@@ -41,6 +42,9 @@ class AdmStormStartupActivity : ProjectActivity {
4142
return
4243
}
4344

45+
ChangeSshBackendStartup.changeConfigurationProcess(project)
46+
checkUpdates(project)
47+
4448
measureTime(LOG, "patch cpp highlight") {
4549
val cppType = FileTypeChooser.getKnownFileTypeOrAssociate(".c") as AbstractFileType
4650
CppTypeHighlightPatcher.patch(cppType)
@@ -52,8 +56,6 @@ class AdmStormStartupActivity : ProjectActivity {
5256
}
5357
}
5458

55-
checkUpdates(project)
56-
5759
// Это необходимо чтобы для бенчмарков показывались все пункты в списке
5860
// который открывается при клике на иконку рядом с классом или методом.
5961
val key = Registry.get("suggest.all.run.configurations.from.context")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.vk.admstorm.startup
2+
3+
import com.intellij.ide.util.PropertiesComponent
4+
import com.intellij.openapi.diagnostic.logger
5+
import com.intellij.openapi.options.advanced.AdvancedSettings
6+
import com.intellij.openapi.project.Project
7+
import com.intellij.ssh.config.SshConnectionConfigService
8+
import com.vk.admstorm.notifications.AdmNotification
9+
10+
object ChangeSshBackendStartup {
11+
private val LOG = logger<ChangeSshBackendStartup>()
12+
13+
private const val SSH_NOTIFICATOR_OPTION = "sshLegacyChanges"
14+
private const val SSH_CONFIG_BACKEND = "ssh.config.backend"
15+
16+
private fun changeSshConfiguration(configValue: SshConnectionConfigService.Kind) {
17+
AdvancedSettings.setEnum(SSH_CONFIG_BACKEND, configValue)
18+
}
19+
20+
fun changeConfigurationProcess(project: Project) {
21+
val dntShow = PropertiesComponent.getInstance(project).getBoolean(SSH_NOTIFICATOR_OPTION)
22+
if (dntShow) {
23+
LOG.info("LEGACY SSH option was enabled")
24+
return
25+
}
26+
27+
val sshSettingValue = AdvancedSettings.getEnum(SSH_CONFIG_BACKEND, SshConnectionConfigService.Kind::class.java)
28+
if (sshSettingValue == SshConnectionConfigService.Kind.LEGACY) {
29+
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true)
30+
LOG.info("LEGACY SSH option was enabled before")
31+
return
32+
}
33+
34+
changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY)
35+
LOG.info("LEGACY SSH has been changed")
36+
37+
AdmNotification("We changed your ssh type to LEGACY")
38+
.withActions(
39+
AdmNotification.Action("Don`t show it again") { _, notification ->
40+
LOG.info("LEGACY SSH option has been set")
41+
notification.expire()
42+
}
43+
).withActions(
44+
AdmNotification.Action("Rollback and turn off this notification") { _, notification ->
45+
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH)
46+
LOG.info("SSH option changed to OpenSSH")
47+
notification.expire()
48+
}
49+
).show(project)
50+
51+
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true)
52+
}
53+
}

0 commit comments

Comments
 (0)