-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8dfb28
commit 6a48860
Showing
3 changed files
with
57 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/kotlin/com/vk/admstorm/startup/ChangeSshBackendStartup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.vk.admstorm.startup | ||
|
||
import com.intellij.ide.util.PropertiesComponent | ||
import com.intellij.openapi.diagnostic.logger | ||
import com.intellij.openapi.options.advanced.AdvancedSettings | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.ssh.config.SshConnectionConfigService | ||
import com.vk.admstorm.notifications.AdmNotification | ||
|
||
object ChangeSshBackendStartup { | ||
private val LOG = logger<ChangeSshBackendStartup>() | ||
|
||
private const val SSH_NOTIFICATOR_OPTION = "sshLegacyChanges" | ||
private const val SSH_CONFIG_BACKEND = "ssh.config.backend" | ||
|
||
private fun changeSshConfiguration(configValue: SshConnectionConfigService.Kind) { | ||
AdvancedSettings.setEnum(SSH_CONFIG_BACKEND, configValue) | ||
} | ||
|
||
fun changeConfigurationProcess(project: Project) { | ||
val dntShow = PropertiesComponent.getInstance(project).getBoolean(SSH_NOTIFICATOR_OPTION) | ||
if (dntShow) { | ||
LOG.info("LEGACY SSH option was enabled") | ||
return | ||
} | ||
|
||
val sshSettingValue = AdvancedSettings.getEnum(SSH_CONFIG_BACKEND, SshConnectionConfigService.Kind::class.java) | ||
if (sshSettingValue == SshConnectionConfigService.Kind.LEGACY) { | ||
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true) | ||
LOG.info("LEGACY SSH option was enabled before") | ||
return | ||
} | ||
|
||
changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY) | ||
LOG.info("LEGACY SSH has been changed") | ||
|
||
AdmNotification("We changed your ssh type to LEGACY") | ||
.withActions( | ||
AdmNotification.Action("Don`t show it again") { _, notification -> | ||
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true) | ||
LOG.info("LEGACY SSH option has been set") | ||
notification.expire() | ||
} | ||
).withActions( | ||
AdmNotification.Action("Rollback and turn off this notification") { _, notification -> | ||
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH) | ||
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true) | ||
LOG.info("SSH option changed to OpenSSH") | ||
notification.expire() | ||
} | ||
).show(project) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters