Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions src/pages/admin/PoolBatchesView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useCallback, useEffect, useMemo, useState, type FormEvent, type KeyboardEvent } from 'react'
import { useNavigate } from 'react-router-dom'
import { api, type AdminDashboard, type ApiError, type PoolBatch } from '@/lib/api'
import { imageTag } from '@/lib/utils'
import { api, type AdminDashboard, type ApiError, type ImageOption, type PoolBatch } from '@/lib/api'
import { imageLabel, imageTag } from '@/lib/utils'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'

const imageSelectContentStyle = { maxHeight: 'min(18rem, var(--radix-select-content-available-height))' }

function formatCreatedAt(value: string) {
return new Date(value).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' })
Expand All @@ -22,7 +25,7 @@ export function PoolBatchesView() {
const navigate = useNavigate()
const [batches, setBatches] = useState<PoolBatch[]>([])
const [dashboard, setDashboard] = useState<AdminDashboard | null>(null)
const [images, setImages] = useState<Array<{ tag: string; image: string; latest?: boolean }>>([])
const [images, setImages] = useState<ImageOption[]>([])
const [label, setLabel] = useState('')
const [count, setCount] = useState('')
const [selectedImage, setSelectedImage] = useState('')
Expand Down Expand Up @@ -155,13 +158,23 @@ export function PoolBatchesView() {
</div>
<div>
<label className="p-label" htmlFor="pool-image">VTA image</label>
<select id="pool-image" className="p-select p-mono" value={selectedImage}
onChange={event => setSelectedImage(event.target.value)} disabled={creating || images.length === 0}>
{images.length === 0 && <option value="">Loading images…</option>}
{images.map(option => (
<option key={option.image} value={option.image}>{option.tag}{option.latest ? ' (latest)' : ''}</option>
))}
</select>
{images.length > 0 ? (
<Select value={selectedImage} onValueChange={setSelectedImage} disabled={creating}>
<SelectTrigger className="w-full" id="pool-image">
<SelectValue />
</SelectTrigger>
<SelectContent position="popper" align="start"
className="w-(--radix-select-trigger-width)" style={imageSelectContentStyle}>
{images.map(option => (
<SelectItem key={option.image} value={option.image} className="p-mono">
{imageLabel(option)}
</SelectItem>
))}
</SelectContent>
</Select>
) : (
<input id="pool-image" className="p-input p-mono" placeholder="Loading images…" disabled />
)}
</div>
</div>
{error && <p className="pool-form-error">{error}</p>}
Expand Down
Loading