Skip to content

Commit fab60ca

Browse files
committed
Impl: create workspace button
- just a link to Coder's templates page - users will have to manually create the workspace - resolves #91
1 parent 0e2012a commit fab60ca

File tree

6 files changed

+29
-0
lines changed

6 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
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

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: 10 additions & 0 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

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)