Skip to content

Commit 91dad07

Browse files
committed
Impl: action button to open SSH terminal
- added the ability to open a web SSH terminal from the Recent Workspaces panel - added missing tooltips for some actions in the Recent Workspaces
1 parent 705f186 commit 91dad07

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

src/main/kotlin/com/coder/gateway/CoderGatewayConnectionProvider.kt

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
3636
val ideProductCode = parameters["ide_product_code"]!!
3737
val ideBuildNumber = parameters["ide_build_number"]!!
3838
val ideDownloadLink = parameters["ide_download_link"]!!
39+
val webTerminalLink = parameters["web_terminal_link"]!!
3940

4041
if (coderWorkspaceHostname != null && projectPath != null) {
4142
val connection = CoderConnectionMetadata(coderWorkspaceHostname)
@@ -89,6 +90,7 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
8990
ideProductCode,
9091
ideBuildNumber,
9192
ideDownloadLink,
93+
webTerminalLink,
9294
)
9395
)
9496

src/main/kotlin/com/coder/gateway/models/RecentWorkspaceConnection.kt

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import com.intellij.openapi.components.BaseState
44
import com.intellij.util.xmlb.annotations.Attribute
55

66
class RecentWorkspaceConnection() : BaseState(), Comparable<RecentWorkspaceConnection> {
7-
constructor(hostname: String, prjPath: String, openedAt: String, productCode: String, buildNumber: String, source: String) : this() {
7+
constructor(hostname: String, prjPath: String, openedAt: String, productCode: String, buildNumber: String, source: String, terminalLink: String) : this() {
88
coderWorkspaceHostname = hostname
99
projectPath = prjPath
1010
lastOpened = openedAt
1111
ideProductCode = productCode
1212
ideBuildNumber = buildNumber
1313
downloadSource = source
14+
webTerminalLink = terminalLink
1415
}
1516

1617
@get:Attribute
@@ -31,6 +32,9 @@ class RecentWorkspaceConnection() : BaseState(), Comparable<RecentWorkspaceConne
3132
@get:Attribute
3233
var downloadSource by string()
3334

35+
@get:Attribute
36+
var webTerminalLink by string()
37+
3438
override fun equals(other: Any?): Boolean {
3539
if (this === other) return true
3640
if (javaClass != other?.javaClass) return false
@@ -43,6 +47,7 @@ class RecentWorkspaceConnection() : BaseState(), Comparable<RecentWorkspaceConne
4347
if (ideProductCode != other.ideProductCode) return false
4448
if (ideBuildNumber != other.ideBuildNumber) return false
4549
if (downloadSource != other.downloadSource) return false
50+
if (webTerminalLink != other.webTerminalLink) return false
4651

4752
return true
4853
}
@@ -54,6 +59,8 @@ class RecentWorkspaceConnection() : BaseState(), Comparable<RecentWorkspaceConne
5459
result = 31 * result + (ideProductCode?.hashCode() ?: 0)
5560
result = 31 * result + (ideBuildNumber?.hashCode() ?: 0)
5661
result = 31 * result + (downloadSource?.hashCode() ?: 0)
62+
result = 31 * result + (webTerminalLink?.hashCode() ?: 0)
63+
5764
return result
5865
}
5966

@@ -72,6 +79,10 @@ class RecentWorkspaceConnection() : BaseState(), Comparable<RecentWorkspaceConne
7279

7380
val m = other.downloadSource?.let { downloadSource?.compareTo(it) }
7481
if (m != null && m != 0) return m
82+
83+
val n = other.webTerminalLink?.let { webTerminalLink?.compareTo(it) }
84+
if (n != null && n != 0) return n
85+
7586
return 0
7687
}
7788
}

src/main/kotlin/com/coder/gateway/views/CoderGatewayRecentWorkspaceConnectionsView.kt

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.coder.gateway.views
33
import com.coder.gateway.CoderGatewayBundle
44
import com.coder.gateway.icons.CoderIcons
55
import com.coder.gateway.services.CoderRecentWorkspaceConnectionsService
6+
import com.intellij.ide.BrowserUtil
67
import com.intellij.openapi.actionSystem.AnActionEvent
78
import com.intellij.openapi.components.service
89
import com.intellij.openapi.project.DumbAwareAction
@@ -11,6 +12,7 @@ import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenUIManager
1112
import com.intellij.ui.components.ActionLink
1213
import com.intellij.ui.components.JBScrollPane
1314
import com.intellij.ui.dsl.builder.BottomGap
15+
import com.intellij.ui.dsl.builder.RightGap
1416
import com.intellij.ui.dsl.builder.TopGap
1517
import com.intellij.ui.dsl.builder.panel
1618
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
@@ -60,8 +62,12 @@ class CoderGatewayRecentWorkspaceConnectionsView : GatewayRecentConnections {
6062
if (hostname != null) {
6163
label(hostname).applyToComponent {
6264
font = JBFont.h3().asBold()
63-
}.horizontalAlign(HorizontalAlign.LEFT)
64-
cell()
65+
}.horizontalAlign(HorizontalAlign.LEFT).gap(RightGap.SMALL)
66+
actionButton(object : DumbAwareAction("Open SSH Web Terminal", "", CoderIcons.OPEN_TERMINAL) {
67+
override fun actionPerformed(e: AnActionEvent) {
68+
BrowserUtil.browse(recentConnections[0]?.webTerminalLink ?: "")
69+
}
70+
})
6571
}
6672
}.topGap(TopGap.MEDIUM)
6773

@@ -78,7 +84,8 @@ class CoderGatewayRecentWorkspaceConnectionsView : GatewayRecentConnections {
7884
"project_path" to connectionDetails.projectPath!!,
7985
"ide_product_code" to "${product.productCode}",
8086
"ide_build_number" to "${connectionDetails.ideBuildNumber}",
81-
"ide_download_link" to "${connectionDetails.downloadSource}"
87+
"ide_download_link" to "${connectionDetails.downloadSource}",
88+
"web_terminal_link" to "${connectionDetails.webTerminalLink}"
8289
)
8390
)
8491
}
@@ -88,7 +95,7 @@ class CoderGatewayRecentWorkspaceConnectionsView : GatewayRecentConnections {
8895
foreground = JBUI.CurrentTheme.ContextHelp.FOREGROUND
8996
font = ComponentPanelBuilder.getCommentFont(font)
9097
}
91-
actionButton(object : DumbAwareAction("", "", CoderIcons.DELETE) {
98+
actionButton(object : DumbAwareAction("Remove", "", CoderIcons.DELETE) {
9299
override fun actionPerformed(e: AnActionEvent) {
93100
recentConnectionsService.removeConnection(connectionDetails)
94101
updateContentView()

src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ class CoderLocateRemoteProjectStepView : CoderWorkspacesWizardStep, Disposable {
146146
"project_path" to tfProject.text,
147147
"ide_product_code" to "${selectedIDE.product.productCode}",
148148
"ide_build_number" to "${selectedIDE.buildNumber}",
149-
"ide_download_link" to "${selectedIDE.source}"
149+
"ide_download_link" to "${selectedIDE.source}",
150+
"web_terminal_link" to "${terminalLink.url}"
150151
)
151152
)
152153
}

0 commit comments

Comments
 (0)