@@ -13,7 +13,6 @@ import { Outlet, useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
1313import {
1414 apiQueryClient ,
1515 useApiMutation ,
16- useApiQuery ,
1716 useApiQueryClient ,
1817 usePrefetchedApiQuery ,
1918 type FloatingIp ,
@@ -28,8 +27,8 @@ import { getProjectSelector, useProjectSelector } from '~/hooks/use-params'
2827import { confirmAction } from '~/stores/confirm-action'
2928import { confirmDelete } from '~/stores/confirm-delete'
3029import { addToast } from '~/stores/toast'
31- import { EmptyCell } from '~/table/cells/EmptyCell'
3230import { InstanceLinkCell } from '~/table/cells/InstanceLinkCell'
31+ import { IpPoolCell } from '~/table/cells/IpPoolCell'
3332import { useColsWithActions , type MenuAction } from '~/table/columns/action-col'
3433import { Columns } from '~/table/columns/common'
3534import { PAGE_SIZE , useQueryTable } from '~/table/QueryTable'
@@ -39,7 +38,6 @@ import { Message } from '~/ui/lib/Message'
3938import { Modal } from '~/ui/lib/Modal'
4039import { PageHeader , PageTitle } from '~/ui/lib/PageHeader'
4140import { TableActions } from '~/ui/lib/Table'
42- import { Tooltip } from '~/ui/lib/Tooltip'
4341import { ALL_ISH } from '~/util/consts'
4442import { docLinks } from '~/util/links'
4543import { pb } from '~/util/path-builder'
@@ -63,6 +61,9 @@ FloatingIpsPage.loader = async ({ params }: LoaderFunctionArgs) => {
6361 apiQueryClient . prefetchQuery ( 'instanceList' , {
6462 query : { project } ,
6563 } ) ,
64+ // fetch IP Pools and preload into RQ cache so fetches by ID in
65+ // IpPoolCell can be mostly instant yet gracefully fall back to
66+ // fetching individually if we don't fetch them all here
6667 apiQueryClient
6768 . fetchQuery ( 'projectIpPoolList' , { query : { limit : ALL_ISH } } )
6869 . then ( ( pools ) => {
@@ -78,18 +79,6 @@ FloatingIpsPage.loader = async ({ params }: LoaderFunctionArgs) => {
7879 return null
7980}
8081
81- const IpPoolCell = ( { ipPoolId } : { ipPoolId : string } ) => {
82- const pool = useApiQuery ( 'projectIpPoolView' , { path : { pool : ipPoolId } } ) . data
83- if ( ! pool ) return < EmptyCell />
84- return pool . description ? (
85- < Tooltip content = { pool . description } placement = "right" >
86- < span > { pool . name } </ span >
87- </ Tooltip >
88- ) : (
89- < > { pool . name } </ >
90- )
91- }
92-
9382const colHelper = createColumnHelper < FloatingIp > ( )
9483const staticCols = [
9584 colHelper . accessor ( 'name' , { } ) ,
@@ -98,12 +87,12 @@ const staticCols = [
9887 header : 'IP address' ,
9988 } ) ,
10089 colHelper . accessor ( 'ipPoolId' , {
101- cell : ( info ) => < IpPoolCell ipPoolId = { info . getValue ( ) } /> ,
10290 header : 'IP pool' ,
91+ cell : ( info ) => < IpPoolCell ipPoolId = { info . getValue ( ) } /> ,
10392 } ) ,
10493 colHelper . accessor ( 'instanceId' , {
105- cell : ( info ) => < InstanceLinkCell instanceId = { info . getValue ( ) } /> ,
10694 header : 'Attached to instance' ,
95+ cell : ( info ) => < InstanceLinkCell instanceId = { info . getValue ( ) } /> ,
10796 } ) ,
10897]
10998
0 commit comments