Skip to content

Commit a4432f0

Browse files
authored
Merge pull request #135 from coder/minor-fixes
Minor fixes
2 parents c6a5c62 + d2b4fda commit a4432f0

File tree

4 files changed

+9
-30
lines changed

4 files changed

+9
-30
lines changed

src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ package com.coder.gateway.sdk
33
import com.coder.gateway.sdk.convertors.InstantConverter
44
import com.coder.gateway.sdk.ex.AuthenticationResponseException
55
import com.coder.gateway.sdk.ex.TemplateResponseException
6-
import com.coder.gateway.sdk.ex.WorkspaceResourcesResponseException
76
import com.coder.gateway.sdk.ex.WorkspaceResponseException
87
import com.coder.gateway.sdk.v2.CoderV2RestFacade
98
import com.coder.gateway.sdk.v2.models.BuildInfo
109
import com.coder.gateway.sdk.v2.models.CreateWorkspaceBuildRequest
1110
import com.coder.gateway.sdk.v2.models.Template
1211
import com.coder.gateway.sdk.v2.models.User
1312
import com.coder.gateway.sdk.v2.models.Workspace
14-
import com.coder.gateway.sdk.v2.models.WorkspaceAgent
1513
import com.coder.gateway.sdk.v2.models.WorkspaceBuild
1614
import com.coder.gateway.sdk.v2.models.WorkspaceTransition
1715
import com.google.gson.Gson
@@ -91,21 +89,6 @@ class CoderRestClientService {
9189
return buildInfoResponse.body()!!
9290
}
9391

94-
/**
95-
* Retrieves the workspace agents a template declares.
96-
* A workspace is a collection of objects like, VMs, containers, cloud DBs, etc...Agents run on compute hosts like VMs or containers.
97-
*
98-
* @throws WorkspaceResourcesResponseException if workspace resources could not be retrieved.
99-
*/
100-
fun workspaceAgentsByTemplate(workspace: Workspace): List<WorkspaceAgent> {
101-
val workspaceResourcesResponse = retroRestClient.templateVersionResources(workspace.latestBuild.templateVersionID).execute()
102-
if (!workspaceResourcesResponse.isSuccessful) {
103-
throw WorkspaceResourcesResponseException("Could not retrieve agents for ${workspace.name} workspace :${workspaceResourcesResponse.code()}, reason: ${workspaceResourcesResponse.message()}")
104-
}
105-
106-
return workspaceResourcesResponse.body()!!.flatMap { it.agents ?: emptyList() }
107-
}
108-
10992
private fun template(templateID: UUID): Template {
11093
val templateResponse = retroRestClient.template(templateID).execute()
11194
if (!templateResponse.isSuccessful) {

src/main/kotlin/com/coder/gateway/sdk/TemplateIconDownloader.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ class TemplateIconDownloader {
1515
private val coderClient: CoderRestClientService = service()
1616
private val cache = mutableMapOf<Pair<String, String>, Icon>()
1717

18-
fun load(path: String, templateName: String): Icon {
18+
fun load(path: String, workspaceName: String): Icon {
1919
var url: URL? = null
2020
if (path.startsWith("http")) {
2121
url = path.toURL()
22-
} else if (path.contains(coderClient.coderURL.host)) {
22+
} else if (!path.contains(":") && !path.contains("//")) {
2323
url = coderClient.coderURL.withPath(path)
2424
}
2525

2626
if (url != null) {
27-
val cachedIcon = cache[Pair(templateName, path)]
27+
val cachedIcon = cache[Pair(workspaceName, path)]
2828
if (cachedIcon != null) {
2929
return cachedIcon
3030
}
3131
var img = ImageLoader.loadFromUrl(url)
3232
if (img != null) {
3333
val icon = IconUtil.toRetinaAwareIcon(Scalr.resize(ImageUtil.toBufferedImage(img), Scalr.Method.ULTRA_QUALITY, 32))
34-
cache[Pair(templateName, path)] = icon
34+
cache[Pair(workspaceName, path)] = icon
3535
return icon
3636
}
3737
}
3838

39-
return iconForChar(templateName.lowercase().first())
39+
return iconForChar(workspaceName.lowercase().first())
4040
}
4141

4242
private fun iconForChar(c: Char) = when (c) {

src/main/kotlin/com/coder/gateway/sdk/v2/CoderV2RestFacade.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.coder.gateway.sdk.v2.models.CreateWorkspaceBuildRequest
55
import com.coder.gateway.sdk.v2.models.Template
66
import com.coder.gateway.sdk.v2.models.User
77
import com.coder.gateway.sdk.v2.models.WorkspaceBuild
8-
import com.coder.gateway.sdk.v2.models.WorkspaceResource
98
import com.coder.gateway.sdk.v2.models.WorkspacesResponse
109
import retrofit2.Call
1110
import retrofit2.http.Body
@@ -32,9 +31,6 @@ interface CoderV2RestFacade {
3231
@GET("api/v2/buildinfo")
3332
fun buildInfo(): Call<BuildInfo>
3433

35-
@GET("api/v2/templateversions/{templateID}/resources")
36-
fun templateVersionResources(@Path("templateID") templateID: UUID): Call<List<WorkspaceResource>>
37-
3834
/**
3935
* Queues a new build to occur for a workspace.
4036
*/

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
118118
maxWidth = JBUI.scale(52)
119119
minWidth = JBUI.scale(52)
120120
}
121-
121+
rowHeight = 48
122122
setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
123123
selectionModel.addListSelectionListener {
124124
enableNextButtonCallback(selectedObject != null && selectedObject?.agentStatus == RUNNING && selectedObject?.agentOS == OS.LINUX)
@@ -523,7 +523,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
523523
null
524524
)
525525
cs.launch(Dispatchers.IO) {
526-
wm.templateIcon = iconDownloader.load(wm.templateIconPath, wm.templateName)
526+
wm.templateIcon = iconDownloader.load(wm.templateIconPath, wm.name)
527527
withContext(Dispatchers.Main) {
528528
tableOfWorkspaces.updateUI()
529529
}
@@ -550,7 +550,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
550550
agent.directory
551551
)
552552
cs.launch(Dispatchers.IO) {
553-
wm.templateIcon = iconDownloader.load(wm.templateIconPath, wm.templateName)
553+
wm.templateIcon = iconDownloader.load(wm.templateIconPath, wm.name)
554554
withContext(Dispatchers.Main) {
555555
tableOfWorkspaces.updateUI()
556556
}
@@ -575,7 +575,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
575575
null
576576
)
577577
cs.launch(Dispatchers.IO) {
578-
wm.templateIcon = iconDownloader.load(wm.templateIconPath, wm.templateName)
578+
wm.templateIcon = iconDownloader.load(wm.templateIconPath, wm.name)
579579
withContext(Dispatchers.Main) {
580580
tableOfWorkspaces.updateUI()
581581
}

0 commit comments

Comments
 (0)