Skip to content

Commit 39e84d9

Browse files
committed
Format
1 parent b3f6b8c commit 39e84d9

File tree

5 files changed

+57
-44
lines changed

5 files changed

+57
-44
lines changed

site/src/components/Workspace/Workspace.stories.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ export const Error = Template.bind({})
3636
Error.args = { ...Started.args, workspaceStatus: "error" }
3737

3838
export const BuildLoading = Template.bind({})
39-
BuildLoading.args = {...Started.args, workspaceStatus: "loading" }
39+
BuildLoading.args = { ...Started.args, workspaceStatus: "loading" }
4040

4141
export const Deleting = Template.bind({})
42-
Deleting.args = {...Started.args, workspaceStatus: "deleting"}
42+
Deleting.args = { ...Started.args, workspaceStatus: "deleting" }
4343

4444
export const Deleted = Template.bind({})
45-
Deleted.args = {...Started.args, workspaceStatus: "deleted"}
45+
Deleted.args = { ...Started.args, workspaceStatus: "deleted" }
4646

4747
export const Canceling = Template.bind({})
48-
Canceling.args = {...Started.args, workspaceStatus: "canceling"}
48+
Canceling.args = { ...Started.args, workspaceStatus: "canceling" }
4949

5050
export const NoBreadcrumb = Template.bind({})
5151
NoBreadcrumb.args = { ...Started.args, template: undefined }

site/src/components/WorkspaceStatusBar/WorkspaceStatusBar.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { combineClasses } from "../../util/combineClasses"
1111
import { Stack } from "../Stack/Stack"
1212
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"
1313

