Skip to content

[dashboard] Redirect to /blocked when trying to create or start a workspace while blocked #3785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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