Skip to content

Commit cddffa3

Browse files
committed
Fix
1 parent a86484e commit cddffa3

File tree

1 file changed

+28
-66
lines changed

1 file changed

+28
-66
lines changed

components/dashboard/src/projects/Prebuilds.tsx

Lines changed: 28 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -359,84 +359,46 @@ export function prebuildStatusIcon(prebuild?: PrebuildWithStatus) {
359359
}
360360
}
361361

362-
function formatDuration(milliseconds: number) {
363-
const hours = Math.floor(milliseconds / (1000 * 60 * 60));
364-
return (hours > 0 ? `${hours}:` : "") + moment(milliseconds).format("mm:ss");
365-
}
366-
367-
export function PrebuildStatus(props: { prebuild: PrebuildWithStatus }) {
368-
const prebuild = props.prebuild;
369-
370-
let status = (
371-
<div className="flex space-x-1 items-center">
372-
{prebuildStatusIcon(prebuild)}
373-
{prebuildStatusLabel(prebuild)}
374-
</div>
375-
);
376-
377-
let details;
378-
379-
switch (prebuild.status) {
362+
function prebuildStatusDescription(prebuild: PrebuildWithStatus): string {
363+
switch (prebuild?.status) {
364+
case undefined: // Fall through
380365
case "queued":
381-
details = (
382-
<div className="flex space-x-1 items-center text-gray-400">
383-
<span>Prebuild is queued and will be processed when there is execution capacity ...</span>
384-
</div>
385-
);
386-
break;
366+
return "Prebuild is queued and will be processed when there is execution capacity.";
387367
case "building":
388-
details = (
389-
<div className="flex space-x-1 items-center text-gray-400">
390-
<span>Prebuild is currently in progress.</span>
391-
</div>
392-
);
393-
break;
368+
return "Prebuild is currently in progress.";
394369
case "aborted":
395-
details = (
396-
<div className="flex space-x-1 items-center text-gray-400">
397-
<span>
398-
Prebuild has been cancelled. Either a user cancelled it, or the prebuild rate limit has been
399-
exceeded.
400-
</span>
401-
</div>
402-
);
403-
break;
370+
return "Prebuild has been cancelled. Either a user cancelled it, or the prebuild rate limit has been exceeded.";
404371
case "failed":
405-
details = (
406-
<div className="flex space-x-1 items-center text-gray-400">
407-
<span>Prebuild failed. {prebuild.error}</span>
408-
</div>
409-
);
410-
break;
372+
return "Prebuild failed for system reasons. Please contact support. Error: {prebuild.error}";
411373
case "timeout":
412-
details = (
413-
<div className="flex space-x-1 items-center text-gray-400">
414-
<span>Prebuild timed out. {prebuild.error}</span>
415-
</div>
416-
);
417-
break;
374+
return "Prebuild timed out. Either the image, or the prebuild tasks took too long.";
418375
case "available":
419376
if (prebuild?.error) {
420-
details = (
421-
<div className="flex space-x-1 items-center text-gray-400">
422-
<span>Prebuild failed. {prebuild.error}</span>
423-
</div>
424-
);
425-
break;
377+
return "The tasks executed in the prebuild returned a non-zero exit code.";
426378
}
427-
428-
details = (
429-
<div className="flex space-x-1 items-center text-gray-400">
430-
<span>Prebuild failed. {prebuild.error}</span>
431-
</div>
432-
);
433-
break;
379+
return "Prebuild completed succesfully.";
434380
}
381+
}
382+
383+
function formatDuration(milliseconds: number) {
384+
const hours = Math.floor(milliseconds / (1000 * 60 * 60));
385+
return (hours > 0 ? `${hours}:` : "") + moment(milliseconds).format("mm:ss");
386+
}
387+
388+
export function PrebuildStatus(props: { prebuild: PrebuildWithStatus }) {
389+
const prebuild = props.prebuild;
435390

436391
return (
437392
<div className="flex flex-col space-y-1 justify-center text-sm font-semibold">
438-
<div>{status}</div>
439-
<div>{details}</div>
393+
<div>
394+
<div className="flex space-x-1 items-center">
395+
{prebuildStatusIcon(prebuild)}
396+
{prebuildStatusLabel(prebuild)}
397+
</div>
398+
</div>
399+
<div className="flex space-x-1 items-center text-gray-400">
400+
<span>{prebuildStatusDescription(prebuild)}</span>
401+
</div>
440402
</div>
441403
);
442404
}

0 commit comments

Comments
 (0)