Skip to content

Commit 5bee1f5

Browse files
authored
Add IP pools to quick actions (#1936)
add IP pools to quick actions
1 parent 16b5b32 commit 5bee1f5

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

app/pages/system/networking/IpPoolsTab.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
* Copyright Oxide Computer Company
77
*/
88

9+
import { useMemo } from 'react'
910
import { Link, Outlet, useNavigate } from 'react-router-dom'
1011

11-
import { apiQueryClient, useApiMutation, type IpPool } from '@oxide/api'
12+
import {
13+
apiQueryClient,
14+
useApiMutation,
15+
usePrefetchedApiQuery,
16+
type IpPool,
17+
} from '@oxide/api'
1218
import { DateCell, linkCell, useQueryTable, type MenuAction } from '@oxide/table'
1319
import { buttonStyle, EmptyMessage, Networking24Icon } from '@oxide/ui'
1420

21+
import { useQuickActions } from 'app/hooks'
1522
import { confirmDelete } from 'app/stores/confirm-delete'
1623
import { pb } from 'app/util/path-builder'
1724

@@ -33,6 +40,7 @@ IpPoolsTab.loader = async function () {
3340
export function IpPoolsTab() {
3441
const navigate = useNavigate()
3542
const { Table, Column } = useQueryTable('ipPoolList', {})
43+
const { data: pools } = usePrefetchedApiQuery('ipPoolList', { query: { limit: 25 } })
3644

3745
const deletePool = useApiMutation('ipPoolDelete', {
3846
onSuccess() {
@@ -59,6 +67,23 @@ export function IpPoolsTab() {
5967
},
6068
]
6169

70+
useQuickActions(
71+
useMemo(
72+
() => [
73+
{
74+
value: 'New IP pool',
75+
onSelect: () => navigate(pb.projectNew()),
76+
},
77+
...(pools.items || []).map((p) => ({
78+
value: p.name,
79+
onSelect: () => navigate(pb.ipPool({ pool: p.name })),
80+
navGroup: 'Go to IP pool',
81+
})),
82+
],
83+
[navigate, pools]
84+
)
85+
)
86+
6287
return (
6388
<>
6489
<div className="mb-3 flex justify-end space-x-2">

0 commit comments

Comments
 (0)