Skip to content

Commit 5774850

Browse files
committed
[dashboard] Don't show 'Continue with Default Image' button while the build is still running
1 parent 7796eec commit 5774850

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
201201
// Preparing means that we haven't actually started the workspace instance just yet, but rather
202202
// are still preparing for launch. This means we're building the Docker image for the workspace.
203203
case "preparing":
204-
return <ImageBuildView workspaceId={this.state.workspaceInstance.workspaceId} onStartWithDefaultImage={e => { (e.target as HTMLButtonElement).disabled = true; this.startWorkspace(true, true); }} />;
204+
return <ImageBuildView workspaceId={this.state.workspaceInstance.workspaceId} />;
205205

206206
// Pending means the workspace does not yet consume resources in the cluster, but rather is looking for
207207
// some space within the cluster. If for example the cluster needs to scale up to accomodate the
@@ -267,7 +267,11 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
267267
case "stopped":
268268
phase = StartPhase.Stopped;
269269
if (this.state.hasImageBuildLogs) {
270-
return <ImageBuildView workspaceId={this.state.workspaceInstance.workspaceId} onStartWithDefaultImage={e => { (e.target as HTMLButtonElement).disabled = true; this.startWorkspace(true, true); }} phase={phase} error={error} />;
270+
const restartWithDefaultImage = (event: React.MouseEvent) => {
271+
(event.target as HTMLButtonElement).disabled = true;
272+
this.startWorkspace(true, true);
273+
}
274+
return <ImageBuildView workspaceId={this.state.workspaceInstance.workspaceId} onStartWithDefaultImage={restartWithDefaultImage} phase={phase} error={error} />;
271275
}
272276
if (!isHeadless && this.state.workspaceInstance.status.conditions.timeout) {
273277
title = 'Timed Out';
@@ -297,7 +301,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
297301

298302
interface ImageBuildViewProps {
299303
workspaceId: string;
300-
onStartWithDefaultImage: (event: React.MouseEvent) => void;
304+
onStartWithDefaultImage?: (event: React.MouseEvent) => void;
301305
phase?: StartPhase;
302306
error?: StartWorkspaceError;
303307
}
@@ -329,7 +333,7 @@ function ImageBuildView(props: ImageBuildViewProps) {
329333
<Suspense fallback={<div />}>
330334
<WorkspaceLogs logsEmitter={logsEmitter} errorMessage={props.error?.message} />
331335
</Suspense>
332-
<button className="mt-6 secondary" onClick={props.onStartWithDefaultImage}>Continue with Default Image</button>
336+
{!!props.onStartWithDefaultImage && <button className="mt-6 secondary" onClick={props.onStartWithDefaultImage}>Continue with Default Image</button>}
333337
</StartPage>;
334338
}
335339

0 commit comments

Comments
 (0)