Skip to content

Impl: create workspace button #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -139,6 +140,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
.addExtraAction(startWorkspaceAction)
.addExtraAction(stopWorkspaceAction)
.addExtraAction(updateWorkspaceTemplateAction)
.addExtraAction(createWorkspaceAction)

private var poller: Job? = null

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -263,6 +271,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
}

private fun updateWorkspaceActions() {
createWorkspaceAction.isEnabled = true

when (tableOfWorkspaces.selectedObject?.agentStatus) {
RUNNING -> {
startWorkspaceAction.isEnabled = false
Expand Down Expand Up @@ -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
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/create.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/main/resources/create_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/resources/messages/CoderGatewayBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down