@@ -29,11 +29,13 @@ import { BuildsTable } from "./BuildsTable";
29
29
import { WorkspaceDeletedBanner } from "./WorkspaceDeletedBanner" ;
30
30
import { WorkspaceStats } from "./WorkspaceStats" ;
31
31
32
- export enum WorkspaceErrors {
33
- GET_BUILDS_ERROR = "getBuildsError" ,
34
- BUILD_ERROR = "buildError" ,
35
- CANCELLATION_ERROR = "cancellationError" ,
36
- }
32
+ export type WorkspaceError =
33
+ | "getBuildsError"
34
+ | "buildError"
35
+ | "cancellationError" ;
36
+
37
+ export type WorkspaceErrors = Partial < Record < WorkspaceError , unknown > > ;
38
+
37
39
export interface WorkspaceProps {
38
40
scheduleProps : {
39
41
onDeadlinePlus : ( hours : number ) => void ;
@@ -56,16 +58,17 @@ export interface WorkspaceProps {
56
58
resources ?: TypesGen . WorkspaceResource [ ] ;
57
59
canUpdateWorkspace : boolean ;
58
60
updateMessage ?: string ;
59
- canRetryDebugMode : boolean ;
60
61
canChangeVersions : boolean ;
61
62
hideSSHButton ?: boolean ;
62
63
hideVSCodeDesktopButton ?: boolean ;
63
- workspaceErrors : Partial < Record < WorkspaceErrors , unknown > > ;
64
+ workspaceErrors : WorkspaceErrors ;
64
65
buildInfo ?: TypesGen . BuildInfoResponse ;
65
66
sshPrefix ?: string ;
66
67
template ?: TypesGen . Template ;
67
68
quotaBudget ?: number ;
69
+ canRetryDebugMode : boolean ;
68
70
handleBuildRetry : ( ) => void ;
71
+ handleBuildRetryDebug : ( ) => void ;
69
72
buildLogs ?: React . ReactNode ;
70
73
builds : TypesGen . WorkspaceBuild [ ] | undefined ;
71
74
onLoadMoreBuilds : ( ) => void ;
@@ -87,55 +90,39 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
87
90
handleCancel,
88
91
handleSettings,
89
92
handleChangeVersion,
90
- handleDormantActivate : handleDormantActivate ,
93
+ handleDormantActivate,
91
94
workspace,
92
95
isUpdating,
93
96
isRestarting,
94
97
resources,
95
98
builds,
96
99
canUpdateWorkspace,
97
100
updateMessage,
98
- canRetryDebugMode,
99
101
canChangeVersions,
100
102
workspaceErrors,
101
103
hideSSHButton,
102
104
hideVSCodeDesktopButton,
103
105
buildInfo,
104
106
sshPrefix,
105
107
template,
108
+ canRetryDebugMode,
106
109
handleBuildRetry,
110
+ handleBuildRetryDebug,
107
111
buildLogs,
108
112
onLoadMoreBuilds,
109
113
isLoadingMoreBuilds,
110
114
hasMoreBuilds,
111
115
canAutostart,
112
116
} ) => {
113
117
const navigate = useNavigate ( ) ;
114
- const serverVersion = buildInfo ?. version || "" ;
115
118
const { saveLocal, getLocal } = useLocalStorage ( ) ;
116
119
117
- const buildError = Boolean ( workspaceErrors [ WorkspaceErrors . BUILD_ERROR ] ) && (
118
- < ErrorAlert
119
- error = { workspaceErrors [ WorkspaceErrors . BUILD_ERROR ] }
120
- dismissible
121
- />
122
- ) ;
123
-
124
- const cancellationError = Boolean (
125
- workspaceErrors [ WorkspaceErrors . CANCELLATION_ERROR ] ,
126
- ) && (
127
- < ErrorAlert
128
- error = { workspaceErrors [ WorkspaceErrors . CANCELLATION_ERROR ] }
129
- dismissible
130
- />
131
- ) ;
132
-
133
- let transitionStats : TypesGen . TransitionStats | undefined = undefined ;
134
- if ( template !== undefined ) {
135
- transitionStats = ActiveTransition ( template , workspace ) ;
136
- }
137
-
138
120
const [ showAlertPendingInQueue , setShowAlertPendingInQueue ] = useState ( false ) ;
121
+
122
+ // 2023-11-15 - MES - This effect will be called every single render because
123
+ // "now" will always change and invalidate the dependency array. Need to
124
+ // figure out if this effect really should run every render (possibly meaning
125
+ // no dependency array at all), or how to get the array stabilized (ideal)
139
126
const now = dayjs ( ) ;
140
127
useEffect ( ( ) => {
141
128
if (
@@ -174,6 +161,9 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
174
161
const autoStartFailing = workspace . autostart_schedule && ! canAutostart ;
175
162
const requiresManualUpdate = updateRequired && autoStartFailing ;
176
163
164
+ const transitionStats =
165
+ template !== undefined ? ActiveTransition ( template , workspace ) : undefined ;
166
+
177
167
return (
178
168
< >
179
169
< FullWidthPageHeader >
@@ -213,8 +203,11 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
213
203
handleUpdate = { handleUpdate }
214
204
handleCancel = { handleCancel }
215
205
handleSettings = { handleSettings }
206
+ handleRetry = { handleBuildRetry }
207
+ handleRetryDebug = { handleBuildRetryDebug }
216
208
handleChangeVersion = { handleChangeVersion }
217
209
handleDormantActivate = { handleDormantActivate }
210
+ canRetryDebug = { canRetryDebugMode }
218
211
canChangeVersions = { canChangeVersions }
219
212
isUpdating = { isUpdating }
220
213
isRestarting = { isRestarting }
@@ -244,8 +237,15 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
244
237
{ updateMessage && < AlertDetail > { updateMessage } </ AlertDetail > }
245
238
</ Alert >
246
239
) ) }
247
- { buildError }
248
- { cancellationError }
240
+
241
+ { Boolean ( workspaceErrors . buildError ) && (
242
+ < ErrorAlert error = { workspaceErrors . buildError } dismissible />
243
+ ) }
244
+
245
+ { Boolean ( workspaceErrors . cancellationError ) && (
246
+ < ErrorAlert error = { workspaceErrors . cancellationError } dismissible />
247
+ ) }
248
+
249
249
{ workspace . latest_build . status === "running" &&
250
250
! workspace . health . healthy && (
251
251
< Alert
@@ -311,16 +311,15 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
311
311
< Alert
312
312
severity = "error"
313
313
actions = {
314
- canRetryDebugMode && (
315
- < Button
316
- key = { 0 }
317
- onClick = { handleBuildRetry }
318
- variant = "text"
319
- size = "small"
320
- >
321
- Try in debug mode
322
- </ Button >
323
- )
314
+ < Button
315
+ onClick = {
316
+ canRetryDebugMode ? handleBuildRetryDebug : handleBuildRetry
317
+ }
318
+ variant = "text"
319
+ size = "small"
320
+ >
321
+ Retry{ canRetryDebugMode && " in debug mode" }
322
+ </ Button >
324
323
}
325
324
>
326
325
< AlertTitle > Workspace build failed</ AlertTitle >
@@ -357,17 +356,15 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
357
356
showBuiltinApps = { canUpdateWorkspace }
358
357
hideSSHButton = { hideSSHButton }
359
358
hideVSCodeDesktopButton = { hideVSCodeDesktopButton }
360
- serverVersion = { serverVersion }
359
+ serverVersion = { buildInfo ?. version || "" }
361
360
onUpdateAgent = { handleUpdate } // On updating the workspace the agent version is also updated
362
361
/>
363
362
) }
364
363
/>
365
364
) }
366
365
367
- { workspaceErrors [ WorkspaceErrors . GET_BUILDS_ERROR ] ? (
368
- < ErrorAlert
369
- error = { workspaceErrors [ WorkspaceErrors . GET_BUILDS_ERROR ] }
370
- />
366
+ { workspaceErrors . getBuildsError ? (
367
+ < ErrorAlert error = { workspaceErrors . getBuildsError } />
371
368
) : (
372
369
< BuildsTable
373
370
builds = { builds }
0 commit comments