Skip to content

Commit

Permalink
WIP: Normalize prebuild logs view status
Browse files Browse the repository at this point in the history
  • Loading branch information
easyCZ committed Apr 5, 2022
1 parent 0c20837 commit 85a3f2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
1 change: 0 additions & 1 deletion components/dashboard/src/components/PrebuildLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
32 changes: 6 additions & 26 deletions components/dashboard/src/projects/Prebuild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -30,7 +30,6 @@ export default function () {
const prebuildId = match?.params?.prebuildId;

const [prebuild, setPrebuild] = useState<PrebuildWithStatus | undefined>();
const [prebuildInstance, setPrebuildInstance] = useState<WorkspaceInstance | undefined>();
const [isRerunningPrebuild, setIsRerunningPrebuild] = useState<boolean>(false);
const [isCancellingPrebuild, setIsCancellingPrebuild] = useState<boolean>(false);

Expand Down Expand Up @@ -109,18 +108,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;
Expand Down Expand Up @@ -161,15 +148,12 @@ export default function () {
<div className="app-container mt-8">
<div className="rounded-xl overflow-hidden bg-gray-100 dark:bg-gray-800 flex flex-col">
<div className="h-96 flex">
<PrebuildLogs
workspaceId={prebuild?.info?.buildWorkspaceId}
onInstanceUpdate={onInstanceUpdate}
/>
<PrebuildLogs workspaceId={prebuild?.info?.buildWorkspaceId} />
</div>
<div className="h-20 px-6 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-600 flex space-x-2">
{prebuild && <PrebuildStatus prebuild={prebuild} />}
<div className="flex-grow" />
{prebuild?.status === "aborted" || prebuild?.status === "timeout" || !!prebuild?.error ? (
{["aborted", "timeout", "failed"].includes(prebuild?.status || "") || !!prebuild?.error ? (
<button
className="flex items-center space-x-2"
disabled={isRerunningPrebuild}
Expand All @@ -178,16 +162,12 @@ export default function () {
{isRerunningPrebuild && (
<img className="h-4 w-4 animate-spin filter brightness-150" src={Spinner} />
)}
<span>Rerun Prebuild ({prebuild.info.branch})</span>
<span>Rerun Prebuild ({prebuild?.info.branch})</span>
</button>
) : prebuild?.status === "building" ? (
) : ["building", "queued"].includes(prebuild?.status || "") ? (
<button
className="danger flex items-center space-x-2"
disabled={
isCancellingPrebuild ||
(prebuildInstance?.status.phase !== "initializing" &&
prebuildInstance?.status.phase !== "running")
}
disabled={isCancellingPrebuild}
onClick={cancelPrebuild}
>
{isCancellingPrebuild && (
Expand Down

0 comments on commit 85a3f2f

Please sign in to comment.