Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 31 additions & 34 deletions app/pages/system/networking/IpPoolPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,37 @@ export async function clientLoader({ params }: LoaderFunctionArgs) {

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

function SiloNameFromId({ value: siloId }: { value: string }) {
const { data: silo } = useQuery(q(api.siloView, { path: { silo: siloId } }))

if (!silo) return <SkeletonCell />

return <LinkCell to={pb.siloIpPools({ silo: silo.name })}>{silo.name}</LinkCell>
}

const silosColHelper = createColumnHelper<IpPoolSiloLink>()

const silosCols = [
silosColHelper.accessor('siloId', {
header: 'Silo',
cell: (info) => <SiloNameFromId value={info.getValue()} />,
}),
silosColHelper.accessor('isDefault', {
header: () => {
return (
<span className="inline-flex items-center gap-2">
Silo default
<TipIcon>
When no pool is specified, IPs are allocated from the silo's default pool for
the relevant version and type.
</TipIcon>
</span>
)
},
cell: (info) => (info.getValue() ? <Badge>default</Badge> : null),
}),
]

export default function IpPoolpage() {
const poolSelector = useIpPoolSelector()
const { data: pool } = usePrefetchedQuery(ipPoolView(poolSelector))
Expand Down Expand Up @@ -256,16 +287,6 @@ function IpRangesTable() {
)
}

function SiloNameFromId({ value: siloId }: { value: string }) {
const { data: silo } = useQuery(q(api.siloView, { path: { silo: siloId } }))

if (!silo) return <SkeletonCell />

return <LinkCell to={pb.siloIpPools({ silo: silo.name })}>{silo.name}</LinkCell>
}

const silosColHelper = createColumnHelper<IpPoolSiloLink>()

/** Look up silo name from query cache and return a label for use in modals. */
function getSiloLabel(siloId: string) {
const siloName = queryClient.getQueryData<Silo>(siloView({ silo: siloId }).queryKey)?.name
Expand Down Expand Up @@ -405,30 +426,6 @@ function LinkedSilosTable() {
/>
)

const silosCols = useMemo(
() => [
silosColHelper.accessor('siloId', {
header: 'Silo',
cell: (info) => <SiloNameFromId value={info.getValue()} />,
}),
silosColHelper.accessor('isDefault', {
header: () => {
return (
<span className="inline-flex items-center gap-2">
Silo default
<TipIcon>
When no pool is specified, IPs are allocated from the silo's default pool
for the relevant version and type.
</TipIcon>
</span>
)
},
cell: (info) => (info.getValue() ? <Badge>default</Badge> : null),
}),
],
[]
)

const columns = useColsWithActions(silosCols, makeActions)
const { table } = useQueryTable({
query: ipPoolSiloList(poolSelector),
Expand Down
Loading