|
1 | 1 | package com.coder.gateway.models
|
2 | 2 |
|
| 3 | +import com.coder.gateway.icons.CoderIcons |
3 | 4 | import com.coder.gateway.sdk.v2.models.Workspace
|
4 | 5 | import com.coder.gateway.sdk.v2.models.WorkspaceAgent
|
5 | 6 | import com.coder.gateway.sdk.v2.models.WorkspaceAgentLifecycleState
|
6 | 7 | import com.coder.gateway.sdk.v2.models.WorkspaceAgentStatus
|
7 | 8 | import com.coder.gateway.sdk.v2.models.WorkspaceStatus
|
8 | 9 | import com.intellij.ui.JBColor
|
| 10 | +import javax.swing.Icon |
9 | 11 |
|
10 | 12 | /**
|
11 | 13 | * WorkspaceAndAgentStatus represents the combined status of a single agent and
|
12 | 14 | * its workspace (or just the workspace if there are no agents).
|
13 | 15 | */
|
14 |
| -enum class WorkspaceAndAgentStatus(val label: String, val description: String) { |
| 16 | +enum class WorkspaceAndAgentStatus(val icon: Icon, val label: String, val description: String) { |
15 | 17 | // 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."), |
26 | 28 |
|
27 | 29 | // 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."); |
42 | 44 |
|
43 | 45 | fun statusColor(): JBColor = when (this) {
|
44 | 46 | READY, AGENT_STARTING_READY, START_TIMEOUT_READY -> JBColor.GREEN
|
@@ -100,7 +102,5 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
|
100 | 102 | WorkspaceStatus.DELETING -> DELETING
|
101 | 103 | WorkspaceStatus.DELETED -> DELETED
|
102 | 104 | }
|
103 |
| - |
104 |
| - fun from(str: String) = WorkspaceAndAgentStatus.values().first { it.label.contains(str, true) } |
105 | 105 | }
|
106 | 106 | }
|
0 commit comments