Skip to content

Commit 51cffae

Browse files
authored
Merge pull request coder#111 from coder/add-doc-for-gateway-ssh-fallback
Refactor: information&warning banner
2 parents 9ca820d + efa98df commit 51cffae

File tree

4 files changed

+69
-28
lines changed

4 files changed

+69
-28
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
- warning system when plugin might not be compatible with Coder REST API
99
- a `Create workspace` button which links to Coder's templates page
1010

11+
### Changed
12+
- redesigned the information&warning banner. Messages can now include hyperlinks
13+
1114
### Fixed
1215
- outdated Coder CLI binaries are cleaned up
1316
- workspace status color style: running workspaces are green, failed ones should be red, everything else is gray

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

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ import com.coder.gateway.icons.CoderIcons
66
import com.coder.gateway.models.CoderWorkspacesWizardModel
77
import com.coder.gateway.models.WorkspaceAgentModel
88
import com.coder.gateway.models.WorkspaceAgentStatus
9-
import com.coder.gateway.models.WorkspaceAgentStatus.DELETING
109
import com.coder.gateway.models.WorkspaceAgentStatus.FAILED
1110
import com.coder.gateway.models.WorkspaceAgentStatus.RUNNING
12-
import com.coder.gateway.models.WorkspaceAgentStatus.STARTING
1311
import com.coder.gateway.models.WorkspaceAgentStatus.STOPPED
14-
import com.coder.gateway.models.WorkspaceAgentStatus.STOPPING
1512
import com.coder.gateway.models.WorkspaceVersionStatus
1613
import com.coder.gateway.sdk.Arch
1714
import com.coder.gateway.sdk.CoderCLIManager
@@ -25,7 +22,6 @@ import com.coder.gateway.sdk.getOS
2522
import com.coder.gateway.sdk.toURL
2623
import com.coder.gateway.sdk.v2.models.Workspace
2724
import com.coder.gateway.sdk.withPath
28-
import com.intellij.icons.AllIcons
2925
import com.intellij.ide.ActivityTracker
3026
import com.intellij.ide.BrowserUtil
3127
import com.intellij.ide.IdeBundle
@@ -72,7 +68,6 @@ import org.zeroturnaround.exec.ProcessExecutor
7268
import java.awt.Component
7369
import java.awt.Dimension
7470
import javax.swing.Icon
75-
import javax.swing.JLabel
7671
import javax.swing.JTable
7772
import javax.swing.JTextField
7873
import javax.swing.ListSelectionModel
@@ -99,7 +94,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
9994
WorkspaceStatusColumnInfo("Status")
10095
)
10196

102-
private val notificationBand = JLabel()
97+
private val notificationBanner = NotificationBanner()
10398
private var tableOfWorkspaces = TableView(listTableModelOfWorkspaces).apply {
10499
setEnableAntialiasing(true)
105100
rowSelectionAllowed = true
@@ -116,13 +111,12 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
116111
selectionModel.addListSelectionListener {
117112
enableNextButtonCallback(selectedObject != null && selectedObject?.agentStatus == RUNNING && selectedObject?.agentOS == OS.LINUX)
118113
if (selectedObject?.agentOS != OS.LINUX) {
119-
notificationBand.apply {
114+
notificationBanner.apply {
120115
isVisible = true
121-
icon = AllIcons.General.Information
122-
text = CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.os.info")
116+
showInfo(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.os.info"))
123117
}
124118
} else {
125-
notificationBand.isVisible = false
119+
notificationBanner.component.isVisible = false
126120
}
127121
updateWorkspaceActions()
128122
}
@@ -142,6 +136,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
142136
.addExtraAction(updateWorkspaceTemplateAction)
143137
.addExtraAction(createWorkspaceAction)
144138

139+
145140
private var poller: Job? = null
146141

147142
override val component = panel {
@@ -174,15 +169,11 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
174169
cell()
175170
}
176171
row {
177-
scrollCell(toolbar.createPanel()).resizableColumn().horizontalAlign(HorizontalAlign.FILL).verticalAlign(VerticalAlign.FILL)
172+
scrollCell(toolbar.createPanel().apply {
173+
add(notificationBanner.component.apply { isVisible = false }, "South")
174+
}).resizableColumn().horizontalAlign(HorizontalAlign.FILL).verticalAlign(VerticalAlign.FILL)
178175
cell()
179-
}.topGap(TopGap.NONE).resizableRow()
180-
row {
181-
cell(notificationBand).resizableColumn().horizontalAlign(HorizontalAlign.FILL).applyToComponent {
182-
font = JBFont.h4().asBold()
183-
isVisible = false
184-
}
185-
}
176+
}.topGap(TopGap.NONE).bottomGap(BottomGap.NONE).resizableRow()
186177
}
187178
}.apply { background = WelcomeScreenUIManager.getMainAssociatedComponentBackground() }
188179

