@@ -13,6 +13,7 @@ import { Outlet, useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
1313import {
1414 apiQueryClient ,
1515 useApiMutation ,
16+ useApiQuery ,
1617 useApiQueryClient ,
1718 usePrefetchedApiQuery ,
1819 type FloatingIp ,
@@ -26,17 +27,20 @@ import { getProjectSelector, useProjectSelector } from '~/hooks'
2627import { confirmAction } from '~/stores/confirm-action'
2728import { confirmDelete } from '~/stores/confirm-delete'
2829import { addToast } from '~/stores/toast'
30+ import { EmptyCell } from '~/table/cells/EmptyCell'
2931import { InstanceLinkCell } from '~/table/cells/InstanceLinkCell'
3032import { useColsWithActions , type MenuAction } from '~/table/columns/action-col'
3133import { Columns } from '~/table/columns/common'
3234import { PAGE_SIZE , useQueryTable } from '~/table/QueryTable'
35+ import { Badge } from '~/ui/lib/Badge'
3336import { CreateLink } from '~/ui/lib/CreateButton'
3437import { EmptyMessage } from '~/ui/lib/EmptyMessage'
3538import { Listbox } from '~/ui/lib/Listbox'
3639import { Message } from '~/ui/lib/Message'
3740import { Modal } from '~/ui/lib/Modal'
3841import { PageHeader , PageTitle } from '~/ui/lib/PageHeader'
3942import { TableActions } from '~/ui/lib/Table'
43+ import { Tooltip } from '~/ui/lib/Tooltip'
4044import { docLinks } from '~/util/links'
4145import { pb } from '~/util/path-builder'
4246
@@ -59,15 +63,45 @@ FloatingIpsPage.loader = async ({ params }: LoaderFunctionArgs) => {
5963 apiQueryClient . prefetchQuery ( 'instanceList' , {
6064 query : { project } ,
6165 } ) ,
66+ apiQueryClient
67+ . fetchQuery ( 'projectIpPoolList' , { query : { limit : 1000 } } )
68+ . then ( ( pools ) => {
69+ for ( const pool of pools . items ) {
70+ apiQueryClient . setQueryData (
71+ 'projectIpPoolView' ,
72+ { path : { pool : pool . id } } ,
73+ pool
74+ )
75+ }
76+ } ) ,
6277 ] )
6378 return null
6479}
6580
81+ const IpPoolCell = ( { ipPoolId } : { ipPoolId : string } ) => {
82+ const pool = useApiQuery ( 'projectIpPoolView' , { path : { pool : ipPoolId } } ) . data
83+ if ( ! pool ) return < EmptyCell />
84+ const badge = < Badge color = "neutral" > { pool . name } </ Badge >
85+ return pool . description ? (
86+ < Tooltip content = { pool . description } placement = "right" >
87+ < span > { badge } </ span >
88+ </ Tooltip >
89+ ) : (
90+ badge
91+ )
92+ }
93+
6694const colHelper = createColumnHelper < FloatingIp > ( )
6795const staticCols = [
6896 colHelper . accessor ( 'name' , { } ) ,
6997 colHelper . accessor ( 'description' , Columns . description ) ,
70- colHelper . accessor ( 'ip' , { } ) ,
98+ colHelper . accessor ( 'ip' , {
99+ header : 'IP address' ,
100+ } ) ,
101+ colHelper . accessor ( 'ipPoolId' , {
102+ cell : ( info ) => < IpPoolCell ipPoolId = { info . getValue ( ) } /> ,
103+ header : 'IP pool' ,
104+ } ) ,
71105 colHelper . accessor ( 'instanceId' , {
72106 cell : ( info ) => < InstanceLinkCell instanceId = { info . getValue ( ) } /> ,
73107 header : 'Attached to instance' ,
0 commit comments