Skip to content

Commit 3285347

Browse files
committed
impl: support for Update and restart action
- when workspace is running and is outdated - resolves #33
1 parent 5544641 commit 3285347

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt

+24-16
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,33 @@ class CoderRemoteEnvironment(
6969
}
7070
}
7171
})
72-
if (wsRawStatus.canStart() && !workspace.outdated) {
73-
actions.add(Action(context.i18n.ptrl("Start")) {
74-
val build = client.startWorkspace(workspace)
75-
update(workspace.copy(latestBuild = build), agent)
76-
})
72+
73+
if (wsRawStatus.canStart()) {
74+
if (workspace.outdated) {
75+
actions.add(Action(context.i18n.ptrl("Update and start")) {
76+
val build = client.updateWorkspace(workspace)
77+
update(workspace.copy(latestBuild = build), agent)
78+
})
79+
} else {
80+
actions.add(Action(context.i18n.ptrl("Start")) {
81+
val build = client.startWorkspace(workspace)
82+
update(workspace.copy(latestBuild = build), agent)
83+
})
84+
}
7785
}
7886
if (wsRawStatus.canStop()) {
79-
actions.add(Action(context.i18n.ptrl("Stop")) {
80-
val build = client.stopWorkspace(workspace)
81-
update(workspace.copy(latestBuild = build), agent)
82-
})
83-
}
84-
if (workspace.outdated) {
85-
actions.add(Action(context.i18n.ptrl("Update and start")) {
86-
val build = client.updateWorkspace(workspace)
87-
update(workspace.copy(latestBuild = build), agent)
88-
})
87+
if (workspace.outdated) {
88+
actions.add(Action(context.i18n.ptrl("Update and restart")) {
89+
val build = client.updateWorkspace(workspace)
90+
update(workspace.copy(latestBuild = build), agent)
91+
})
92+
} else {
93+
actions.add(Action(context.i18n.ptrl("Stop")) {
94+
val build = client.stopWorkspace(workspace)
95+
update(workspace.copy(latestBuild = build), agent)
96+
})
97+
}
8998
}
90-
9199
return actions
92100
}
93101

src/main/resources/localization/defaultMessages.po

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ msgstr ""
7676
msgid "Update and start"
7777
msgstr ""
7878

79+
msgid "Update and restart"
80+
msgstr ""
81+
7982
msgid "Settings"
8083
msgstr ""
8184

0 commit comments

Comments
 (0)