Skip to content

Commit 1e86154

Browse files
committed
put in missing quick actions on VPC child tabs
1 parent c53101e commit 1e86154

3 files changed

Lines changed: 53 additions & 2 deletions

File tree

app/pages/project/vpcs/VpcFirewallRulesTab.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import { ListPlusCell } from '~/components/ListPlusCell'
2323
import { ProtocolBadge } from '~/components/ProtocolBadge'
2424
import { getVpcSelector, useVpcSelector } from '~/hooks/use-params'
25+
import { useQuickActions } from '~/hooks/use-quick-actions'
2526
import { confirmDelete } from '~/stores/confirm-delete'
2627
import { EnabledCell } from '~/table/cells/EnabledCell'
2728
import { LinkCell } from '~/table/cells/LinkCell'
@@ -169,6 +170,22 @@ export default function VpcFirewallRulesTab() {
169170

170171
const table = useReactTable({ columns, data: rules, getCoreRowModel: getCoreRowModel() })
171172

173+
useQuickActions(
174+
() => [
175+
{
176+
value: 'New firewall rule',
177+
navGroup: 'Actions',
178+
action: pb.vpcFirewallRulesNew(vpcSelector),
179+
},
180+
...rules.map((r) => ({
181+
value: r.name,
182+
navGroup: 'Edit firewall rule',
183+
action: pb.vpcFirewallRuleEdit({ ...vpcSelector, rule: r.name }),
184+
})),
185+
],
186+
[vpcSelector, rules]
187+
)
188+
172189
const emptyState = (
173190
<TableEmptyBox>
174191
<EmptyMessage

app/pages/project/vpcs/VpcRoutersTab.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { api, getListQFn, q, queryClient, useApiMutation, type VpcRouter } from
1414
import { HL } from '~/components/HL'
1515
import { routeFormMessage } from '~/forms/vpc-router-route-common'
1616
import { getVpcSelector, useVpcSelector } from '~/hooks/use-params'
17+
import { useQuickActions } from '~/hooks/use-quick-actions'
1718
import { confirmDelete } from '~/stores/confirm-delete'
1819
import { addToast } from '~/stores/toast'
1920
import { makeLinkCell } from '~/table/cells/LinkCell'
@@ -103,12 +104,28 @@ export default function VpcRoutersTab() {
103104
)
104105

105106
const columns = useColsWithActions(staticColumns, makeActions)
106-
const { table } = useQueryTable({
107+
const { table, query } = useQueryTable({
107108
query: vpcRouterList({ project, vpc }),
108109
columns,
109110
emptyState,
110111
})
111112

113+
useQuickActions(
114+
() => [
115+
{
116+
value: 'New router',
117+
navGroup: 'Actions',
118+
action: pb.vpcRoutersNew({ project, vpc }),
119+
},
120+
...(query.data?.items || []).map((r) => ({
121+
value: r.name,
122+
navGroup: 'Edit router',
123+
action: pb.vpcRouterEdit({ project, vpc, router: r.name }),
124+
})),
125+
],
126+
[project, vpc, query.data]
127+
)
128+
112129
return (
113130
<>
114131
<div className="mb-3 flex justify-end space-x-2">

app/pages/project/vpcs/VpcSubnetsTab.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Outlet, type LoaderFunctionArgs } from 'react-router'
1212
import { api, getListQFn, queryClient, useApiMutation, type VpcSubnet } from '@oxide/api'
1313

1414
import { getVpcSelector, useVpcSelector } from '~/hooks/use-params'
15+
import { useQuickActions } from '~/hooks/use-quick-actions'
1516
import { confirmDelete } from '~/stores/confirm-delete'
1617
import { addToast } from '~/stores/toast'
1718
import { makeLinkCell } from '~/table/cells/LinkCell'
@@ -96,13 +97,29 @@ export default function VpcSubnetsTab() {
9697
/>
9798
)
9899

99-
const { table } = useQueryTable({
100+
const { table, query } = useQueryTable({
100101
query: subnetList(vpcSelector),
101102
columns,
102103
emptyState,
103104
rowHeight: 'large',
104105
})
105106

107+
useQuickActions(
108+
() => [
109+
{
110+
value: 'New VPC subnet',
111+
navGroup: 'Actions',
112+
action: pb.vpcSubnetsNew(vpcSelector),
113+
},
114+
...(query.data?.items || []).map((s) => ({
115+
value: s.name,
116+
navGroup: 'Edit VPC subnet',
117+
action: pb.vpcSubnetsEdit({ ...vpcSelector, subnet: s.name }),
118+
})),
119+
],
120+
[vpcSelector, query.data]
121+
)
122+
106123
return (
107124
<>
108125
<div className="mb-3 flex justify-end space-x-2">

0 commit comments

Comments
 (0)