@@ -317,20 +308,18 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
317308
try {
318309
coderClient.initClientSession(localWizardModel.coderURL.toURL(), token)
319310
if (!CoderSemVer.isValidVersion(coderClient.buildVersion)) {
320-
notificationBand.apply {
321-
isVisible = true
322-
icon = AllIcons.General.Warning
323-
text = CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.invalid.coder.version", coderClient.buildVersion)
311+
notificationBanner.apply {
312+
component.isVisible = true
313+
showWarning(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.invalid.coder.version", coderClient.buildVersion))
324314
}
325315
} else {
326316
val coderVersion = CoderSemVer.parse(coderClient.buildVersion)
327317
val testedCoderVersion = CoderSupportedVersions.lastTestedVersion
328318

329319
if (!testedCoderVersion.isCompatibleWith(coderVersion)) {
330-
notificationBand.apply {
331-
isVisible = true
332-
icon = AllIcons.General.Warning
333-
text = CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.coder.version", coderClient.buildVersion)
320+
notificationBanner.apply {
321+
component.isVisible = true
322+
showWarning(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.coder.version", coderClient.buildVersion))
334323
}
335324
}
336325
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.coder.gateway.views.steps
2+
3+
import com.intellij.icons.AllIcons
4+
import com.intellij.openapi.ui.DialogPanel
5+
import com.intellij.ui.dsl.builder.panel
6+
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
7+
import com.intellij.util.ui.JBUI
8+
import javax.swing.JEditorPane
9+
import javax.swing.JLabel
10+
11+
class NotificationBanner {
12+
var component: DialogPanel
13+
private lateinit var icon: JLabel
14+
private lateinit var txt: JEditorPane
15+
16+
init {
17+
component = panel {
18+
row {
19+
icon = icon(AllIcons.General.Warning).applyToComponent {
20+
border = JBUI.Borders.empty(0, 5)
21+
}.component
22+
txt = text("").resizableColumn().horizontalAlign(HorizontalAlign.FILL).applyToComponent { foreground = JBUI.CurrentTheme.NotificationWarning.foregroundColor() }.component
23+
}
24+
}.apply {
25+
background = JBUI.CurrentTheme.NotificationWarning.backgroundColor()
26+
}
27+
}
28+
29+
fun showWarning(warning: String) {
30+
icon.icon = AllIcons.General.Warning
31+
txt.apply {
32+
text = warning
33+
foreground = JBUI.CurrentTheme.NotificationWarning.foregroundColor()
34+
}
35+
36+
component.background = JBUI.CurrentTheme.NotificationWarning.backgroundColor()
37+
38+
}
39+
40+
fun showInfo(info: String) {
41+
icon.icon = AllIcons.General.Information
42+
txt.apply {
43+
text = info
44+
foreground = JBUI.CurrentTheme.NotificationInfo.foregroundColor()
45+
}
46+
47+
component.background = JBUI.CurrentTheme.NotificationInfo.backgroundColor()
48+
}
49+
}

src/main/resources/messages/CoderGatewayBundle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ gateway.connector.view.coder.workspaces.stop.text=Stop Workspace
1616
gateway.connector.view.coder.workspaces.update.text=Update Workspace Template
1717
gateway.connector.view.coder.workspaces.create.text=Create workspace
1818
gateway.connector.view.coder.workspaces.unsupported.os.info=Gateway supports only Linux machines. Support for macOS and Windows is planned.
19-
gateway.connector.view.coder.workspaces.invalid.coder.version=Could not parse Coder version {0}. Coder Gateway plugin might not be compatible with this version.
20-
gateway.connector.view.coder.workspaces.unsupported.coder.version=Coder version {0} might not be compatible with this plugin version.
19+
gateway.connector.view.coder.workspaces.invalid.coder.version=Could not parse Coder version {0}. Coder Gateway plugin might not be compatible with this version. <a href='https://coder.com/docs/coder-oss/latest/ides/gateway#creating-a-new-jetbrains-gateway-connection'>Connect to a Coder workspace manually</a>
20+
gateway.connector.view.coder.workspaces.unsupported.coder.version=Coder version {0} might not be compatible with this plugin version. <a href='https://coder.com/docs/coder-oss/latest/ides/gateway#creating-a-new-jetbrains-gateway-connection'>Connect to a Coder workspace manually</a>
2121
gateway.connector.view.coder.remoteproject.loading.text=Retrieving products...
2222
gateway.connector.view.coder.remoteproject.ide.error.text=Could not retrieve any IDE for workspace {0} because an error was encountered
2323
gateway.connector.view.coder.remoteproject.next.text=Start IDE and connect

0 commit comments

Comments
 (0)