From a8f8aec6dcd14095c201aeafc9b89e5931d39b0b Mon Sep 17 00:00:00 2001 From: Alex Drankou Date: Mon, 15 Jun 2026 11:55:06 +0200 Subject: [PATCH 1/3] feat: make templates list build-agnostic, move resources to builds # Conflicts: # src/features/dashboard/templates/builds/table.tsx # src/features/dashboard/templates/list/table-config.tsx # src/features/dashboard/templates/list/table.tsx --- src/core/modules/builds/models.ts | 4 + src/core/modules/builds/repository.server.ts | 4 + .../dashboard/common/envd-version.tsx | 39 +++++++++ .../templates/builds/table-cells.tsx | 80 ++++++++++++++----- .../dashboard/templates/builds/table.tsx | 64 ++++++++++----- .../dashboard/templates/list/table-cells.tsx | 57 ------------- .../dashboard/templates/list/table-config.tsx | 27 ------- 7 files changed, 154 insertions(+), 121 deletions(-) create mode 100644 src/features/dashboard/common/envd-version.tsx diff --git a/src/core/modules/builds/models.ts b/src/core/modules/builds/models.ts index e94eb62c1..78b314d66 100644 --- a/src/core/modules/builds/models.ts +++ b/src/core/modules/builds/models.ts @@ -31,6 +31,10 @@ export interface ListedBuildModel { statusMessage: string | null createdAt: number finishedAt: number | null + cpuCount: number + memoryMB: number + diskSizeMB: number | null + envdVersion: string | null } export interface RunningBuildStatusModel { diff --git a/src/core/modules/builds/repository.server.ts b/src/core/modules/builds/repository.server.ts index 1cfaab6d9..df02e1ae4 100644 --- a/src/core/modules/builds/repository.server.ts +++ b/src/core/modules/builds/repository.server.ts @@ -149,6 +149,10 @@ export function createBuildsRepository( finishedAt: build.finishedAt ? new Date(build.finishedAt).getTime() : null, + cpuCount: build.cpuCount, + memoryMB: build.memoryMB, + diskSizeMB: build.diskSizeMB, + envdVersion: build.envdVersion, }) ), nextCursor: result.data?.nextCursor ?? null, diff --git a/src/features/dashboard/common/envd-version.tsx b/src/features/dashboard/common/envd-version.tsx new file mode 100644 index 000000000..6d9cf11f0 --- /dev/null +++ b/src/features/dashboard/common/envd-version.tsx @@ -0,0 +1,39 @@ +import { cn } from '@/lib/utils' +import { isVersionCompatible } from '@/lib/utils/version' +import HelpTooltip from '@/ui/help-tooltip' + +const INVALID_ENVD_VERSION = '0.0.1' +const SDK_V2_MINIMAL_ENVD_VERSION = '0.2.0' + +export function EnvdVersion({ + version, + className, +}: { + version: string | null | undefined + className?: string +}) { + const versionValue = + version && version !== INVALID_ENVD_VERSION ? version : null + + const isNotV2Compatible = versionValue + ? isVersionCompatible(versionValue, SDK_V2_MINIMAL_ENVD_VERSION) === false + : false + + return ( +
+ {versionValue ?? '--'} + {isNotV2Compatible && ( + + The envd version is not compatible with the SDK v2. To update the envd + version, you need to rebuild the template. + + )} +
+ ) +} diff --git a/src/features/dashboard/templates/builds/table-cells.tsx b/src/features/dashboard/templates/builds/table-cells.tsx index d610f0c62..c918834be 100644 --- a/src/features/dashboard/templates/builds/table-cells.tsx +++ b/src/features/dashboard/templates/builds/table-cells.tsx @@ -19,6 +19,13 @@ import { Badge } from '@/ui/primitives/badge' import { Button } from '@/ui/primitives/button' import { CheckmarkIcon, CloseIcon } from '@/ui/primitives/icons' import { Loader } from '@/ui/primitives/loader' +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from '@/ui/primitives/tooltip' +import { EnvdVersion } from '../../common/envd-version' +import ResourceUsage from '../../common/resource-usage' export function BuildId({ id }: { id: string }) { return ( @@ -107,9 +114,10 @@ export function StartedAt({ timestamp }: { timestamp: number }) { interface StatusProps { status: BuildStatus + statusMessage?: ListedBuildModel['statusMessage'] } -export function Status({ status }: StatusProps) { +export function Status({ status, statusMessage }: StatusProps) { const config: Record< BuildStatus, { @@ -137,31 +145,65 @@ export function Status({ status }: StatusProps) { const { label, icon, variant } = config[status]! + const badge = ( + + {icon} + {label} + + ) + + const showReason = status === 'failed' && Boolean(statusMessage) + return (
- - {icon} - {label} - + {showReason ? ( + + {badge} + + {statusMessage} + + + ) : ( + badge + )}
) } -export function Reason({ - statusMessage, -}: { - statusMessage: ListedBuildModel['statusMessage'] -}) { - if (!statusMessage) return null +export function Cpu({ cpuCount }: { cpuCount: number }) { + return ( +
+ +
+ ) +} +export function Memory({ memoryMB }: { memoryMB: number }) { return ( - - {statusMessage} - +
+ +
+ ) +} + +export function Storage({ diskSizeMB }: { diskSizeMB: number | null }) { + const diskSizeGB = diskSizeMB != null ? diskSizeMB / 1024 : null + return ( +
+ +
+ ) +} + +export function Envd({ version }: { version: string | null }) { + return ( +
+ +
) } diff --git a/src/features/dashboard/templates/builds/table.tsx b/src/features/dashboard/templates/builds/table.tsx index 1f345e5bd..37e6b42c3 100644 --- a/src/features/dashboard/templates/builds/table.tsx +++ b/src/features/dashboard/templates/builds/table.tsx @@ -30,10 +30,13 @@ import { import BuildsEmpty from './empty' import { BuildId, + Cpu, Duration, - Reason, + Envd, + Memory, StartedAt, Status, + Storage, Template, } from './table-cells' import useFilters from './use-filters' @@ -46,6 +49,10 @@ const COLUMN_WIDTHS = { id: 152, status: 96, template: 192, + cpu: 72, + memory: 88, + storage: 88, + envd: 98, started: 126, duration: 96, } as const @@ -163,16 +170,25 @@ const BuildsTable = () => { + + + + + - - + Status Template + ID + CPU + Memory + Storage + ENVD Ver. Started @@ -180,7 +196,6 @@ const BuildsTable = () => { Duration - ID @@ -192,7 +207,7 @@ const BuildsTable = () => { > {showLoader && ( - +
@@ -202,7 +217,7 @@ const BuildsTable = () => { {showEmpty && ( - + @@ -213,7 +228,7 @@ const BuildsTable = () => { {hasScrolledPastInitialPages && ( @@ -247,7 +262,10 @@ const BuildsTable = () => { className="py-1.5" style={{ maxWidth: COLUMN_WIDTHS.status }} > - + { templateId={build.templateId} /> + + + + + + + + + + + + + + + @@ -268,15 +304,7 @@ const BuildsTable = () => { isBuilding={isBuilding} />
- - - - - - +
) })} @@ -284,7 +312,7 @@ const BuildsTable = () => { {hasNextPage && ( ) { - const cpuCount = row.getValue('cpuCount') as number - return ( -
- -
- ) -} - -export function MemoryCell({ - row, -}: CellContext