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
Add tooltips to describe the status
  • Loading branch information
code-asher committed Apr 25, 2023
commit 176d868c3df4397744ca893bc1092d34d06348a7
35 changes: 24 additions & 11 deletions src/main/kotlin/com/coder/gateway/models/WorkspaceAndAgentStatus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,33 @@ import com.intellij.ui.JBColor
* WorkspaceAndAgentStatus represents the combined status of a single agent and
* its workspace (or just the workspace if there are no agents).
*/
enum class WorkspaceAndAgentStatus(val label: String) {
enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something feels a bit off to me about this, like maybe we should just have the workspace status and agent status and check both whenever we need to rather than have this computed state but my thoughts about it are a bit fuzzy and we already had it architectured like this so I left it for now.

// Workspace states.
QUEUED("◍ Queued"), STARTING("⦿ Starting"), FAILED("ⓧ Failed"),
DELETING("⦸ Deleting"), DELETED("⦸ Deleted"),
STOPPING("◍ Stopping"), STOPPED("◍ Stopped"),
CANCELING("◍ Canceling action"), CANCELED("◍ Canceled action"),
RUNNING("⦿ Running"),
QUEUED("◍ Queued", "The workspace is queueing to start."),
STARTING("⦿ Starting", "The workspace is starting."),
FAILED("ⓧ Failed", "The workspace has failed to start."),
DELETING("⦸ Deleting", "The workspace is being deleted."),
DELETED("⦸ Deleted", "The workspace has been deleted."),
STOPPING("◍ Stopping", "The workspace is stopping."),
STOPPED("◍ Stopped", "The workspace has stopped."),
CANCELING("◍ Canceling action", "The workspace is being canceled."),
CANCELED("◍ Canceled action", "The workspace has been canceled."),
RUNNING("⦿ Running", "The workspace is running, waiting for agents."),

// Agent states.
OFF("⦸ Off"), CONNECTING("⦿ Connecting"), DISCONNECTED("⦸ Disconnected"), TIMEOUT("ⓧ Timeout"),
AGENT_STARTING("⦿ Starting"), AGENT_STARTING_READY("⦿ Starting"),
CREATED("⦿ Created"), START_ERROR("◍ Started with error"), START_TIMEOUT("◍ Started with timeout"),
SHUTTING_DOWN("◍ Shutting down"), SHUTDOWN_ERROR("⦸ Shutdown with error"), SHUTDOWN_TIMEOUT("⦸ Shutdown with timeout"),
READY("⦿ Ready");
CONNECTING("⦿ Connecting", "The agent is connecting."),
DISCONNECTED("⦸ Disconnected", "The agent has disconnected."),
TIMEOUT("ⓧ Timeout", "The agent has timed out."),
AGENT_STARTING("⦿ Starting", "The agent is running the startup script."),
AGENT_STARTING_READY("⦿ Starting", "The agent is running the startup script but is ready to accept connections."),
CREATED("⦿ Created", "The agent has been created."),
START_ERROR("◍ Started with error", "The agent is ready but the startup script errored."),
START_TIMEOUT("◍ Started with timeout", "The agent is ready but the startup script timed out"),
SHUTTING_DOWN("◍ Shutting down", "The agent is shutting down."),
SHUTDOWN_ERROR("⦸ Shutdown with error", "The agent shut down but the shutdown script errored."),
SHUTDOWN_TIMEOUT("⦸ Shutdown with timeout", "The agent shut down but the shutdown script timed out."),
OFF("⦸ Off", "The agent has shut down."),
READY("⦿ Ready", "The agent is ready to accept connections.");

fun statusColor(): JBColor = when (this) {
READY, AGENT_STARTING_READY -> JBColor.GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,11 +906,19 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod

override fun getRenderer(item: WorkspaceAgentModel?): TableCellRenderer {
return object : DefaultTableCellRenderer() {
override fun getTableCellRendererComponent(table: JTable, value: Any, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int): Component {
override fun getTableCellRendererComponent(
table: JTable,
value: Any,
isSelected: Boolean,
hasFocus: Boolean,
row: Int,
column: Int,
): Component {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column)
if (value is String) {
text = value
foreground = WorkspaceAndAgentStatus.from(value).statusColor()
toolTipText = WorkspaceAndAgentStatus.from(value).description
}
font = this@CoderWorkspacesStepView.tableOfWorkspaces.tableHeader.font
border = JBUI.Borders.empty(0, 8)
Expand Down