Skip to content

Commit c04d9f8

Browse files
committed
fix size validation on disk create from 1023 GiB snapshot
1 parent 2fa9b42 commit c04d9f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/forms/disk-create.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useController, useForm, type Control } from 'react-hook-form'
1111
import { useNavigate, type NavigateFunction } from 'react-router'
1212

1313
import {
14+
MAX_DISK_SIZE_GiB,
1415
useApiMutation,
1516
useApiQuery,
1617
useApiQueryClient,
@@ -228,7 +229,7 @@ const DiskSourceField = ({
228229
const imageSizeGiB = image.size / GiB
229230
if (diskSizeField.value < imageSizeGiB) {
230231
const nearest10 = Math.ceil(imageSizeGiB / 10) * 10
231-
diskSizeField.onChange(nearest10)
232+
diskSizeField.onChange(Math.min(nearest10, MAX_DISK_SIZE_GiB))
232233
}
233234
}}
234235
/>
@@ -289,7 +290,7 @@ const SnapshotSelectField = ({ control }: { control: Control<DiskCreate> }) => {
289290
const snapshotSizeGiB = snapshot.size / GiB
290291
if (diskSizeField.value < snapshotSizeGiB) {
291292
const nearest10 = Math.ceil(snapshotSizeGiB / 10) * 10
292-
diskSizeField.onChange(nearest10)
293+
diskSizeField.onChange(Math.min(nearest10, MAX_DISK_SIZE_GiB))
293294
}
294295
}}
295296
/>

0 commit comments

Comments
 (0)