Skip to content

Add status and start/stop buttons to recents view #243

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 9 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Store name in recent connection
So we can match against the API response.  We could split the hostname
on `--` but there are cases where that will fail (when the name or
domain itself contains -- in specific configurations).

We have to add the config path anyway so this is the best opportunity to
add more information.
  • Loading branch information
code-asher committed May 5, 2023
commit 04796e81f5ed0d084eab0853904fd9e0493fb657
17 changes: 14 additions & 3 deletions src/main/kotlin/com/coder/gateway/WorkspaceParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private const val IDE_BUILD_NUMBER = "ide_build_number"
private const val IDE_PATH_ON_HOST = "ide_path_on_host"
private const val WEB_TERMINAL_LINK = "web_terminal_link"
private const val CONFIG_DIRECTORY = "config_directory"
private const val NAME = "name"

private val localTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm")

Expand All @@ -35,7 +36,8 @@ fun RecentWorkspaceConnection.toWorkspaceParams(): Map<String, String> {
IDE_PRODUCT_CODE to IntelliJPlatformProduct.fromProductCode(this.ideProductCode!!)!!.productCode,
IDE_BUILD_NUMBER to "${this.ideBuildNumber}",
WEB_TERMINAL_LINK to "${this.webTerminalLink}",
CONFIG_DIRECTORY to "${this.configDirectory}"
CONFIG_DIRECTORY to "${this.configDirectory}",
NAME to "${this.name}"
)

if (!this.downloadSource.isNullOrBlank()) {
Expand Down Expand Up @@ -88,6 +90,13 @@ fun Map<String, String>.withConfigDirectory(dir: String): Map<String, String> {
return map
}

fun Map<String, String>.withName(name: String): Map<String, String> {
val map = this.toMutableMap()
map[NAME] = name
return map
}


fun Map<String, String>.areCoderType(): Boolean {
return this[TYPE] == VALUE_FOR_TYPE && !this[CODER_WORKSPACE_HOSTNAME].isNullOrBlank() && !this[PROJECT_PATH].isNullOrBlank()
}
Expand Down Expand Up @@ -149,7 +158,8 @@ fun Map<String, String>.toRecentWorkspaceConnection(): RecentWorkspaceConnection
this[IDE_DOWNLOAD_LINK]!!,
null,
this[WEB_TERMINAL_LINK]!!,
this[CONFIG_DIRECTORY]!!
this[CONFIG_DIRECTORY]!!,
this[NAME]!!,
) else RecentWorkspaceConnection(
this.workspaceHostname(),
this.projectPath(),
Expand All @@ -159,6 +169,7 @@ fun Map<String, String>.toRecentWorkspaceConnection(): RecentWorkspaceConnection
null,
this[IDE_PATH_ON_HOST],
this[WEB_TERMINAL_LINK]!!,
this[CONFIG_DIRECTORY]!!
this[CONFIG_DIRECTORY]!!,
this[NAME]!!,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.intellij.openapi.components.BaseState
import com.intellij.util.xmlb.annotations.Attribute

class RecentWorkspaceConnection() : BaseState(), Comparable<RecentWorkspaceConnection> {
constructor(hostname: String, prjPath: String, openedAt: String, productCode: String, buildNumber: String, source: String?, idePath: String?, terminalLink: String, config: String) : this() {
constructor(hostname: String, prjPath: String, openedAt: String, productCode: String, buildNumber: String, source: String?, idePath: String?, terminalLink: String, config: String, name: String) : this() {
coderWorkspaceHostname = hostname
projectPath = prjPath
lastOpened = openedAt
Expand All @@ -14,6 +14,7 @@ class RecentWorkspaceConnection() : BaseState(), Comparable<RecentWorkspaceConne
idePathOnHost = idePath
webTerminalLink = terminalLink
configDirectory = config
this.name = name
}

@get:Attribute
Expand Down Expand Up @@ -44,6 +45,9 @@ class RecentWorkspaceConnection() : BaseState(), Comparable<RecentWorkspaceConne
@get:Attribute
var configDirectory by string()

@get:Attribute
var name by string()

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.coder.gateway.sdk.withPath
import com.coder.gateway.toWorkspaceParams
import com.coder.gateway.views.LazyBrowserLink
import com.coder.gateway.withConfigDirectory
import com.coder.gateway.withName
import com.coder.gateway.withProjectPath
import com.coder.gateway.withWebTerminalLink
import com.coder.gateway.withWorkspaceHostname
Expand Down Expand Up @@ -184,7 +185,7 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
try {
val ides = suspendingRetryWithExponentialBackOff(
action = { attempt ->
logger.info("Retrieving IDEs...(attempt $attempt)")
logger.info("Retrieving IDEs... (attempt $attempt)")
if (attempt > 1) {
cbIDE.renderer = IDECellRenderer(CoderGatewayBundle.message("gateway.connector.view.coder.retrieve.ides.retry", attempt))
}
Expand Down Expand Up @@ -336,6 +337,7 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
.withProjectPath(tfProject.text)
.withWebTerminalLink("${terminalLink.url}")
.withConfigDirectory(wizardModel.configDirectory)
.withName(selectedWorkspace.name)
)
}
return true
Expand Down