Skip to content

Commit

Permalink
use prebuildlogs instead
Browse files Browse the repository at this point in the history
  • Loading branch information
laushinka committed Jun 21, 2022
1 parent 1617d3d commit 68eeca1
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 25 deletions.
5 changes: 3 additions & 2 deletions components/dashboard/src/components/PrebuildLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { getGitpodService } from "../service/service";
const WorkspaceLogs = React.lazy(() => import("./WorkspaceLogs"));

export interface PrebuildLogsProps {
workspaceId?: string;
workspaceId: string | undefined;
logsEmitter?: EventEmitter;
}

export default function PrebuildLogs(props: PrebuildLogsProps) {
Expand Down Expand Up @@ -92,7 +93,7 @@ export default function PrebuildLogs(props: PrebuildLogsProps) {

return (
<Suspense fallback={<div />}>
<WorkspaceLogs classes="h-full w-full" logsEmitter={logsEmitter} errorMessage={error?.message} />
<WorkspaceLogs logsEmitter={logsEmitter} errorMessage={error?.message} />
</Suspense>
);
}
Expand Down
33 changes: 17 additions & 16 deletions components/dashboard/src/start/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
*/

import EventEmitter from "events";
import React, { useEffect, Suspense, useContext, useState } from "react";
import React, { useEffect, useContext, useState } from "react";
import {
CreateWorkspaceMode,
WorkspaceCreationResult,
RunningWorkspacePrebuildStarting,
ContextURL,
PrebuildWithStatus,
} from "@gitpod/gitpod-protocol";
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
import Modal from "../components/Modal";
Expand All @@ -25,8 +26,7 @@ import { watchHeadlessLogs } from "../components/PrebuildLogs";
import CodeText from "../components/CodeText";
import FeedbackComponent from "../feedback-form/FeedbackComponent";
import { isGitpodIo } from "../utils";

const WorkspaceLogs = React.lazy(() => import("../components/WorkspaceLogs"));
import LogsView from "./LogsView";

export interface CreateWorkspaceProps {
contextUrl: string;
Expand Down Expand Up @@ -462,6 +462,7 @@ interface RunningPrebuildViewProps {

function RunningPrebuildView(props: RunningPrebuildViewProps) {
const [logsEmitter] = useState(new EventEmitter());
const [prebuild, setPrebuild] = useState<PrebuildWithStatus | undefined>();

useEffect(() => {
const disposables = watchHeadlessLogs(
Expand All @@ -480,6 +481,11 @@ function RunningPrebuildView(props: RunningPrebuildViewProps) {
props.onPrebuildSucceeded();
}
},
onPrebuildUpdate(update: PrebuildWithStatus) {
if (update.info) {
setPrebuild(update);
}
},
}),
);

Expand All @@ -489,18 +495,13 @@ function RunningPrebuildView(props: RunningPrebuildViewProps) {
}, []);

return (
<StartPage title="Prebuild in Progress">
<Suspense fallback={<div />}>
<WorkspaceLogs logsEmitter={logsEmitter} />
</Suspense>
<button
className="mt-6 secondary"
onClick={() => {
props.onIgnorePrebuild();
}}
>
Don't Wait for Prebuild
</button>
</StartPage>
<LogsView
logsEmitter={logsEmitter}
workspaceId={props.runningPrebuild.workspaceID}
prebuild={prebuild}
onIgnorePrebuild={props.onIgnorePrebuild}
shouldRunPrebuild={true}
isIntermediate={props.runningPrebuild.starting === "running"}
/>
);
}
25 changes: 25 additions & 0 deletions components/dashboard/src/start/IntermediatePrebuildStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

import StatusRunning from "../icons/StatusRunning.svg";

function IntermediatePrebuildStatus() {
return (
<div className="flex flex-col space-y-1 justify-center text-sm font-semibold">
<div>
<div className="flex space-x-1 items-center">
<img alt="" className="h-4 w-4" src={StatusRunning} />
<span className="font-medium text-blue-500 uppercase">running</span>
</div>
</div>
<div className="flex space-x-1 items-center text-gray-400">
<span>Prebuild is currently in progress.</span>
</div>
</div>
);
}

export default IntermediatePrebuildStatus;
46 changes: 46 additions & 0 deletions components/dashboard/src/start/LogsView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

import { Suspense } from "react";
import EventEmitter from "events";
import PrebuildLogs from "../components/PrebuildLogs";
import { StartPage } from "./StartPage";
import WorkspaceLogs from "../components/WorkspaceLogs";
import { PrebuildWithStatus } from "@gitpod/gitpod-protocol";
import { PrebuildStatus } from "../projects/Prebuilds";
import IntermediatePrebuildStatus from "./IntermediatePrebuildStatus";

function LogsView(props: {
logsEmitter: EventEmitter;
workspaceId?: string;
shouldRunPrebuild?: boolean;
prebuild?: PrebuildWithStatus | undefined;
onIgnorePrebuild?: () => void;
isIntermediate?: boolean;
}) {
return (
<StartPage title="Prebuild in Progress">
<Suspense fallback={<div />}>
{props.shouldRunPrebuild ? (
<PrebuildLogs workspaceId={props.workspaceId} />
) : (
<WorkspaceLogs logsEmitter={props.logsEmitter} />
)}
</Suspense>
{props.shouldRunPrebuild && (
<div className="flex gap-x-8 mt-4 mb-8">
{props.prebuild && <PrebuildStatus prebuild={props.prebuild} />}
{!props.prebuild && props.isIntermediate && <IntermediatePrebuildStatus />}
<button className="secondary" onClick={() => props.onIgnorePrebuild && props.onIgnorePrebuild()}>
Skip Prebuild
</button>
</div>
)}
</StartPage>
);
}

export default LogsView;
9 changes: 2 additions & 7 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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 @@ -736,11 +737,5 @@ function HeadlessWorkspaceView(props: { instanceId: string }) {
};
}, []);

return (
<StartPage title="Prebuild in Progress">
<Suspense fallback={<div />}>
<WorkspaceLogs logsEmitter={logsEmitter} />
</Suspense>
</StartPage>
);
return <LogsView logsEmitter={logsEmitter} />;
}

0 comments on commit 68eeca1

Please sign in to comment.