Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laushinka committed Jun 22, 2022
1 parent 44694a8 commit 2fac644
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 94 deletions.
13 changes: 9 additions & 4 deletions components/dashboard/src/components/PrebuildLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ const WorkspaceLogs = React.lazy(() => import("./WorkspaceLogs"));

export interface PrebuildLogsProps {
workspaceId: string | undefined;
prebuildId?: string | undefined;
logsEmitter?: EventEmitter;
onIgnorePrebuild?: () => void;
children?: React.ReactNode;
}

export default function PrebuildLogs(props: PrebuildLogsProps) {
Expand All @@ -46,6 +48,10 @@ export default function PrebuildLogs(props: PrebuildLogsProps) {
setWorkspace(info.workspace);
setWorkspaceInstance(info.latestInstance);
}
if (props.prebuildId) {
const foundPrebuild = await getGitpodService().server.getPrebuild(props.prebuildId);
setPrebuild(foundPrebuild);
}
disposables.push(
getGitpodService().registerClient({
onInstanceUpdate: (instance) => {
Expand Down Expand Up @@ -105,11 +111,10 @@ export default function PrebuildLogs(props: PrebuildLogsProps) {
<Suspense fallback={<div />}>
<WorkspaceLogs logsEmitter={logsEmitter} errorMessage={error?.message} />
</Suspense>
<div className="flex gap-x-8 mt-4 mb-8">
<div className="h-20 px-6 border-t border-gray-200 dark:border-gray-600 flex space-x-2">
{prebuild && <PrebuildStatus prebuild={prebuild} />}
<button className="secondary" onClick={() => props.onIgnorePrebuild && props.onIgnorePrebuild()}>
Skip Prebuild
</button>
<div className="flex-grow" />
{props.children}
</div>
</>
);
Expand Down
10 changes: 2 additions & 8 deletions components/dashboard/src/projects/Prebuild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import PrebuildLogs from "../components/PrebuildLogs";
import Spinner from "../icons/Spinner.svg";
import { getGitpodService, gitpodHostUrl } from "../service/service";
import { TeamsContext, getCurrentTeam } from "../teams/teams-context";
import { PrebuildStatus } from "./Prebuilds";
import { shortCommitMessage } from "./render-utils";

export default function () {
Expand Down Expand Up @@ -157,12 +156,7 @@ export default function () {
<Header title={renderTitle()} subtitle={renderSubtitle()} />
<div className="app-container mt-8">
<div className="rounded-xl overflow-hidden bg-gray-100 dark:bg-gray-800 flex flex-col">
<div className="h-96 flex">
<PrebuildLogs workspaceId={prebuild?.info?.buildWorkspaceId} />
</div>
<div className="h-20 px-6 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-600 flex space-x-2">
{prebuild && <PrebuildStatus prebuild={prebuild} />}
<div className="flex-grow" />
<PrebuildLogs workspaceId={prebuild?.info?.buildWorkspaceId} prebuildId={prebuild?.info?.id}>
{["aborted", "timeout", "failed"].includes(prebuild?.status || "") || !!prebuild?.error ? (
<button
className="flex items-center space-x-2"
Expand Down Expand Up @@ -195,7 +189,7 @@ export default function () {
) : (
<button disabled={true}>New Workspace ({prebuild?.info.branch})</button>
)}
</div>
</PrebuildLogs>
</div>
</div>
</>
Expand Down
10 changes: 9 additions & 1 deletion components/dashboard/src/start/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,15 @@ function RunningPrebuildView(props: RunningPrebuildViewProps) {

return (
<StartPage title="Prebuild in Progress">
<PrebuildLogs workspaceId={props.runningPrebuild.workspaceID} onIgnorePrebuild={props.onIgnorePrebuild} />
<PrebuildLogs
workspaceId={props.runningPrebuild.workspaceID}
onIgnorePrebuild={props.onIgnorePrebuild}
prebuildId={props.runningPrebuild.prebuildID}
>
<button className="secondary" onClick={() => props.onIgnorePrebuild && props.onIgnorePrebuild()}>
Skip Prebuild
</button>
</PrebuildLogs>
</StartPage>
);
}
25 changes: 0 additions & 25 deletions components/dashboard/src/start/IntermediatePrebuildStatus.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions components/dashboard/src/start/LogsView.tsx

This file was deleted.

26 changes: 20 additions & 6 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import { v4 } from "uuid";
import Arrow from "../components/Arrow";
import ContextMenu from "../components/ContextMenu";
import PendingChangesDropdown from "../components/PendingChangesDropdown";
import { watchHeadlessLogs } from "../components/PrebuildLogs";
import PrebuildLogs, { watchHeadlessLogs } from "../components/PrebuildLogs";
import { getGitpodService, gitpodHostUrl } from "../service/service";
import { StartPage, StartPhase, StartWorkspaceError } from "./StartPage";
import ConnectToSSHModal from "../workspaces/ConnectToSSHModal";
import Alert from "../components/Alert";
import LogsView from "./LogsView";

const sessionId = v4();

const WorkspaceLogs = React.lazy(() => import("../components/WorkspaceLogs"));
Expand Down Expand Up @@ -443,7 +443,12 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
// or as a headless workspace.
case "running":
if (isPrebuild) {
return <HeadlessWorkspaceView instanceId={this.state.workspaceInstance.id} />;
return (
<HeadlessWorkspaceView
instanceId={this.state.workspaceInstance.id}
workspaceId={this.props.workspaceId}
/>
);
}
if (!this.state.desktopIde) {
phase = StartPhase.Running;
Expand Down Expand Up @@ -570,7 +575,12 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
// Stopping means that the workspace is currently shutting down. It could go to stopped every moment.
case "stopping":
if (isPrebuild) {
return <HeadlessWorkspaceView instanceId={this.state.workspaceInstance.id} />;
return (
<HeadlessWorkspaceView
instanceId={this.state.workspaceInstance.id}
workspaceId={this.props.workspaceId}
/>
);
}
phase = StartPhase.Stopping;
statusMessage = (
Expand Down Expand Up @@ -721,7 +731,7 @@ function ImageBuildView(props: ImageBuildViewProps) {
);
}

function HeadlessWorkspaceView(props: { instanceId: string }) {
function HeadlessWorkspaceView(props: { instanceId: string; workspaceId?: string }) {
const [logsEmitter] = useState(new EventEmitter());

useEffect(() => {
Expand All @@ -737,5 +747,9 @@ function HeadlessWorkspaceView(props: { instanceId: string }) {
};
}, []);

return <LogsView logsEmitter={logsEmitter} />;
return (
<StartPage title="Prebuild in Progress">
<PrebuildLogs workspaceId={props.workspaceId} />
</StartPage>
);
}
5 changes: 1 addition & 4 deletions components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2245,10 +2245,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {

public async getPrebuild(ctx: TraceContext, prebuildId: string): Promise<PrebuildWithStatus | undefined> {
traceAPIParams(ctx, { prebuildId });

const user = this.checkAndBlockUser("getPrebuild");
await this.guardProjectOperation(user, prebuildId, "get");

this.checkUser("getPrebuild");
return this.projectsService.getPrebuild(prebuildId);
}

Expand Down

0 comments on commit 2fac644

Please sign in to comment.