Skip to content

Commit e0e967a

Browse files
authored
Merge pull request #107 from coder/impl-add-link-to-templates
Impl: create workspace button
2 parents 0e2012a + 25e1303 commit e0e967a

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
### Added
88
- warning system when plugin might not be compatible with Coder REST API
9+
- a `Create workspace` button which links to Coder's templates page
910

1011
### Fixed
1112
- outdated Coder CLI binaries are cleaned up
13+
- workspace status color style: running workspaces are green, failed ones should be red, everything else is gray
1214

1315
## 2.1.2 - 2022-11-23
1416

src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ object CoderIcons {
99

1010
val OPEN_TERMINAL = IconLoader.getIcon("open_terminal.svg", javaClass)
1111

12+
val CREATE = IconLoader.getIcon("create.svg", javaClass)
1213
val RUN = IconLoader.getIcon("run.svg", javaClass)
1314
val STOP = IconLoader.getIcon("stop.svg", javaClass)
1415
val UPDATE = IconLoader.getIcon("update.svg", javaClass)

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
131131
private val startWorkspaceAction = StartWorkspaceAction()
132132
private val stopWorkspaceAction = StopWorkspaceAction()
133133
private val updateWorkspaceTemplateAction = UpdateWorkspaceTemplateAction()
134+
private val createWorkspaceAction = CreateWorkspaceAction()
134135

135136
private val toolbar = ToolbarDecorator.createDecorator(tableOfWorkspaces)
136137
.disableAddAction()
@@ -139,6 +140,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
139140
.addExtraAction(startWorkspaceAction)
140141
.addExtraAction(stopWorkspaceAction)
141142
.addExtraAction(updateWorkspaceTemplateAction)
143+
.addExtraAction(createWorkspaceAction)
142144

143145
private var poller: Job? = null
144146

@@ -225,6 +227,12 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
225227
}
226228
}
227229

230+
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) {
231+
override fun actionPerformed(p0: AnActionEvent) {
232+
BrowserUtil.browse(coderClient.coderURL.toURI().resolve("/templates"))
233+
}
234+
}
235+
228236
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) {
229237
override fun actionPerformed(p0: AnActionEvent) {
230238
if (tableOfWorkspaces.selectedObject != null) {
@@ -263,6 +271,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
263271
}
264272

265273
private fun updateWorkspaceActions() {
274+
createWorkspaceAction.isEnabled = true
275+
266276
when (tableOfWorkspaces.selectedObject?.agentStatus) {
267277
RUNNING -> {
268278
startWorkspaceAction.isEnabled = false
@@ -642,8 +652,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
642652

643653
private fun WorkspaceAgentModel.statusColor() = when (this.agentStatus) {
644654
RUNNING -> JBColor.GREEN
645-
STARTING, STOPPING, DELETING -> if (JBColor.isBright()) JBColor.LIGHT_GRAY else JBColor.DARK_GRAY
646-
else -> JBColor.RED
655+
FAILED -> JBColor.RED
656+
else -> if (JBColor.isBright()) JBColor.LIGHT_GRAY else JBColor.DARK_GRAY
647657
}
648658
}
649659

src/main/resources/create.svg

Lines changed: 8 additions & 0 deletions
Loading

src/main/resources/create_dark.svg

Lines changed: 8 additions & 0 deletions
Loading

src/main/resources/messages/CoderGatewayBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ gateway.connector.view.coder.workspaces.next.text=Select IDE and Project
1414
gateway.connector.view.coder.workspaces.start.text=Start Workspace
1515
gateway.connector.view.coder.workspaces.stop.text=Stop Workspace
1616
gateway.connector.view.coder.workspaces.update.text=Update Workspace Template
17+
gateway.connector.view.coder.workspaces.create.text=Create workspace
1718
gateway.connector.view.coder.workspaces.unsupported.os.info=Gateway supports only Linux machines. Support for macOS and Windows is planned.
1819
gateway.connector.view.coder.workspaces.invalid.coder.version=Could not parse Coder version {0}. Coder Gateway plugin might not be compatible with this version.
1920
gateway.connector.view.coder.workspaces.unsupported.coder.version=Coder version {0} might not be compatible with this plugin version.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy