@@ -5,10 +5,11 @@ import com.coder.toolbox.sdk.v2.models.WorkspaceAgent
5
5
import com.coder.toolbox.sdk.v2.models.WorkspaceAgentLifecycleState
6
6
import com.coder.toolbox.sdk.v2.models.WorkspaceAgentStatus
7
7
import com.coder.toolbox.sdk.v2.models.WorkspaceStatus
8
- import com.jetbrains.toolbox.api.core.ui.color.Color
8
+ import com.jetbrains.toolbox.api.core.ServiceLocator
9
9
import com.jetbrains.toolbox.api.core.ui.color.StateColor
10
- import com.jetbrains.toolbox.api.core.ui.color.ThemeColor
11
10
import com.jetbrains.toolbox.api.remoteDev.states.CustomRemoteEnvironmentState
11
+ import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentStateColorPalette
12
+ import com.jetbrains.toolbox.api.remoteDev.states.StandardRemoteEnvironmentState
12
13
13
14
/* *
14
15
* WorkspaceAndAgentStatus represents the combined status of a single agent and
@@ -57,27 +58,27 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
57
58
* Note that a reachable environment will always display "connected" or
58
59
* "disconnected" regardless of the label we give that status.
59
60
*/
60
- fun toRemoteEnvironmentState (): CustomRemoteEnvironmentState {
61
- // Use comments; no named arguments for non-Kotlin functions.
62
- // TODO@JB: Is there a set of default colors we could use?
61
+ fun toRemoteEnvironmentState (serviceLocator : ServiceLocator ): CustomRemoteEnvironmentState {
62
+ val stateColor = getStateColor(serviceLocator)
63
63
return CustomRemoteEnvironmentState (
64
64
label,
65
- StateColor (
66
- ThemeColor (
67
- Color (0.407f , 0.439f , 0.502f , 1.0f ), // lightThemeColor
68
- Color (0.784f , 0.784f , 0.784f , 0.784f ), // darkThemeColor
69
- ),
70
- ThemeColor (
71
- Color (0.878f , 0.878f , 0.941f , 0.102f ), // darkThemeBackgroundColor
72
- Color (0.878f , 0.878f , 0.961f , 0.980f ), // lightThemeBackgroundColor
73
- )
74
- ),
65
+ stateColor,
75
66
ready(), // reachable
76
67
// TODO@JB: How does this work? Would like a spinner for pending states.
77
68
null , // iconId
78
69
)
79
70
}
80
71
72
+ private fun getStateColor (serviceLocator : ServiceLocator ): StateColor {
73
+ val colorPalette = serviceLocator.getService(EnvironmentStateColorPalette ::class .java)
74
+
75
+
76
+ return if (ready()) colorPalette.getColor(StandardRemoteEnvironmentState .Active )
77
+ else if (canStart()) colorPalette.getColor(StandardRemoteEnvironmentState .Failed )
78
+ else if (pending()) colorPalette.getColor(StandardRemoteEnvironmentState .Activating )
79
+ else colorPalette.getColor(StandardRemoteEnvironmentState .Unreachable )
80
+ }
81
+
81
82
/* *
82
83
* Return true if the agent is in a connectable state.
83
84
*/
0 commit comments