Skip to content
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
Extract ready logic to WorkspaceAndAgentStatus
  • Loading branch information
code-asher committed Apr 26, 2023
commit a70a32bf0a4f299186c7c78190094ffd488b13d6
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
else -> if (JBColor.isBright()) JBColor.LIGHT_GRAY else JBColor.DARK_GRAY
}

/**
* Return true if the agent is in a connectable state.
*/
fun ready(): Boolean {
return listOf(READY, START_ERROR, AGENT_STARTING_READY, START_TIMEOUT_READY)
.contains(this)
}

// We want to check that the workspace is `running`, the agent is
// `connected`, and the agent lifecycle state is `ready` to ensure the best
// possible scenario for attempting a connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,8 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
setEmptyState("Disconnected")
setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
selectionModel.addListSelectionListener {
val ready = listOf(
WorkspaceAndAgentStatus.READY,
WorkspaceAndAgentStatus.START_ERROR,
WorkspaceAndAgentStatus.AGENT_STARTING_READY,
WorkspaceAndAgentStatus.START_TIMEOUT_READY,
).contains(selectedObject?.agentStatus)
setNextButtonEnabled(ready && selectedObject?.agentOS == OS.LINUX)
if (ready && selectedObject?.agentOS != OS.LINUX) {
setNextButtonEnabled(selectedObject?.agentStatus?.ready() == true && selectedObject?.agentOS == OS.LINUX)
if (selectedObject?.agentStatus?.ready() == true && selectedObject?.agentOS != OS.LINUX) {
notificationBanner.apply {
component.isVisible = true
showInfo(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.os.info"))
Expand Down