diff --git a/CHANGELOG.md b/CHANGELOG.md index add0004d..eac4f6c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ - warning system when plugin might not be compatible with Coder REST API - a `Create workspace` button which links to Coder's templates page +### Changed +- redesigned the information&warning banner. Messages can now include hyperlinks + ### 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 diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt index 25575415..9b19a9b3 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -6,12 +6,9 @@ import com.coder.gateway.icons.CoderIcons import com.coder.gateway.models.CoderWorkspacesWizardModel import com.coder.gateway.models.WorkspaceAgentModel import com.coder.gateway.models.WorkspaceAgentStatus -import com.coder.gateway.models.WorkspaceAgentStatus.DELETING import com.coder.gateway.models.WorkspaceAgentStatus.FAILED import com.coder.gateway.models.WorkspaceAgentStatus.RUNNING -import com.coder.gateway.models.WorkspaceAgentStatus.STARTING import com.coder.gateway.models.WorkspaceAgentStatus.STOPPED -import com.coder.gateway.models.WorkspaceAgentStatus.STOPPING import com.coder.gateway.models.WorkspaceVersionStatus import com.coder.gateway.sdk.Arch import com.coder.gateway.sdk.CoderCLIManager @@ -25,7 +22,6 @@ import com.coder.gateway.sdk.getOS import com.coder.gateway.sdk.toURL import com.coder.gateway.sdk.v2.models.Workspace import com.coder.gateway.sdk.withPath -import com.intellij.icons.AllIcons import com.intellij.ide.ActivityTracker import com.intellij.ide.BrowserUtil import com.intellij.ide.IdeBundle @@ -72,7 +68,6 @@ import org.zeroturnaround.exec.ProcessExecutor import java.awt.Component import java.awt.Dimension import javax.swing.Icon -import javax.swing.JLabel import javax.swing.JTable import javax.swing.JTextField import javax.swing.ListSelectionModel @@ -99,7 +94,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : WorkspaceStatusColumnInfo("Status") ) - private val notificationBand = JLabel() + private val notificationBanner = NotificationBanner() private var tableOfWorkspaces = TableView(listTableModelOfWorkspaces).apply { setEnableAntialiasing(true) rowSelectionAllowed = true @@ -116,13 +111,12 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : selectionModel.addListSelectionListener { enableNextButtonCallback(selectedObject != null && selectedObject?.agentStatus == RUNNING && selectedObject?.agentOS == OS.LINUX) if (selectedObject?.agentOS != OS.LINUX) { - notificationBand.apply { + notificationBanner.apply { isVisible = true - icon = AllIcons.General.Information - text = CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.os.info") + showInfo(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.os.info")) } } else { - notificationBand.isVisible = false + notificationBanner.component.isVisible = false } updateWorkspaceActions() } @@ -142,6 +136,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : .addExtraAction(updateWorkspaceTemplateAction) .addExtraAction(createWorkspaceAction) + private var poller: Job? = null override val component = panel { @@ -174,15 +169,11 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : cell() } row { - scrollCell(toolbar.createPanel()).resizableColumn().horizontalAlign(HorizontalAlign.FILL).verticalAlign(VerticalAlign.FILL) + scrollCell(toolbar.createPanel().apply { + add(notificationBanner.component.apply { isVisible = false }, "South") + }).resizableColumn().horizontalAlign(HorizontalAlign.FILL).verticalAlign(VerticalAlign.FILL) cell() - }.topGap(TopGap.NONE).resizableRow() - row { - cell(notificationBand).resizableColumn().horizontalAlign(HorizontalAlign.FILL).applyToComponent { - font = JBFont.h4().asBold() - isVisible = false - } - } + }.topGap(TopGap.NONE).bottomGap(BottomGap.NONE).resizableRow() } }.apply { background = WelcomeScreenUIManager.getMainAssociatedComponentBackground() } @@ -317,20 +308,18 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : try { coderClient.initClientSession(localWizardModel.coderURL.toURL(), token) if (!CoderSemVer.isValidVersion(coderClient.buildVersion)) { - notificationBand.apply { - isVisible = true - icon = AllIcons.General.Warning - text = CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.invalid.coder.version", coderClient.buildVersion) + notificationBanner.apply { + component.isVisible = true + showWarning(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.invalid.coder.version", coderClient.buildVersion)) } } else { val coderVersion = CoderSemVer.parse(coderClient.buildVersion) val testedCoderVersion = CoderSupportedVersions.lastTestedVersion if (!testedCoderVersion.isCompatibleWith(coderVersion)) { - notificationBand.apply { - isVisible = true - icon = AllIcons.General.Warning - text = CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.coder.version", coderClient.buildVersion) + notificationBanner.apply { + component.isVisible = true + showWarning(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.coder.version", coderClient.buildVersion)) } } } diff --git a/src/main/kotlin/com/coder/gateway/views/steps/NotificationBanner.kt b/src/main/kotlin/com/coder/gateway/views/steps/NotificationBanner.kt new file mode 100644 index 00000000..e0cb8b1a --- /dev/null +++ b/src/main/kotlin/com/coder/gateway/views/steps/NotificationBanner.kt @@ -0,0 +1,49 @@ +package com.coder.gateway.views.steps + +import com.intellij.icons.AllIcons +import com.intellij.openapi.ui.DialogPanel +import com.intellij.ui.dsl.builder.panel +import com.intellij.ui.dsl.gridLayout.HorizontalAlign +import com.intellij.util.ui.JBUI +import javax.swing.JEditorPane +import javax.swing.JLabel + +class NotificationBanner { + var component: DialogPanel + private lateinit var icon: JLabel + private lateinit var txt: JEditorPane + + init { + component = panel { + row { + icon = icon(AllIcons.General.Warning).applyToComponent { + border = JBUI.Borders.empty(0, 5) + }.component + txt = text("").resizableColumn().horizontalAlign(HorizontalAlign.FILL).applyToComponent { foreground = JBUI.CurrentTheme.NotificationWarning.foregroundColor() }.component + } + }.apply { + background = JBUI.CurrentTheme.NotificationWarning.backgroundColor() + } + } + + fun showWarning(warning: String) { + icon.icon = AllIcons.General.Warning + txt.apply { + text = warning + foreground = JBUI.CurrentTheme.NotificationWarning.foregroundColor() + } + + component.background = JBUI.CurrentTheme.NotificationWarning.backgroundColor() + + } + + fun showInfo(info: String) { + icon.icon = AllIcons.General.Information + txt.apply { + text = info + foreground = JBUI.CurrentTheme.NotificationInfo.foregroundColor() + } + + component.background = JBUI.CurrentTheme.NotificationInfo.backgroundColor() + } +} \ No newline at end of file diff --git a/src/main/resources/messages/CoderGatewayBundle.properties b/src/main/resources/messages/CoderGatewayBundle.properties index 9bbae2c1..13ad7cda 100644 --- a/src/main/resources/messages/CoderGatewayBundle.properties +++ b/src/main/resources/messages/CoderGatewayBundle.properties @@ -16,8 +16,8 @@ gateway.connector.view.coder.workspaces.stop.text=Stop Workspace gateway.connector.view.coder.workspaces.update.text=Update Workspace Template gateway.connector.view.coder.workspaces.create.text=Create workspace gateway.connector.view.coder.workspaces.unsupported.os.info=Gateway supports only Linux machines. Support for macOS and Windows is planned. -gateway.connector.view.coder.workspaces.invalid.coder.version=Could not parse Coder version {0}. Coder Gateway plugin might not be compatible with this version. -gateway.connector.view.coder.workspaces.unsupported.coder.version=Coder version {0} might not be compatible with this plugin version. +gateway.connector.view.coder.workspaces.invalid.coder.version=Could not parse Coder version {0}. Coder Gateway plugin might not be compatible with this version. Connect to a Coder workspace manually +gateway.connector.view.coder.workspaces.unsupported.coder.version=Coder version {0} might not be compatible with this plugin version. Connect to a Coder workspace manually gateway.connector.view.coder.remoteproject.loading.text=Retrieving products... gateway.connector.view.coder.remoteproject.ide.error.text=Could not retrieve any IDE for workspace {0} because an error was encountered gateway.connector.view.coder.remoteproject.next.text=Start IDE and connect