Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
easyCZ committed Mar 15, 2022
1 parent cddffa3 commit e49a30b
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions components/dashboard/src/projects/Prebuilds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,24 +359,38 @@ export function prebuildStatusIcon(prebuild?: PrebuildWithStatus) {
}
}

function prebuildStatusDescription(prebuild: PrebuildWithStatus): string {
switch (prebuild?.status) {
case undefined: // Fall through
function PrebuildStatusDescription(props: { prebuild: PrebuildWithStatus }) {
switch (props.prebuild.status) {
case "queued":
return "Prebuild is queued and will be processed when there is execution capacity.";
return <span>Prebuild is queued and will be processed when there is execution capacity.</span>;
case "building":
return "Prebuild is currently in progress.";
return <span>Prebuild is currently in progress.</span>;
case "aborted":
return "Prebuild has been cancelled. Either a user cancelled it, or the prebuild rate limit has been exceeded.";
return (
<span>
Prebuild has been cancelled. Either a user cancelled it, or the prebuild rate limit has been
exceeded. {props.prebuild.error}
</span>
);
case "failed":
return "Prebuild failed for system reasons. Please contact support. Error: {prebuild.error}";
return <span>Prebuild failed for system reasons. Please contact support. {props.prebuild.error}</span>;
case "timeout":
return "Prebuild timed out. Either the image, or the prebuild tasks took too long.";
return (
<span>
Prebuild timed out. Either the image, or the prebuild tasks took too long. {props.prebuild.error}
</span>
);
case "available":
if (prebuild?.error) {
return "The tasks executed in the prebuild returned a non-zero exit code.";
if (props.prebuild?.error) {
return (
<span>
The tasks executed in the prebuild returned a non-zero exit code. {props.prebuild.error}
</span>
);
}
return "Prebuild completed succesfully.";
return <span>Prebuild completed succesfully.</span>;
default:
return <span>Unknown prebuild status.</span>;
}
}

Expand All @@ -397,12 +411,13 @@ export function PrebuildStatus(props: { prebuild: PrebuildWithStatus }) {
</div>
</div>
<div className="flex space-x-1 items-center text-gray-400">
<span>{prebuildStatusDescription(prebuild)}</span>
<PrebuildStatusDescription prebuild={prebuild} />
</div>
</div>
);
}

// Deprecated. Use PrebuildStatus instead.
export function PrebuildInstanceStatus(props: { prebuildInstance?: WorkspaceInstance; prebuild?: PrebuildWithStatus }) {
let status = <></>;
let details = <></>;
Expand Down

0 comments on commit e49a30b

Please sign in to comment.