diff --git a/CHANGELOG.md b/CHANGELOG.md index 639edd3b..add0004d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,11 @@ ### Added - warning system when plugin might not be compatible with Coder REST API +- a `Create workspace` button which links to Coder's templates page ### 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 ## 2.1.2 - 2022-11-23 diff --git a/src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt b/src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt index 3f7a587f..16322770 100644 --- a/src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt +++ b/src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt @@ -9,6 +9,7 @@ object CoderIcons { val OPEN_TERMINAL = IconLoader.getIcon("open_terminal.svg", javaClass) + val CREATE = IconLoader.getIcon("create.svg", javaClass) val RUN = IconLoader.getIcon("run.svg", javaClass) val STOP = IconLoader.getIcon("stop.svg", javaClass) val UPDATE = IconLoader.getIcon("update.svg", javaClass) 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 0c61414c..25575415 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -131,6 +131,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : private val startWorkspaceAction = StartWorkspaceAction() private val stopWorkspaceAction = StopWorkspaceAction() private val updateWorkspaceTemplateAction = UpdateWorkspaceTemplateAction() + private val createWorkspaceAction = CreateWorkspaceAction() private val toolbar = ToolbarDecorator.createDecorator(tableOfWorkspaces) .disableAddAction() @@ -139,6 +140,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : .addExtraAction(startWorkspaceAction) .addExtraAction(stopWorkspaceAction) .addExtraAction(updateWorkspaceTemplateAction) + .addExtraAction(createWorkspaceAction) private var poller: Job? = null @@ -225,6 +227,12 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : } } + private inner class CreateWorkspaceAction : AnActionButton(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.create.text"), CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.create.text"), CoderIcons.CREATE) { + override fun actionPerformed(p0: AnActionEvent) { + BrowserUtil.browse(coderClient.coderURL.toURI().resolve("/templates")) + } + } + private inner class StopWorkspaceAction : AnActionButton(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.stop.text"), CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.stop.text"), CoderIcons.STOP) { override fun actionPerformed(p0: AnActionEvent) { if (tableOfWorkspaces.selectedObject != null) { @@ -263,6 +271,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : } private fun updateWorkspaceActions() { + createWorkspaceAction.isEnabled = true + when (tableOfWorkspaces.selectedObject?.agentStatus) { RUNNING -> { startWorkspaceAction.isEnabled = false @@ -642,8 +652,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) : private fun WorkspaceAgentModel.statusColor() = when (this.agentStatus) { RUNNING -> JBColor.GREEN - STARTING, STOPPING, DELETING -> if (JBColor.isBright()) JBColor.LIGHT_GRAY else JBColor.DARK_GRAY - else -> JBColor.RED + FAILED -> JBColor.RED + else -> if (JBColor.isBright()) JBColor.LIGHT_GRAY else JBColor.DARK_GRAY } } diff --git a/src/main/resources/create.svg b/src/main/resources/create.svg new file mode 100644 index 00000000..c6da8ba4 --- /dev/null +++ b/src/main/resources/create.svg @@ -0,0 +1,8 @@ +<!-- Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. --> +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"> + <g fill="none" fill-rule="evenodd"> + <rect width="8" height="2" x="4" y="7" fill="#6E6E6E" transform="rotate(90 8 8)"/> + <path fill="#6E6E6E" d="M8,15 C4.13400675,15 1,11.8659932 1,8 C1,4.13400675 4.13400675,1 8,1 C11.8659932,1 15,4.13400675 15,8 C15,11.8659932 11.8659932,15 8,15 Z M8,13.6875 C11.1411195,13.6875 13.6875,11.1411195 13.6875,8 C13.6875,4.85888049 11.1411195,2.3125 8,2.3125 C4.85888049,2.3125 2.3125,4.85888049 2.3125,8 C2.3125,11.1411195 4.85888049,13.6875 8,13.6875 Z"/> + <rect width="8" height="2" x="4" y="7" fill="#6E6E6E"/> + </g> +</svg> diff --git a/src/main/resources/create_dark.svg b/src/main/resources/create_dark.svg new file mode 100644 index 00000000..511a8ef5 --- /dev/null +++ b/src/main/resources/create_dark.svg @@ -0,0 +1,8 @@ +<!-- Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. --> +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"> + <g fill="none" fill-rule="evenodd"> + <rect width="8" height="2" x="4" y="7" fill="#AFB1B3" transform="rotate(90 8 8)"/> + <path fill="#AFB1B3" d="M8,15 C4.13400675,15 1,11.8659932 1,8 C1,4.13400675 4.13400675,1 8,1 C11.8659932,1 15,4.13400675 15,8 C15,11.8659932 11.8659932,15 8,15 Z M8,13.6875 C11.1411195,13.6875 13.6875,11.1411195 13.6875,8 C13.6875,4.85888049 11.1411195,2.3125 8,2.3125 C4.85888049,2.3125 2.3125,4.85888049 2.3125,8 C2.3125,11.1411195 4.85888049,13.6875 8,13.6875 Z"/> + <rect width="8" height="2" x="4" y="7" fill="#AFB1B3"/> + </g> +</svg> diff --git a/src/main/resources/messages/CoderGatewayBundle.properties b/src/main/resources/messages/CoderGatewayBundle.properties index 05bd400d..9bbae2c1 100644 --- a/src/main/resources/messages/CoderGatewayBundle.properties +++ b/src/main/resources/messages/CoderGatewayBundle.properties @@ -14,6 +14,7 @@ gateway.connector.view.coder.workspaces.next.text=Select IDE and Project gateway.connector.view.coder.workspaces.start.text=Start Workspace 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.