Skip to content

Commit

Permalink
[dashboard] Redirect to /blocked when trying to create or start a wor…
Browse files Browse the repository at this point in the history
…kspace while blocked
  • Loading branch information
jankeromnes committed Apr 9, 2021
1 parent 1af540e commit 9600e6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions components/dashboard/src/start/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
<a href={authorizeUrl}><button className="secondary">Authorize with {error.data.host}</button></a>
</div>;
break;
case ErrorCodes.USER_BLOCKED:
window.location.href = '/blocked';
return;
case ErrorCodes.NOT_FOUND:
return <RepositoryNotFoundView error={error} />;
case ErrorCodes.PLAN_DOES_NOT_ALLOW_PRIVATE_REPOS:
Expand Down
11 changes: 7 additions & 4 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import EventEmitter from "events";
import React, { useEffect, Suspense } from "react";
import { DisposableCollection, WorkspaceInstance, WorkspaceImageBuild, Workspace, WithPrebuild } from "@gitpod/gitpod-protocol";
import { HeadlessLogEvent } from "@gitpod/gitpod-protocol/lib/headless-workspace-log";
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
import ContextMenu, { ContextMenuEntry } from "../components/ContextMenu";
import CaretDown from "../icons/CaretDown.svg";
import { getGitpodService, gitpodHostUrl } from "../service/service";
Expand Down Expand Up @@ -95,6 +96,10 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
if (typeof error === 'string') {
error = { message: error };
}
if (error?.code === ErrorCodes.USER_BLOCKED) {
this.redirectTo(gitpodHostUrl.with({ pathname: '/blocked' }).toString());
return;
}
this.setState({ error });
}
}
Expand Down Expand Up @@ -138,7 +143,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
this.setState({ hasImageBuildLogs: true });
}

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

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

0 comments on commit 9600e6d

Please sign in to comment.