1
+ import * as Yup from 'yup'
2
+ import { useNavigate } from 'react-router-dom'
1
3
import invariant from 'tiny-invariant'
2
4
3
5
import type {
@@ -80,6 +82,7 @@ export default function CreateInstanceForm({
80
82
onError,
81
83
...props
82
84
} : CreateFullPageFormProps < InstanceCreateInput , Instance > ) {
85
+ const navigate = useNavigate ( )
83
86
const queryClient = useApiQueryClient ( )
84
87
const addToast = useToast ( )
85
88
const pageParams = useParams ( 'orgName' , 'projectName' )
@@ -116,6 +119,12 @@ export default function CreateInstanceForm({
116
119
initialValues = { initialValues }
117
120
title = { title }
118
121
icon = { < Instances24Icon /> }
122
+ validationSchema = { Yup . object ( {
123
+ // needed to cover case where there are no images, in which case there
124
+ // are no individual radio fields marked required, which unfortunately
125
+ // is how required radio fields work
126
+ globalImage : Yup . string ( ) . required ( ) ,
127
+ } ) }
119
128
onSubmit = {
120
129
onSubmit ||
121
130
( async ( values ) => {
@@ -218,6 +227,7 @@ export default function CreateInstanceForm({
218
227
< Tabs id = "boot-disk-tabs" aria-describedby = "boot-disk" fullWidth >
219
228
< Tab > Distros</ Tab >
220
229
< Tab . Panel className = "space-y-4" >
230
+ { images . length === 0 && < span > No images found</ span > }
221
231
< ImageSelectField
222
232
id = "boot-disk-image"
223
233
name = "globalImage"
@@ -235,9 +245,13 @@ export default function CreateInstanceForm({
235
245
< DiskSizeField id = "disk-size" label = "Disk size" name = "bootDiskSize" />
236
246
</ Tab . Panel >
237
247
< Tab > Images</ Tab >
238
- < Tab . Panel > </ Tab . Panel >
248
+ < Tab . Panel >
249
+ < span > No images found</ span >
250
+ </ Tab . Panel >
239
251
< Tab > Snapshots</ Tab >
240
- < Tab . Panel > </ Tab . Panel >
252
+ < Tab . Panel >
253
+ < span > No snapshots found</ span >
254
+ </ Tab . Panel >
241
255
</ Tabs >
242
256
< Divider />
243
257
< Form . Heading id = "additional-disks" > Additional disks</ Form . Heading >
@@ -255,7 +269,8 @@ export default function CreateInstanceForm({
255
269
< Form . Submit loading = { createDisk . isLoading || createInstance . isLoading } >
256
270
{ title }
257
271
</ Form . Submit >
258
- < Form . Cancel />
272
+ { /* TODO: this nav may not always be correct. Could get rid of the button instead. */ }
273
+ < Form . Cancel onClick = { ( ) => navigate ( '..' ) } />
259
274
</ Form . Actions >
260
275
</ FullPageForm >
261
276
)
0 commit comments