Skip to content

Commit 8eb2cb7

Browse files
committed
[dashboard] Redirect to /blocked when trying to create or start a workspace while blocked
1 parent 1af540e commit 8eb2cb7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

components/dashboard/src/start/CreateWorkspace.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
8585
<a href={authorizeUrl}><button className="secondary">Authorize with {error.data.host}</button></a>
8686
</div>;
8787
break;
88+
case ErrorCodes.USER_BLOCKED:
89+
window.location.href = '/blocked';
90+
return;
8891
case ErrorCodes.NOT_FOUND:
8992
return <RepositoryNotFoundView error={error} />;
9093
case ErrorCodes.PLAN_DOES_NOT_ALLOW_PRIVATE_REPOS:

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import EventEmitter from "events";
88
import React, { useEffect, Suspense } from "react";
99
import { DisposableCollection, WorkspaceInstance, WorkspaceImageBuild, Workspace, WithPrebuild } from "@gitpod/gitpod-protocol";
1010
import { HeadlessLogEvent } from "@gitpod/gitpod-protocol/lib/headless-workspace-log";
11+
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
1112
import ContextMenu, { ContextMenuEntry } from "../components/ContextMenu";
1213
import CaretDown from "../icons/CaretDown.svg";
1314
import { getGitpodService, gitpodHostUrl } from "../service/service";
@@ -95,6 +96,10 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
9596
if (typeof error === 'string') {
9697
error = { message: error };
9798
}
99+
if (error?.code === ErrorCodes.USER_BLOCKED) {
100+
this.redirectTo(gitpodHostUrl.with({ pathname: '/blocked' }).toString());
101+
return;
102+
}
98103
this.setState({ error });
99104
}
100105
}
@@ -138,7 +143,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
138143
this.setState({ hasImageBuildLogs: true });
139144
}
140145

141-
let error;
146+
let error: StartWorkspaceError | undefined;
142147
if (workspaceInstance.status.conditions.failed) {
143148
error = { message: workspaceInstance.status.conditions.failed };
144149
}
@@ -186,9 +191,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
186191
const isPrebuilt = WithPrebuild.is(this.state.workspace?.context);
187192
let phase = StartPhase.Preparing;
188193
let title = undefined;
189-
let statusMessage = !error
190-
? <p className="text-base text-gray-400">Preparing workspace …</p>
191-
: <p className="text-base text-gitpod-red w-96">{error.message}</p>;
194+
let statusMessage = !!error ? undefined : <p className="text-base text-gray-400">Preparing workspace …</p>;
192195

193196
switch (this.state?.workspaceInstance?.status.phase) {
194197
// unknown indicates an issue within the system in that it cannot determine the actual phase of

0 commit comments

Comments
 (0)