diff --git a/components/dashboard/src/components/PrebuildLogs.tsx b/components/dashboard/src/components/PrebuildLogs.tsx index 3cddd1778838e2..e0b1530f04fbd3 100644 --- a/components/dashboard/src/components/PrebuildLogs.tsx +++ b/components/dashboard/src/components/PrebuildLogs.tsx @@ -19,7 +19,6 @@ const WorkspaceLogs = React.lazy(() => import("./WorkspaceLogs")); export interface PrebuildLogsProps { workspaceId?: string; - onInstanceUpdate?: (instance: WorkspaceInstance) => void; } export default function PrebuildLogs(props: PrebuildLogsProps) { @@ -81,9 +80,6 @@ export default function PrebuildLogs(props: PrebuildLogsProps) { }, [props.workspaceId]); useEffect(() => { - if (props.onInstanceUpdate && workspaceInstance) { - props.onInstanceUpdate(workspaceInstance); - } switch (workspaceInstance?.status.phase) { // Preparing means that we haven't actually started the workspace instance just yet, but rather // are still preparing for launch. This means we're building the Docker image for the workspace. diff --git a/components/dashboard/src/projects/Prebuild.tsx b/components/dashboard/src/projects/Prebuild.tsx index fe7cd3113f6eb4..2bab83b1be939e 100644 --- a/components/dashboard/src/projects/Prebuild.tsx +++ b/components/dashboard/src/projects/Prebuild.tsx @@ -5,7 +5,7 @@ */ import moment from "moment"; -import { PrebuildWithStatus, WorkspaceInstance } from "@gitpod/gitpod-protocol"; +import { PrebuildWithStatus } from "@gitpod/gitpod-protocol"; import { useContext, useEffect, useState } from "react"; import { useHistory, useLocation, useRouteMatch } from "react-router"; import Header from "../components/Header"; @@ -30,7 +30,6 @@ export default function () { const prebuildId = match?.params?.prebuildId; const [prebuild, setPrebuild] = useState(); - const [prebuildInstance, setPrebuildInstance] = useState(); const [isRerunningPrebuild, setIsRerunningPrebuild] = useState(false); const [isCancellingPrebuild, setIsCancellingPrebuild] = useState(false); @@ -56,6 +55,16 @@ export default function () { }); setPrebuild(prebuilds[0]); })(); + + return getGitpodService().registerClient({ + onPrebuildUpdate(update: PrebuildWithStatus) { + if (update.info.id !== prebuildId) { + return; + } + + setPrebuild(update); + }, + }).dispose; }, [prebuildId, projectSlug, team, teams]); const renderTitle = () => { @@ -109,18 +118,6 @@ export default function () { ); }; - const onInstanceUpdate = async (instance: WorkspaceInstance) => { - setPrebuildInstance(instance); - if (!prebuild) { - return; - } - const prebuilds = await getGitpodService().server.findPrebuilds({ - projectId: prebuild.info.projectId, - prebuildId, - }); - setPrebuild(prebuilds[0]); - }; - const rerunPrebuild = async () => { if (!prebuild) { return; @@ -161,15 +158,12 @@ export default function () {
- +
{prebuild && }
- {prebuild?.status === "aborted" || prebuild?.status === "timeout" || !!prebuild?.error ? ( + {["aborted", "timeout", "failed"].includes(prebuild?.status || "") || !!prebuild?.error ? ( - ) : prebuild?.status === "building" ? ( + ) : ["building", "queued"].includes(prebuild?.status || "") ? (