14-
const Language = {
14+
export const Language = {
1515
stop: "Stop",
1616
start: "Start",
1717
retry: "Retry",
@@ -23,11 +23,11 @@ const Language = {
2323
stopping: "Stopping",
2424
error: "Build Failed",
2525
loading: "Loading Status",
26-
deleting: "Deleting",
26+
deleting: "Deleting",
2727
deleted: "Deleted",
28-
// "Canceling" would be misleading because it refers to a build, not the workspace.
28+
// "Canceling" would be misleading because it refers to a build, not the workspace.
2929
// So just stall. When it is canceled it will appear as the error workspaceStatus.
30-
canceling: "Loading Status"
30+
canceling: "Loading Status",
3131
}
3232

3333
export interface WorkspaceStatusBarProps {

site/src/pages/WorkspacePage/WorkspacePage.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ import { firstOrItem } from "../../util/array"
1010
import { XServiceContext } from "../../xServices/StateContext"
1111
import { selectWorkspaceStatus } from "../../xServices/workspace/workspaceSelectors"
1212

13-
export type WorkspaceStatus = "started" | "starting" | "stopped" | "stopping" | "error" | "loading" | "deleting" | "deleted" | "canceling"
13+
export type WorkspaceStatus =
14+
| "started"
15+
| "starting"
16+
| "stopped"
17+
| "stopping"
18+
| "error"
19+
| "loading"
20+
| "deleting"
21+
| "deleted"
22+
| "canceling"
1423

1524
export const WorkspacePage: React.FC = () => {
1625
const { workspace: workspaceQueryParam } = useParams()

site/src/xServices/workspace/workspaceSelectors.ts

+20-13
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@ import { WorkspaceStatus } from "../../pages/WorkspacePage/WorkspacePage"
44
import { WorkspaceContext, WorkspaceEvent } from "./workspaceXService"
55

66
const inProgressToStatus: Record<WorkspaceBuildTransition, Partial<WorkspaceStatus>> = {
7-
"start": "starting",
8-
"stop": "stopping",
9-
"delete": "deleting"
7+
start: "starting",
8+
stop: "stopping",
9+
delete: "deleting",
1010
}
1111

1212
const succeededToStatus: Record<WorkspaceBuildTransition, Partial<WorkspaceStatus>> = {
13-
"start": "started",
14-
"stop": "stopped",
15-
"delete": "deleted"
13+
start: "started",
14+
stop: "stopped",
15+
delete: "deleted",
1616
}
1717

1818
export const selectWorkspaceStatus = (state: State<WorkspaceContext, WorkspaceEvent>): WorkspaceStatus => {
1919
const transition = state.context.workspace?.latest_build.transition as WorkspaceBuildTransition
2020
const jobStatus = state.context.workspace?.latest_build.job.status
2121
switch (jobStatus) {
22-
case undefined: return "loading"
23-
case "succeeded": return succeededToStatus[transition]
24-
case "pending": return inProgressToStatus[transition]
25-
case "running": return inProgressToStatus[transition]
26-
case "canceling": return "canceling"
27-
case "canceled": return "error"
28-
case "failed": return "error"
22+
case undefined:
23+
return "loading"
24+
case "succeeded":
25+
return succeededToStatus[transition]
26+
case "pending":
27+
return inProgressToStatus[transition]
28+
case "running":
29+
return inProgressToStatus[transition]
30+
case "canceling":
31+
return "canceling"
32+
case "canceled":
33+
return "error"
34+
case "failed":
35+
return "error"
2936
}
3037
}

site/src/xServices/workspace/workspaceXService.ts

+19-22
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ export const workspaceMachine = createMachine(
9090
invoke: {
9191
id: "refreshWorkspace",
9292
src: "refreshWorkspace",
93-
onDone: { target: "waiting", actions: "assignWorkspace"},
93+
onDone: { target: "waiting", actions: "assignWorkspace" },
9494
onError: { target: "waiting", actions: "assignRefreshWorkspaceError" },
9595
},
9696
},
9797
waiting: {
9898
after: {
99-
1000: "refreshingWorkspace"
100-
}
101-
}
102-
}
99+
1000: "refreshingWorkspace",
100+
},
101+
},
102+
},
103103
},
104104
breadcrumb: {
105105
initial: "gettingTemplate",
@@ -145,10 +145,7 @@ export const workspaceMachine = createMachine(
145145
on: {
146146
START: "requestingStart",
147147
STOP: "requestingStop",
148-
RETRY: [
149-
{ cond: "triedToStart", target: "requestingStart" },
150-
{ target: "requestingStop" }
151-
],
148+
RETRY: [{ cond: "triedToStart", target: "requestingStart" }, { target: "requestingStop" }],
152149
UPDATE: "refreshingTemplate",
153150
},
154151
},
@@ -159,13 +156,13 @@ export const workspaceMachine = createMachine(
159156
src: "startWorkspace",
160157
onDone: {
161158
target: "idle",
162-
actions: "assignBuild"
159+
actions: "assignBuild",
163160
},
164161
onError: {
165162
target: "idle",
166-
actions: "assignBuildError"
167-
}
168-
}
163+
actions: "assignBuildError",
164+
},
165+
},
169166
},
170167
requestingStop: {
171168
entry: "clearBuildError",
@@ -174,13 +171,13 @@ export const workspaceMachine = createMachine(
174171
src: "stopWorkspace",
175172
onDone: {
176173
target: "idle",
177-
actions: "assignBuild"
174+
actions: "assignBuild",
178175
},
179176
onError: {
180177
target: "idle",
181-
actions: "assignBuildError"
182-
}
183-
}
178+
actions: "assignBuildError",
179+
},
180+
},
184181
},
185182
refreshingTemplate: {
186183
entry: "clearRefreshTemplateError",
@@ -189,15 +186,15 @@ export const workspaceMachine = createMachine(
189186
src: "getTemplate",
190187
onDone: {
191188
target: "requestingStart",
192-
actions: "assignTemplate"
189+
actions: "assignTemplate",
193190
},
194191
onError: {
195192
target: "idle",
196-
actions: "assignRefreshTemplateError"
197-
}
198-
}
193+
actions: "assignRefreshTemplateError",
194+
},
195+
},
199196
},
200-
}
197+
},
201198
},
202199
},
203200
},

0 commit comments

Comments
 (0)