Skip to content

Commit c84bc66

Browse files
committed
chore: Add two new generic container types, add reset button in the error page
1 parent 5e6ed49 commit c84bc66

File tree

4 files changed

+83
-53
lines changed

4 files changed

+83
-53
lines changed

app/error.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import ActionButton from '@/shared/ActionButton';
34
import { DetailedAlert } from '@shared/DetailedAlert';
45
import { useEffect } from 'react';
56
import { RiErrorWarningLine } from 'react-icons/ri';
@@ -16,14 +17,22 @@ export default function ErrorPage({ error, reset }: { error: Error & { digest?:
1617
icon={<RiErrorWarningLine />}
1718
title="Something went wrong"
1819
description={
19-
<div>
20-
An unexpected error occurred. Please try again, or return to the home page.
21-
{process.env.NODE_ENV === 'development' && (
22-
<div className="col gap-1 px-3 py-2 pt-2 font-mono text-sm">
23-
<div>{error.message}</div>
24-
{!!error.digest && <div className="text-slate-500">{error.digest}</div>}
25-
</div>
26-
)}
20+
<div className="col gap-3">
21+
<div>
22+
An unexpected error occurred. Please try again, or return to the home page.
23+
{process.env.NODE_ENV === 'development' && (
24+
<div className="col gap-1 px-3 py-2 pt-2 font-mono text-sm">
25+
<div>{error.message}</div>
26+
{!!error.digest && <div className="text-slate-500">{error.digest}</div>}
27+
</div>
28+
)}
29+
</div>
30+
31+
<div className="center-all w-full">
32+
<ActionButton color="primary" onPress={reset}>
33+
Try Again
34+
</ActionButton>
35+
</div>
2736
</div>
2837
}
2938
fullWidth

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/deeploys/DraftCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default function DraftCard({ project }: { project: DraftProject }) {
6161
<div className="min-w-[110px]">
6262
{!!jobs && (
6363
<div className="font-medium">
64-
{jobs.length} job{jobs.length > 1 ? 's' : ''}
64+
{jobs.length} job{jobs.length > 1 || jobs.length === 0 ? 's' : ''}
6565
</div>
6666
)}
6767
</div>

src/data/containerResources.tsx

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ type RunningJobResources = {
5555
};
5656

5757
export const genericContainerTypes: ContainerOrWorkerType[] = [
58+
{
59+
id: 53,
60+
name: 'MICRO',
61+
jobType: 53,
62+
notes: 'No GPU',
63+
notesColor: 'red',
64+
monthlyBudgetPerWorker: 3,
65+
pricePerEpoch: 100_000n,
66+
minimalBalancing: 2,
67+
cores: 0.25,
68+
ram: 0.5,
69+
storage: 2,
70+
},
71+
{
72+
id: 54,
73+
name: 'LITE',
74+
jobType: 54,
75+
notes: 'No GPU',
76+
notesColor: 'red',
77+
monthlyBudgetPerWorker: 5,
78+
pricePerEpoch: 166_666n,
79+
minimalBalancing: 2,
80+
cores: 0.5,
81+
ram: 1,
82+
storage: 4,
83+
},
5884
{
5985
id: 1,
6086
name: 'ENTRY',
@@ -332,54 +358,49 @@ export const gpuMappings: {
332358
export const getRunningJobResources = (jobType: bigint): RunningJobResources | undefined => {
333359
const jobTypeN = Number(jobType);
334360

335-
if (jobTypeN <= 9) {
336-
// Generic
337-
const genericContainerType = genericContainerTypes.find((type) => type.jobType === jobTypeN);
361+
const genericContainerType = genericContainerTypes.find((type) => type.jobType === jobTypeN);
338362

339-
if (genericContainerType) {
340-
return {
341-
containerOrWorkerType: genericContainerType,
342-
jobType: JobType.Generic,
343-
};
344-
}
345-
} else if (jobTypeN >= 16 && jobTypeN <= 20) {
346-
// Native
347-
const nativeWorkerType = nativeWorkerTypes.find((type) => type.jobType === jobTypeN);
363+
if (genericContainerType) {
364+
return {
365+
containerOrWorkerType: genericContainerType,
366+
jobType: JobType.Generic,
367+
};
368+
}
348369

349-
if (nativeWorkerType) {
350-
return {
351-
containerOrWorkerType: nativeWorkerType,
352-
jobType: JobType.Native,
353-
};
354-
}
355-
} else if (jobTypeN >= 50 && jobTypeN <= 52) {
356-
// Service
357-
const serviceContainerType = serviceContainerTypes.find((type) => type.jobType === jobTypeN);
370+
const nativeWorkerType = nativeWorkerTypes.find((type) => type.jobType === jobTypeN);
358371

359-
if (serviceContainerType) {
360-
return {
361-
containerOrWorkerType: serviceContainerType,
362-
jobType: JobType.Service,
363-
};
364-
}
365-
} else {
366-
const gpuMapping = gpuMappings[jobTypeN];
372+
if (nativeWorkerType) {
373+
return {
374+
containerOrWorkerType: nativeWorkerType,
375+
jobType: JobType.Native,
376+
};
377+
}
367378

368-
if (gpuMapping) {
369-
const gpuType = gpuTypes.find((type) => type.id === gpuMapping.gpuTypeId);
379+
const serviceContainerType = serviceContainerTypes.find((type) => type.jobType === jobTypeN);
370380

371-
const containerOrWorkerType =
372-
gpuMapping.jobType === JobType.Generic
373-
? genericContainerTypes.find((type) => type.id === gpuMapping.containerOrWorkerTypeId)
374-
: nativeWorkerTypes.find((type) => type.id === gpuMapping.containerOrWorkerTypeId);
381+
if (serviceContainerType) {
382+
return {
383+
containerOrWorkerType: serviceContainerType,
384+
jobType: JobType.Service,
385+
};
386+
}
387+
388+
const gpuMapping = gpuMappings[jobTypeN];
389+
390+
if (gpuMapping) {
391+
const gpuType = gpuTypes.find((type) => type.id === gpuMapping.gpuTypeId);
375392

376-
if (gpuType && containerOrWorkerType) {
377-
return {
378-
containerOrWorkerType,
379-
gpuType,
380-
jobType: gpuMapping.jobType,
381-
};
382-
}
393+
const containerOrWorkerType =
394+
gpuMapping.jobType === JobType.Generic
395+
? genericContainerTypes.find((type) => type.id === gpuMapping.containerOrWorkerTypeId)
396+
: nativeWorkerTypes.find((type) => type.id === gpuMapping.containerOrWorkerTypeId);
397+
398+
if (gpuType && containerOrWorkerType) {
399+
return {
400+
containerOrWorkerType,
401+
gpuType,
402+
jobType: gpuMapping.jobType,
403+
};
383404
}
384405
}
385406
};

0 commit comments

Comments
 (0)