Skip to content

Commit 7ebe21f

Browse files
committed
Normalize usage of prebuild status in dashboard
1 parent 0fc7a91 commit 7ebe21f

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

components/dashboard/src/projects/Prebuild.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import PrebuildLogs from "../components/PrebuildLogs";
1313
import Spinner from "../icons/Spinner.svg";
1414
import { getGitpodService, gitpodHostUrl } from "../service/service";
1515
import { TeamsContext, getCurrentTeam } from "../teams/teams-context";
16-
import { PrebuildInstanceStatus } from "./Prebuilds";
16+
import { PrebuildStatus } from "./Prebuilds";
1717
import { shortCommitMessage } from "./render-utils";
1818

1919
export default function () {
@@ -167,7 +167,7 @@ export default function () {
167167
/>
168168
</div>
169169
<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">
170-
{prebuildInstance && <PrebuildInstanceStatus prebuildInstance={prebuildInstance} />}
170+
{prebuildInstance && <PrebuildStatus prebuild={prebuild!} />}
171171
<div className="flex-grow" />
172172
{prebuild?.status === "aborted" || prebuild?.status === "timeout" || !!prebuild?.error ? (
173173
<button

components/dashboard/src/projects/Prebuilds.tsx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,66 @@ export function prebuildStatusIcon(prebuild?: PrebuildWithStatus) {
359359
}
360360
}
361361

362+
function PrebuildStatusDescription(props: { prebuild: PrebuildWithStatus }) {
363+
switch (props.prebuild.status) {
364+
case "queued":
365+
return <span>Prebuild is queued and will be processed when there is execution capacity.</span>;
366+
case "building":
367+
return <span>Prebuild is currently in progress.</span>;
368+
case "aborted":
369+
return (
370+
<span>
371+
Prebuild has been cancelled. Either a user cancelled it, or the prebuild rate limit has been
372+
exceeded. {props.prebuild.error}
373+
</span>
374+
);
375+
case "failed":
376+
return <span>Prebuild failed for system reasons. Please contact support. {props.prebuild.error}</span>;
377+
case "timeout":
378+
return (
379+
<span>
380+
Prebuild timed out. Either the image, or the prebuild tasks took too long. {props.prebuild.error}
381+
</span>
382+
);
383+
case "available":
384+
if (props.prebuild?.error) {
385+
return (
386+
<span>
387+
The tasks executed in the prebuild returned a non-zero exit code. {props.prebuild.error}
388+
</span>
389+
);
390+
}
391+
return <span>Prebuild completed succesfully.</span>;
392+
default:
393+
return <span>Unknown prebuild status.</span>;
394+
}
395+
}
396+
362397
function formatDuration(milliseconds: number) {
363398
const hours = Math.floor(milliseconds / (1000 * 60 * 60));
364399
return (hours > 0 ? `${hours}:` : "") + moment(milliseconds).format("mm:ss");
365400
}
366401

367-
export function PrebuildInstanceStatus(props: { prebuildInstance?: WorkspaceInstance }) {
402+
export function PrebuildStatus(props: { prebuild: PrebuildWithStatus }) {
403+
const prebuild = props.prebuild;
404+
405+
return (
406+
<div className="flex flex-col space-y-1 justify-center text-sm font-semibold">
407+
<div>
408+
<div className="flex space-x-1 items-center">
409+
{prebuildStatusIcon(prebuild)}
410+
{prebuildStatusLabel(prebuild)}
411+
</div>
412+
</div>
413+
<div className="flex space-x-1 items-center text-gray-400">
414+
<PrebuildStatusDescription prebuild={prebuild} />
415+
</div>
416+
</div>
417+
);
418+
}
419+
420+
// Deprecated. Use PrebuildStatus instead.
421+
export function PrebuildInstanceStatus(props: { prebuildInstance?: WorkspaceInstance; prebuild?: PrebuildWithStatus }) {
368422
let status = <></>;
369423
let details = <></>;
370424
switch (props.prebuildInstance?.status.phase) {

0 commit comments

Comments
 (0)