@@ -10,13 +10,13 @@ import com.coder.gateway.models.WorkspaceAgentListModel
10
10
import com.coder.gateway.models.WorkspaceProjectIDE
11
11
import com.coder.gateway.models.toWorkspaceProjectIDE
12
12
import com.coder.gateway.sdk.CoderRestClient
13
- import com.coder.gateway.sdk.ex.APIResponseException
14
13
import com.coder.gateway.sdk.v2.models.WorkspaceStatus
15
14
import com.coder.gateway.sdk.v2.models.toAgentList
16
15
import com.coder.gateway.services.CoderRecentWorkspaceConnectionsService
17
16
import com.coder.gateway.services.CoderRestClientService
18
17
import com.coder.gateway.services.CoderSettingsService
19
18
import com.coder.gateway.util.humanizeConnectionError
19
+ import com.coder.gateway.util.toURL
20
20
import com.coder.gateway.util.withPath
21
21
import com.coder.gateway.util.withoutNull
22
22
import com.intellij.icons.AllIcons
@@ -56,7 +56,6 @@ import kotlinx.coroutines.launch
56
56
import kotlinx.coroutines.withContext
57
57
import java.awt.Component
58
58
import java.awt.Dimension
59
- import java.net.URL
60
59
import java.util.Locale
61
60
import javax.swing.JComponent
62
61
import javax.swing.event.DocumentEvent
@@ -159,7 +158,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
159
158
panel {
160
159
connectionsByDeployment.forEach { (deploymentURL, connectionsByWorkspace) ->
161
160
var first = true
162
- val deployment = deployments[deploymentURL.toString() ]
161
+ val deployment = deployments[deploymentURL]
163
162
val deploymentError = deployment?.error
164
163
connectionsByWorkspace.forEach { (workspaceName, connections) ->
165
164
// Show the error at the top of each deployment list.
@@ -198,7 +197,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
198
197
label(workspaceName).applyToComponent {
199
198
font = JBFont .h3().asBold()
200
199
}.align(AlignX .LEFT ).gap(RightGap .SMALL )
201
- label(deploymentURL.toString() ).applyToComponent {
200
+ label(deploymentURL).applyToComponent {
202
201
foreground = UIUtil .getContextHelpForeground()
203
202
font = ComponentPanelBuilder .getCommentFont(font)
204
203
}
@@ -305,7 +304,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
305
304
/* *
306
305
* Get valid connections grouped by deployment and workspace.
307
306
*/
308
- private fun getConnectionsByDeployment (filter : Boolean ): Map <URL , Map <String , List <WorkspaceProjectIDE >>> {
307
+ private fun getConnectionsByDeployment (filter : Boolean ): Map <String , Map <String , List <WorkspaceProjectIDE >>> {
309
308
return recentConnectionsService.getAllRecentConnections()
310
309
// Validate and parse connections.
311
310
.mapNotNull {
@@ -319,7 +318,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
319
318
}
320
319
.filter { ! filter || matchesFilter(it) }
321
320
// Group by the deployment.
322
- .groupBy { it.deploymentURL }
321
+ .groupBy { it.deploymentURL.toString() }
323
322
// Group the connections in each deployment by workspace.
324
323
.mapValues { (_, connections) ->
325
324
connections
@@ -369,12 +368,12 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
369
368
withContext(Dispatchers .IO ) {
370
369
val connectionsByDeployment = getConnectionsByDeployment(false )
371
370
connectionsByDeployment.forEach { (deploymentURL, connectionsByWorkspace) ->
372
- val deployment = deployments.getOrPut(deploymentURL.toString() ) { DeploymentInfo () }
371
+ val deployment = deployments.getOrPut(deploymentURL) { DeploymentInfo () }
373
372
try {
374
373
val client = deployment.client
375
374
? : CoderRestClientService (
376
- deploymentURL,
377
- settings.token(deploymentURL)?.first,
375
+ deploymentURL.toURL() ,
376
+ settings.token(deploymentURL.toURL() )?.first,
378
377
)
379
378
380
379
// Delete connections that have no workspace.
@@ -390,13 +389,13 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
390
389
deployment.items = items
391
390
deployment.error = null
392
391
} catch (e: Exception ) {
393
- val msg = humanizeConnectionError(deploymentURL, settings.requireTokenAuth, e)
392
+ val msg = humanizeConnectionError(deploymentURL.toURL() , settings.requireTokenAuth, e)
394
393
deployment.items = null
395
394
deployment.error = msg
396
395
logger.error(msg, e)
397
- if (e is APIResponseException && e.isUnauthorized && settings.requireTokenAuth) {
398
- // TODO: Ask for a token and reconfigure the CLI.
399
- }
396
+ // TODO: Ask for a token and reconfigure the CLI.
397
+ // if (e is APIResponseException && e.isUnauthorized && settings.requireTokenAuth) {
398
+ // }
400
399
}
401
400
}
402
401
}
0 commit comments