Skip to content

Commit fb407cd

Browse files
committed
Split agent status icon and label
So we can show just the icon in the recent connections view.
1 parent 5b9fdcb commit fb407cd

File tree

6 files changed

+54
-31
lines changed

6 files changed

+54
-31
lines changed

src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ object CoderIcons {
88

99
val OPEN_TERMINAL = IconLoader.getIcon("open_terminal.svg", javaClass)
1010

11+
val PENDING = IconLoader.getIcon("pending.svg", javaClass)
12+
val RUNNING = IconLoader.getIcon("running.svg", javaClass)
13+
val OFF = IconLoader.getIcon("off.svg", javaClass)
14+
1115
val HOME = IconLoader.getIcon("homeFolder.svg", javaClass)
1216
val CREATE = IconLoader.getIcon("create.svg", javaClass)
1317
val RUN = IconLoader.getIcon("run.svg", javaClass)
@@ -55,4 +59,4 @@ object CoderIcons {
5559
val Y = IconLoader.getIcon("y.svg", javaClass)
5660
val Z = IconLoader.getIcon("z.svg", javaClass)
5761

58-
}
62+
}

src/main/kotlin/com/coder/gateway/models/WorkspaceAndAgentStatus.kt

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
11
package com.coder.gateway.models
22

3+
import com.coder.gateway.icons.CoderIcons
34
import com.coder.gateway.sdk.v2.models.Workspace
45
import com.coder.gateway.sdk.v2.models.WorkspaceAgent
56
import com.coder.gateway.sdk.v2.models.WorkspaceAgentLifecycleState
67
import com.coder.gateway.sdk.v2.models.WorkspaceAgentStatus
78
import com.coder.gateway.sdk.v2.models.WorkspaceStatus
89
import com.intellij.ui.JBColor
10+
import javax.swing.Icon
911

