Skip to content

Fix connection handle window #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@
## Unreleased

### Added

- warning system when plugin might not be compatible with Coder REST API
- a `Create workspace` button which links to Coder's templates page
- workspace icons
- quick toolbar action to open Coder Dashboard in the browser

### Changed

- redesigned the information&warning banner. Messages can now include hyperlinks

### Removed

- connection handle window is no longer displayed

### Fixed

- outdated Coder CLI binaries are cleaned up
- workspace status color style: running workspaces are green, failed ones should be red, everything else is gray
- typos in plugin description

## 2.1.2 - 2022-11-23

### Added

- upgraded support for the latest Coder REST API
- support for latest Gateway 2022.2.x builds

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ package com.coder.gateway
import com.coder.gateway.models.RecentWorkspaceConnection
import com.coder.gateway.services.CoderRecentWorkspaceConnectionsService
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.rd.util.launchUnderBackgroundProgress
import com.intellij.remote.AuthType
import com.intellij.remote.RemoteCredentialsHolder
import com.intellij.ssh.config.unified.SshConfig
import com.jetbrains.gateway.api.ConnectionRequestor
import com.jetbrains.gateway.api.GatewayConnectionHandle
import com.jetbrains.gateway.api.GatewayConnectionProvider
import com.jetbrains.gateway.api.GatewayUI
import com.jetbrains.gateway.ssh.HighLevelHostAccessor
import com.jetbrains.gateway.ssh.HostDeployInputs
import com.jetbrains.gateway.ssh.IdeInfo
Expand All @@ -30,7 +30,6 @@ import java.time.format.DateTimeFormatter
class CoderGatewayConnectionProvider : GatewayConnectionProvider {
private val recentConnectionsService = service<CoderRecentWorkspaceConnectionsService>()

private val connections = mutableSetOf<CoderConnectionMetadata>()
private val localTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm")

override suspend fun connect(parameters: Map<String, String>, requestor: ConnectionRequestor): GatewayConnectionHandle? {
Expand All @@ -42,11 +41,6 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
val webTerminalLink = parameters["web_terminal_link"]!!

if (coderWorkspaceHostname != null && projectPath != null) {
val connection = CoderConnectionMetadata(coderWorkspaceHostname)
if (connection in connections) {
logger.warn("There is already a connection started on ${connection.workspaceHostname}")
return null
}
val sshConfiguration = SshConfig(true).apply {
setHost(coderWorkspaceHostname)
setUsername("coder")
Expand Down Expand Up @@ -89,27 +83,12 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
}

recentConnectionsService.addRecentConnection(RecentWorkspaceConnection(coderWorkspaceHostname, projectPath, localTimeFormatter.format(LocalDateTime.now()), ideProductCode, ideBuildNumber, ideDownloadLink, webTerminalLink))

return object : GatewayConnectionHandle(clientLifetime) {
override fun getTitle(): String {
return "Connection to Coder Workspaces"
}

override fun hideToTrayOnStart(): Boolean {
return false
}
}
GatewayUI.getInstance().reset()
}
return null
}

override fun isApplicable(parameters: Map<String, String>): Boolean {
return parameters["type"] == "coder"
}

companion object {
val logger = Logger.getInstance(CoderGatewayConnectionProvider::class.java.simpleName)
}
}

internal data class CoderConnectionMetadata(val workspaceHostname: String)
}