@@ -17,6 +17,7 @@ import com.coder.gateway.sdk.CoderCLIManager
1717import com.coder.gateway.sdk.CoderRestClientService
1818import com.coder.gateway.sdk.OS
1919import com.coder.gateway.sdk.ex.AuthenticationResponseException
20+ import com.coder.gateway.sdk.ex.WorkspaceResponseException
2021import com.coder.gateway.sdk.getOS
2122import com.coder.gateway.sdk.toURL
2223import com.coder.gateway.sdk.v2.models.Workspace
@@ -171,13 +172,37 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
171172
172173 private inner class StartWorkspaceAction : AnActionButton (CoderGatewayBundle .message("gateway.connector.view.coder.workspaces.start.text"), CoderGatewayBundle .message("gateway.connector.view.coder.workspaces.start.text"), CoderIcons .RUN ) {
173174 override fun actionPerformed (p0 : AnActionEvent ) {
174- TODO (" Not yet implemented" )
175+ if (tableOfWorkspaces.selectedObject != null ) {
176+ val workspace = tableOfWorkspaces.selectedObject as WorkspaceAgentModel
177+ cs.launch {
178+ withContext(Dispatchers .IO ) {
179+ try {
180+ coderClient.startWorkspace(workspace.workspaceID, workspace.workspaceName)
181+ startWorkspaceAction.isEnabled = false
182+ } catch (e: WorkspaceResponseException ) {
183+ logger.warn(" Could not build workspace ${workspace.name} , reason: $e " )
184+ }
185+ }
186+ }
187+ }
175188 }
176189 }
177190
178191 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 ) {
179192 override fun actionPerformed (p0 : AnActionEvent ) {
180- TODO (" Not yet implemented" )
193+ if (tableOfWorkspaces.selectedObject != null ) {
194+ val workspace = tableOfWorkspaces.selectedObject as WorkspaceAgentModel
195+ cs.launch {
196+ withContext(Dispatchers .IO ) {
197+ try {
198+ coderClient.stopWorkspace(workspace.workspaceID, workspace.workspaceName)
199+ stopWorkspaceAction.isEnabled = false
200+ } catch (e: WorkspaceResponseException ) {
201+ logger.warn(" Could not stop workspace ${workspace.name} , reason: $e " )
202+ }
203+ }
204+ }
205+ }
181206 }
182207 }
183208
@@ -310,6 +335,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
310335 0 -> {
311336 listOf (
312337 WorkspaceAgentModel (
338+ this .id,
339+ this .name,
313340 this .name,
314341 this .templateName,
315342 WorkspaceVersionStatus .from(this ),
@@ -324,6 +351,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
324351 1 -> {
325352 listOf (
326353 WorkspaceAgentModel (
354+ this .id,
355+ this .name,
327356 this .name,
328357 this .templateName,
329358 WorkspaceVersionStatus .from(this ),
@@ -338,6 +367,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
338367 else -> agents.map { agent ->
339368 val workspaceName = " ${this .name} .${agent.name} "
340369 WorkspaceAgentModel (
370+ this .id,
371+ this .name,
341372 workspaceName,
342373 this .templateName,
343374 WorkspaceVersionStatus .from(this ),
@@ -353,6 +384,8 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
353384 logger.warn(" Agent(s) for ${this .name} could not be retrieved. Reason: $e " )
354385 listOf (
355386 WorkspaceAgentModel (
387+ this .id,
388+ this .name,
356389 this .name,
357390 this .templateName,
358391 WorkspaceVersionStatus .from(this ),
0 commit comments