1012
/**
1113
* WorkspaceAndAgentStatus represents the combined status of a single agent and
1214
* its workspace (or just the workspace if there are no agents).
1315
*/
14-
enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
16+
enum class WorkspaceAndAgentStatus(val icon: Icon, val label: String, val description: String) {
1517
// Workspace states.
16-
QUEUED("Queued", "The workspace is queueing to start."),
17-
STARTING("⦿ Starting", "The workspace is starting."),
18-
FAILED("Failed", "The workspace has failed to start."),
19-
DELETING("Deleting", "The workspace is being deleted."),
20-
DELETED("Deleted", "The workspace has been deleted."),
21-
STOPPING("Stopping", "The workspace is stopping."),
22-
STOPPED("Stopped", "The workspace has stopped."),
23-
CANCELING("Canceling action", "The workspace is being canceled."),
24-
CANCELED("Canceled action", "The workspace has been canceled."),
25-
RUNNING("⦿ Running", "The workspace is running, waiting for agents."),
18+
QUEUED(CoderIcons.PENDING, "Queued", "The workspace is queueing to start."),
19+
STARTING(CoderIcons.PENDING, "Starting", "The workspace is starting."),
20+
FAILED(CoderIcons.OFF, "Failed", "The workspace has failed to start."),
21+
DELETING(CoderIcons.PENDING, "Deleting", "The workspace is being deleted."),
22+
DELETED(CoderIcons.OFF, "Deleted", "The workspace has been deleted."),
23+
STOPPING(CoderIcons.PENDING, "Stopping", "The workspace is stopping."),
24+
STOPPED(CoderIcons.OFF, "Stopped", "The workspace has stopped."),
25+
CANCELING(CoderIcons.PENDING, "Canceling action", "The workspace is being canceled."),
26+
CANCELED(CoderIcons.OFF, "Canceled action", "The workspace has been canceled."),
27+
RUNNING(CoderIcons.RUN, "Running", "The workspace is running, waiting for agents."),
2628

2729
// Agent states.
28-
CONNECTING("⦿ Connecting", "The agent is connecting."),
29-
DISCONNECTED("Disconnected", "The agent has disconnected."),
30-
TIMEOUT("Timeout", "The agent is taking longer than expected to connect."),
31-
AGENT_STARTING("⦿ Starting", "The startup script is running."),
32-
AGENT_STARTING_READY("⦿ Starting", "The startup script is still running but the agent is ready to accept connections."),
33-
CREATED("⦿ Created", "The agent has been created."),
34-
START_ERROR("Started with error", "The agent is ready but the startup script errored."),
35-
START_TIMEOUT("Starting", "The startup script is taking longer than expected."),
36-
START_TIMEOUT_READY("Starting", "The startup script is taking longer than expected but the agent is ready to accept connections."),
37-
SHUTTING_DOWN("Shutting down", "The agent is shutting down."),
38-
SHUTDOWN_ERROR("Shutdown with error", "The agent shut down but the shutdown script errored."),
39-
SHUTDOWN_TIMEOUT("Shutting down", "The shutdown script is taking longer than expected."),
40-
OFF("Off", "The agent has shut down."),
41-
READY("⦿ Ready", "The agent is ready to accept connections.");
30+
CONNECTING(CoderIcons.PENDING, "Connecting", "The agent is connecting."),
31+
DISCONNECTED(CoderIcons.OFF, "Disconnected", "The agent has disconnected."),
32+
TIMEOUT(CoderIcons.PENDING, "Timeout", "The agent is taking longer than expected to connect."),
33+
AGENT_STARTING(CoderIcons.PENDING, "Starting", "The startup script is running."),
34+
AGENT_STARTING_READY(CoderIcons.RUNNING, "Starting", "The startup script is still running but the agent is ready to accept connections."),
35+
CREATED(CoderIcons.PENDING, "Created", "The agent has been created."),
36+
START_ERROR(CoderIcons.RUNNING, "Started with error", "The agent is ready but the startup script errored."),
37+
START_TIMEOUT(CoderIcons.PENDING, "Starting", "The startup script is taking longer than expected."),
38+
START_TIMEOUT_READY(CoderIcons.RUNNING, "Starting", "The startup script is taking longer than expected but the agent is ready to accept connections."),
39+
SHUTTING_DOWN(CoderIcons.PENDING, "Shutting down", "The agent is shutting down."),
40+
SHUTDOWN_ERROR(CoderIcons.OFF, "Shutdown with error", "The agent shut down but the shutdown script errored."),
41+
SHUTDOWN_TIMEOUT(CoderIcons.OFF, "Shutting down", "The shutdown script is taking longer than expected."),
42+
OFF(CoderIcons.OFF, "Off", "The agent has shut down."),
43+
READY(CoderIcons.RUNNING, "Ready", "The agent is ready to accept connections.");
4244

4345
fun statusColor(): JBColor = when (this) {
4446
READY, AGENT_STARTING_READY, START_TIMEOUT_READY -> JBColor.GREEN
@@ -100,7 +102,5 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
100102
WorkspaceStatus.DELETING -> DELETING
101103
WorkspaceStatus.DELETED -> DELETED
102104
}
103-
104-
fun from(str: String) = WorkspaceAndAgentStatus.values().first { it.label.contains(str, true) }
105105
}
106106
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.coder.gateway.icons.CoderIcons
55
import com.coder.gateway.models.CoderWorkspacesWizardModel
66
import com.coder.gateway.models.TokenSource
77
import com.coder.gateway.models.WorkspaceAgentModel
8-
import com.coder.gateway.models.WorkspaceAndAgentStatus
98
import com.coder.gateway.models.WorkspaceVersionStatus
109
import com.coder.gateway.sdk.CoderCLIManager
1110
import com.coder.gateway.sdk.CoderRestClientService
@@ -860,12 +859,13 @@ class WorkspacesTableModel : ListTableModel<WorkspaceAgentModel>(
860859

861860
override fun getRenderer(item: WorkspaceAgentModel?): TableCellRenderer {
862861
return object : DefaultTableCellRenderer() {
862+
private val workspace = item
863863
override fun getTableCellRendererComponent(table: JTable, value: Any, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int): Component {
864864
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column)
865865
if (value is String) {
866866
text = value
867-
foreground = WorkspaceAndAgentStatus.from(value).statusColor()
868-
toolTipText = WorkspaceAndAgentStatus.from(value).description
867+
foreground = workspace?.agentStatus?.statusColor()
868+
toolTipText = workspace?.agentStatus?.description
869869
}
870870
font = table.tableHeader.font
871871
border = JBUI.Borders.empty(0, 8)

src/main/resources/off.svg

Lines changed: 6 additions & 0 deletions
Loading

src/main/resources/pending.svg

Lines changed: 7 additions & 0 deletions
Loading

src/main/resources/running.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)