Skip to content

Commit

Permalink
add component
Browse files Browse the repository at this point in the history
  • Loading branch information
laushinka committed Jun 21, 2022
1 parent 065141b commit b6d2007
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/dashboard/src/components/PrebuildLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { getGitpodService } from "../service/service";
const WorkspaceLogs = React.lazy(() => import("./WorkspaceLogs"));

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

Expand Down
61 changes: 61 additions & 0 deletions components/dashboard/src/start/WatchLogsView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* 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, useEffect, useState } from "react";
import EventEmitter from "events";
import PrebuildLogs, { watchHeadlessLogs } from "../components/PrebuildLogs";
import { StartPage } from "./StartPage";
import WorkspaceLogs from "../components/WorkspaceLogs";
import { PrebuildWithStatus } from "@gitpod/gitpod-protocol";
import { PrebuildStatus } from "../projects/Prebuilds";

function WatchLogsView(props: {
instanceId: string;
hasPrebuild?: boolean;
prebuild?: PrebuildWithStatus | undefined;
}) {
const [logsEmitter] = useState(new EventEmitter());

useEffect(() => {
const disposables = watchHeadlessLogs(
props.instanceId,
(chunk) => logsEmitter.emit("logs", chunk),
async () => {
return false;
},
);
return function cleanup() {
disposables.dispose();
};
}, []);

return (
<StartPage title="Prebuild in Progress">
<Suspense fallback={<div />}>
{props.hasPrebuild ? (
<PrebuildLogs workspaceId={props.instanceId} />
) : (
<WorkspaceLogs logsEmitter={logsEmitter} />
)}
</Suspense>
{props.hasPrebuild && (
<div className="flex">
{props.prebuild && <PrebuildStatus prebuild={props.prebuild} />}
<button
className="mt-6 secondary"
onClick={() => {
// props.onIgnorePrebuild();
}}
>
Skip Prebuild
</button>
</div>
)}
</StartPage>
);
}

export default WatchLogsView;

0 comments on commit b6d2007

Please sign in to comment.