Skip to content

Commit

Permalink
use logsview
Browse files Browse the repository at this point in the history
  • Loading branch information
laushinka committed Jun 21, 2022
1 parent 6d263ae commit eb1689a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 91 deletions.
32 changes: 11 additions & 21 deletions components/dashboard/src/start/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import EventEmitter from "events";
import React, { useEffect, Suspense, useContext, useState } from "react";
import React, { useEffect, useContext, useState } from "react";
import {
CreateWorkspaceMode,
WorkspaceCreationResult,
Expand All @@ -22,12 +22,11 @@ import StartWorkspace, { parseProps } from "./StartWorkspace";
import { openAuthorizeWindow } from "../provider-utils";
import { SelectAccountPayload } from "@gitpod/gitpod-protocol/lib/auth";
import { SelectAccountModal } from "../settings/SelectAccountModal";
import PrebuildLogs, { watchHeadlessLogs } from "../components/PrebuildLogs";
import { watchHeadlessLogs } from "../components/PrebuildLogs";
import CodeText from "../components/CodeText";
import FeedbackComponent from "../feedback-form/FeedbackComponent";
import { isGitpodIo } from "../utils";
import { PrebuildStatus } from "../projects/Prebuilds";
import IntermediatePrebuildStatus from "./IntermediatePrebuildStatus";
import LogsView from "./LogsView";

export interface CreateWorkspaceProps {
contextUrl: string;
Expand Down Expand Up @@ -502,22 +501,13 @@ function RunningPrebuildView(props: RunningPrebuildViewProps) {
}, []);

return (
<StartPage title="Prebuild in Progress">
<Suspense fallback={<div />}>
<PrebuildLogs workspaceId={props.runningPrebuild.workspaceID} />
</Suspense>
<div className="flex">
{prebuild && <PrebuildStatus prebuild={prebuild} />}
{!prebuild && props.runningPrebuild.starting && <IntermediatePrebuildStatus />}
<button
className="mt-6 secondary"
onClick={() => {
props.onIgnorePrebuild();
}}
>
Skip Prebuild
</button>
</div>
</StartPage>
<LogsView
logsEmitter={logsEmitter}
workspaceId={props.runningPrebuild.workspaceID}
prebuild={prebuild}
onIgnorePrebuild={props.onIgnorePrebuild}
shouldRunPrebuild={true}
isIntermediate={props.runningPrebuild.starting === "running"}
/>
);
}
4 changes: 2 additions & 2 deletions components/dashboard/src/start/IntermediatePrebuildStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function IntermediatePrebuildStatus() {
<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>;
<img alt="" className="h-4 w-4" src={StatusRunning} />
<span className="font-medium text-blue-500 uppercase">running</span>
</div>
</div>
</div>
Expand Down
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-4">
{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} />;
}
61 changes: 0 additions & 61 deletions components/dashboard/src/start/WatchLogsView.tsx

This file was deleted.

0 comments on commit eb1689a

Please sign in to comment.