Skip to content

Commit 264e2cd

Browse files
authored
Don't prefetch IP pools for floating IP create (#1969)
don't prefetch IP pools for floating IP create
1 parent 3ec255f commit 264e2cd

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

app/forms/floating-ip-create.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import { useNavigate } from 'react-router-dom'
1111
import type { SetRequired } from 'type-fest'
1212

1313
import {
14-
apiQueryClient,
1514
useApiMutation,
15+
useApiQuery,
1616
useApiQueryClient,
17-
usePrefetchedApiQuery,
1817
type FloatingIpCreate,
1918
type SiloIpPool,
2019
} from '@oxide/api'
@@ -32,13 +31,6 @@ import {
3231
import { useForm, useProjectSelector, useToast } from 'app/hooks'
3332
import { pb } from 'app/util/path-builder'
3433

35-
CreateFloatingIpSideModalForm.loader = async () => {
36-
await apiQueryClient.prefetchQuery('projectIpPoolList', {
37-
query: { limit: 1000 },
38-
})
39-
return null
40-
}
41-
4234
const toListboxItem = (p: SiloIpPool) => {
4335
if (!p.isDefault) {
4436
return { value: p.name, label: p.name }
@@ -66,8 +58,9 @@ const defaultValues: SetRequired<FloatingIpCreate, 'address'> = {
6658
}
6759

6860
export function CreateFloatingIpSideModalForm() {
69-
// Fetch 1000 to we can be sure to get them all.
70-
const { data: allPools } = usePrefetchedApiQuery('projectIpPoolList', {
61+
// Fetch 1000 to we can be sure to get them all. Don't bother prefetching
62+
// because the list is hidden under the Advanced accordion.
63+
const { data: allPools } = useApiQuery('projectIpPoolList', {
7164
query: { limit: 1000 },
7265
})
7366

@@ -126,7 +119,7 @@ export function CreateFloatingIpSideModalForm() {
126119

127120
<ListboxField
128121
name="pool"
129-
items={allPools.items.map((p) => toListboxItem(p))}
122+
items={(allPools?.items || []).map((p) => toListboxItem(p))}
130123
label="IP pool"
131124
control={form.control}
132125
placeholder="Select pool"

app/routes.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ export const routes = createRoutesFromElements(
356356
<Route path="floating-ips" handle={{ crumb: 'Floating IPs' }} element={null} />
357357
<Route
358358
path="floating-ips-new"
359-
loader={CreateFloatingIpSideModalForm.loader}
360359
element={<CreateFloatingIpSideModalForm />}
361360
handle={{ crumb: 'New Floating IP' }}
362361
/>

0 commit comments

Comments
 (0)