From 2fac6444678592f101667c2af007dddc84058011 Mon Sep 17 00:00:00 2001 From: "Laurie T. Malau" Date: Wed, 22 Jun 2022 19:32:58 +0000 Subject: [PATCH] fix --- .../dashboard/src/components/PrebuildLogs.tsx | 13 ++++-- .../dashboard/src/projects/Prebuild.tsx | 10 +--- .../dashboard/src/start/CreateWorkspace.tsx | 10 +++- .../src/start/IntermediatePrebuildStatus.tsx | 25 ---------- components/dashboard/src/start/LogsView.tsx | 46 ------------------- .../dashboard/src/start/StartWorkspace.tsx | 26 ++++++++--- .../src/workspace/gitpod-server-impl.ts | 5 +- 7 files changed, 41 insertions(+), 94 deletions(-) delete mode 100644 components/dashboard/src/start/IntermediatePrebuildStatus.tsx delete mode 100644 components/dashboard/src/start/LogsView.tsx diff --git a/components/dashboard/src/components/PrebuildLogs.tsx b/components/dashboard/src/components/PrebuildLogs.tsx index 353781169a5a74..ad1bb033058511 100644 --- a/components/dashboard/src/components/PrebuildLogs.tsx +++ b/components/dashboard/src/components/PrebuildLogs.tsx @@ -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) { @@ -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) => { @@ -105,11 +111,10 @@ export default function PrebuildLogs(props: PrebuildLogsProps) { }> -
+
{prebuild && } - +
+ {props.children}
); diff --git a/components/dashboard/src/projects/Prebuild.tsx b/components/dashboard/src/projects/Prebuild.tsx index 2bab83b1be939e..8d9df4515d5f52 100644 --- a/components/dashboard/src/projects/Prebuild.tsx +++ b/components/dashboard/src/projects/Prebuild.tsx @@ -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 () { @@ -157,12 +156,7 @@ export default function () {
-
- -
-
- {prebuild && } -
+ {["aborted", "timeout", "failed"].includes(prebuild?.status || "") || !!prebuild?.error ? ( )} -
+
diff --git a/components/dashboard/src/start/CreateWorkspace.tsx b/components/dashboard/src/start/CreateWorkspace.tsx index dce4399bdca136..6b735326cd83ac 100644 --- a/components/dashboard/src/start/CreateWorkspace.tsx +++ b/components/dashboard/src/start/CreateWorkspace.tsx @@ -488,7 +488,15 @@ function RunningPrebuildView(props: RunningPrebuildViewProps) { return ( - + + + ); } diff --git a/components/dashboard/src/start/IntermediatePrebuildStatus.tsx b/components/dashboard/src/start/IntermediatePrebuildStatus.tsx deleted file mode 100644 index e695c291ff7ea3..00000000000000 --- a/components/dashboard/src/start/IntermediatePrebuildStatus.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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 ( -
-
-
- - running -
-
-
- Prebuild is currently in progress. -
-
- ); -} - -export default IntermediatePrebuildStatus; diff --git a/components/dashboard/src/start/LogsView.tsx b/components/dashboard/src/start/LogsView.tsx deleted file mode 100644 index d25411ccc821fc..00000000000000 --- a/components/dashboard/src/start/LogsView.tsx +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 ( - - }> - {props.shouldRunPrebuild ? ( - - ) : ( - - )} - - {props.shouldRunPrebuild && ( -
- {props.prebuild && } - {!props.prebuild && props.isIntermediate && } - -
- )} -
- ); -} - -export default LogsView; diff --git a/components/dashboard/src/start/StartWorkspace.tsx b/components/dashboard/src/start/StartWorkspace.tsx index 7cff7bb4a121aa..023317cb877e23 100644 --- a/components/dashboard/src/start/StartWorkspace.tsx +++ b/components/dashboard/src/start/StartWorkspace.tsx @@ -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")); @@ -443,7 +443,12 @@ export default class StartWorkspace extends React.Component; + return ( + + ); } if (!this.state.desktopIde) { phase = StartPhase.Running; @@ -570,7 +575,12 @@ export default class StartWorkspace extends React.Component; + return ( + + ); } phase = StartPhase.Stopping; statusMessage = ( @@ -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(() => { @@ -737,5 +747,9 @@ function HeadlessWorkspaceView(props: { instanceId: string }) { }; }, []); - return ; + return ( + + + + ); } diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 413045e2855caf..ded59c6fe9cecf 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -2245,10 +2245,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { public async getPrebuild(ctx: TraceContext, prebuildId: string): Promise { traceAPIParams(ctx, { prebuildId }); - - const user = this.checkAndBlockUser("getPrebuild"); - await this.guardProjectOperation(user, prebuildId, "get"); - + this.checkUser("getPrebuild"); return this.projectsService.getPrebuild(prebuildId); }