Skip to content

Commit a02b888

Browse files
authored
minor: move ip pool page table columns out to static var (#3152)
Saw this while doing #3146, didn't want to add to that diff.
1 parent 90b26fb commit a02b888

1 file changed

Lines changed: 31 additions & 34 deletions

File tree

app/pages/system/networking/IpPoolPage.tsx

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,37 @@ export async function clientLoader({ params }: LoaderFunctionArgs) {
101101

102102
export const handle = makeCrumb((p) => p.pool!)
103103

104+
function SiloNameFromId({ value: siloId }: { value: string }) {
105+
const { data: silo } = useQuery(q(api.siloView, { path: { silo: siloId } }))
106+
107+
if (!silo) return <SkeletonCell />
108+
109+
return <LinkCell to={pb.siloIpPools({ silo: silo.name })}>{silo.name}</LinkCell>
110+
}
111+
112+
const silosColHelper = createColumnHelper<IpPoolSiloLink>()
113+
114+
const silosCols = [
115+
silosColHelper.accessor('siloId', {
116+
header: 'Silo',
117+
cell: (info) => <SiloNameFromId value={info.getValue()} />,
118+
}),
119+
silosColHelper.accessor('isDefault', {
120+
header: () => {
121+
return (
122+
<span className="inline-flex items-center gap-2">
123+
Silo default
124+
<TipIcon>
125+
When no pool is specified, IPs are allocated from the silo's default pool for
126+
the relevant version and type.
127+
</TipIcon>
128+
</span>
129+
)
130+
},
131+
cell: (info) => (info.getValue() ? <Badge>default</Badge> : null),
132+
}),
133+
]
134+
104135
export default function IpPoolpage() {
105136
const poolSelector = useIpPoolSelector()
106137
const { data: pool } = usePrefetchedQuery(ipPoolView(poolSelector))
@@ -256,16 +287,6 @@ function IpRangesTable() {
256287
)
257288
}
258289

259-
function SiloNameFromId({ value: siloId }: { value: string }) {
260-
const { data: silo } = useQuery(q(api.siloView, { path: { silo: siloId } }))
261-
262-
if (!silo) return <SkeletonCell />
263-
264-
return <LinkCell to={pb.siloIpPools({ silo: silo.name })}>{silo.name}</LinkCell>
265-
}
266-
267-
const silosColHelper = createColumnHelper<IpPoolSiloLink>()
268-
269290
/** Look up silo name from query cache and return a label for use in modals. */
270291
function getSiloLabel(siloId: string) {
271292
const siloName = queryClient.getQueryData<Silo>(siloView({ silo: siloId }).queryKey)?.name
@@ -405,30 +426,6 @@ function LinkedSilosTable() {
405426
/>
406427
)
407428

408-
const silosCols = useMemo(
409-
() => [
410-
silosColHelper.accessor('siloId', {
411-
header: 'Silo',
412-
cell: (info) => <SiloNameFromId value={info.getValue()} />,
413-
}),
414-
silosColHelper.accessor('isDefault', {
415-
header: () => {
416-
return (
417-
<span className="inline-flex items-center gap-2">
418-
Silo default
419-
<TipIcon>
420-
When no pool is specified, IPs are allocated from the silo's default pool
421-
for the relevant version and type.
422-
</TipIcon>
423-
</span>
424-
)
425-
},
426-
cell: (info) => (info.getValue() ? <Badge>default</Badge> : null),
427-
}),
428-
],
429-
[]
430-
)
431-
432429
const columns = useColsWithActions(silosCols, makeActions)
433430
const { table } = useQueryTable({
434431
query: ipPoolSiloList(poolSelector),

0 commit comments

Comments
 (0)