@@ -45,44 +45,54 @@ class CoderRemoteEnvironment(
45
45
46
46
override val actionsList: MutableStateFlow <List <ActionDescription >> = MutableStateFlow (getAvailableActions())
47
47
48
- private fun getAvailableActions (): List <ActionDescription > = listOf (
49
- Action (context.i18n.ptrl(" Open web terminal" )) {
50
- context.cs.launch {
51
- BrowserUtil .browse(client.url.withPath(" /${workspace.ownerName} /$name /terminal" ).toString()) {
52
- context.ui.showErrorInfoPopup(it)
48
+ private fun getAvailableActions (): List <ActionDescription > {
49
+ val actions = mutableListOf (
50
+ Action (context.i18n.ptrl(" Open web terminal" )) {
51
+ context.cs.launch {
52
+ BrowserUtil .browse(client.url.withPath(" /${workspace.ownerName} /$name /terminal" ).toString()) {
53
+ context.ui.showErrorInfoPopup(it)
54
+ }
53
55
}
54
- }
55
- },
56
- Action ( context.i18n.ptrl( " Open in dashboard " )) {
57
- context.cs.launch {
58
- BrowserUtil .browse(client.url.withPath( " /@ ${workspace.ownerName} / ${workspace.name} " ).toString()) {
59
- context.ui.showErrorInfoPopup(it)
56
+ },
57
+ Action (context.i18n.ptrl( " Open in dashboard " )) {
58
+ context.cs.launch {
59
+ BrowserUtil .browse(client.url.withPath( " /@ ${workspace.ownerName} / ${workspace.name} " ).toString()) {
60
+ context.ui.showErrorInfoPopup(it)
61
+ }
60
62
}
61
- }
62
- },
63
+ },
63
64
64
- Action (context.i18n.ptrl(" View template" )) {
65
- context.cs.launch {
66
- BrowserUtil .browse(client.url.withPath(" /templates/${workspace.templateName} " ).toString()) {
67
- context.ui.showErrorInfoPopup(it)
65
+ Action (context.i18n.ptrl(" View template" )) {
66
+ context.cs.launch {
67
+ BrowserUtil .browse(client.url.withPath(" /templates/${workspace.templateName} " ).toString()) {
68
+ context.ui.showErrorInfoPopup(it)
69
+ }
68
70
}
69
- }
70
- },
71
- Action (context.i18n.ptrl(" Start" ), enabled = { wsRawStatus.canStart() && ! workspace.outdated }) {
72
- val build = client.startWorkspace(workspace)
73
- workspace = workspace.copy(latestBuild = build)
74
- update(workspace, agent)
75
- },
76
- Action (context.i18n.ptrl(" Stop" ), enabled = { wsRawStatus.canStop() }) {
77
- val build = client.stopWorkspace(workspace)
78
- workspace = workspace.copy(latestBuild = build)
79
- update(workspace, agent)
80
- },
81
- Action (context.i18n.ptrl(" Update and start" ), enabled = { workspace.outdated }) {
82
- val build = client.updateWorkspace(workspace)
83
- workspace = workspace.copy(latestBuild = build)
84
- update(workspace, agent)
85
- })
71
+ })
72
+ if (wsRawStatus.canStart() && ! workspace.outdated) {
73
+ actions.add(Action (context.i18n.ptrl(" Start" )) {
74
+ val build = client.startWorkspace(workspace)
75
+ workspace = workspace.copy(latestBuild = build)
76
+ update(workspace, agent)
77
+ })
78
+ }
79
+ if (wsRawStatus.canStop()) {
80
+ actions.add(Action (context.i18n.ptrl(" Stop" )) {
81
+ val build = client.stopWorkspace(workspace)
82
+ workspace = workspace.copy(latestBuild = build)
83
+ update(workspace, agent)
84
+ })
85
+ }
86
+ if (workspace.outdated) {
87
+ actions.add(Action (context.i18n.ptrl(" Update and start" )) {
88
+ val build = client.updateWorkspace(workspace)
89
+ workspace = workspace.copy(latestBuild = build)
90
+ update(workspace, agent)
91
+ })
92
+ }
93
+
94
+ return actions
95
+ }
86
96
87
97
/* *
88
98
* Update the workspace/agent status to the listeners, if it has changed.
0 commit comments