Skip to content

Commit f1c815a

Browse files
committed
[dashboard] Disable 'Continue with Default Image' button on click to prevent restart spam
1 parent 2e7cba9 commit f1c815a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

components/dashboard/src/start/StartWorkspace.tsx

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

207207
// Pending means the workspace does not yet consume resources in the cluster, but rather is looking for
208208
// some space within the cluster. If for example the cluster needs to scale up to accomodate the
@@ -268,7 +268,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
268268
case "stopped":
269269
phase = StartPhase.Stopped;
270270
if (this.state.hasImageBuildLogs) {
271-
return <ImageBuildView workspaceId={this.state.workspaceInstance.workspaceId} onStartWithDefaultImage={() => this.startWorkspace(true, true)} phase={phase} error={error} />;
271+
return <ImageBuildView workspaceId={this.state.workspaceInstance.workspaceId} onStartWithDefaultImage={e => { (e.target as HTMLButtonElement).disabled = true; this.startWorkspace(true, true); }} phase={phase} error={error} />;
272272
}
273273
if (!isHeadless && this.state.workspaceInstance.status.conditions.timeout) {
274274
title = 'Timed Out';
@@ -332,7 +332,7 @@ function PendingChangesDropdown(props: { workspaceInstance?: WorkspaceInstance }
332332

333333
interface ImageBuildViewProps {
334334
workspaceId: string;
335-
onStartWithDefaultImage: () => void;
335+
onStartWithDefaultImage: (event: React.MouseEvent) => void;
336336
phase?: StartPhase;
337337
error?: StartWorkspaceError;
338338
}

0 commit comments

Comments
 (0)