Skip to content

Commit c98d27b

Browse files
committed
Add more quick actions throughout console
1 parent 1e86154 commit c98d27b

9 files changed

Lines changed: 159 additions & 0 deletions

File tree

app/pages/project/instances/NetworkingTab.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
useInstanceSelector,
4646
useProjectSelector,
4747
} from '~/hooks/use-params'
48+
import { useQuickActions } from '~/hooks/use-quick-actions'
4849
import { confirmAction } from '~/stores/confirm-action'
4950
import { confirmDelete } from '~/stores/confirm-delete'
5051
import { addToast } from '~/stores/toast'
@@ -636,6 +637,53 @@ export default function NetworkingTab() {
636637
const subnetDisabledReason =
637638
availableSubnets.length === 0 ? 'No available external subnets' : null
638639

640+
useQuickActions(
641+
() => [
642+
...(!ephemeralDisabledReason
643+
? [
644+
{
645+
value: 'Attach ephemeral IP',
646+
navGroup: 'Actions',
647+
action: () => setAttachEphemeralModalOpen(true),
648+
},
649+
]
650+
: []),
651+
...(!floatingDisabledReason
652+
? [
653+
{
654+
value: 'Attach floating IP',
655+
navGroup: 'Actions',
656+
action: () => setAttachFloatingModalOpen(true),
657+
},
658+
]
659+
: []),
660+
...(instanceCan.updateNic({ runState: instance.runState })
661+
? [
662+
{
663+
value: 'Add network interface',
664+
navGroup: 'Actions',
665+
action: () => setCreateModalOpen(true),
666+
},
667+
]
668+
: []),
669+
...(!subnetDisabledReason
670+
? [
671+
{
672+
value: 'Attach external subnet',
673+
navGroup: 'Actions',
674+
action: () => setAttachSubnetModalOpen(true),
675+
},
676+
]
677+
: []),
678+
],
679+
[
680+
ephemeralDisabledReason,
681+
floatingDisabledReason,
682+
instance.runState,
683+
subnetDisabledReason,
684+
]
685+
)
686+
639687
return (
640688
<div className="space-y-5">
641689
<CardBlock>

app/pages/project/instances/StorageTab.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { DiskStateBadge, DiskTypeBadge, ReadOnlyBadge } from '~/components/State
2828
import { AttachDiskModalForm } from '~/forms/disk-attach'
2929
import { CreateDiskSideModalForm } from '~/forms/disk-create'
3030
import { getInstanceSelector, useInstanceSelector } from '~/hooks/use-params'
31+
import { useQuickActions } from '~/hooks/use-quick-actions'
3132
import { DiskDetailSideModal } from '~/pages/project/disks/DiskDetailSideModal'
3233
import { confirmAction } from '~/stores/confirm-action'
3334
import { addToast } from '~/stores/toast'
@@ -339,6 +340,26 @@ export default function StorageTab() {
339340
getCoreRowModel: getCoreRowModel(),
340341
})
341342

343+
const canAttachDisk = instanceCan.attachDisk(instance)
344+
useQuickActions(
345+
() =>
346+
canAttachDisk
347+
? [
348+
{
349+
value: 'Attach existing disk',
350+
navGroup: 'Actions',
351+
action: () => setShowDiskAttach(true),
352+
},
353+
{
354+
value: 'Create disk',
355+
navGroup: 'Actions',
356+
action: () => setShowDiskCreate(true),
357+
},
358+
]
359+
: [],
360+
[canAttachDisk]
361+
)
362+
342363
return (
343364
<div className="space-y-5">
344365
<CardBlock>

app/pages/project/vpcs/RouterPage.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { MoreActionsMenu } from '~/components/MoreActionsMenu'
3131
import { routeFormMessage } from '~/forms/vpc-router-route-common'
3232
import { makeCrumb } from '~/hooks/use-crumbs'
3333
import { getVpcRouterSelector, useVpcRouterSelector } from '~/hooks/use-params'
34+
import { useQuickActions } from '~/hooks/use-quick-actions'
3435
import { confirmAction } from '~/stores/confirm-action'
3536
import { addToast } from '~/stores/toast'
3637
import { TypeValueCell } from '~/table/cells/TypeValueCell'
@@ -176,6 +177,20 @@ export default function RouterPage() {
176177
// https://github.com/oxidecomputer/omicron/blob/914f5fd7d51f9b060dcc0382a30b607e25df49b2/nexus/src/app/vpc_router.rs#L201-L205
177178
const canCreateNewRoute = routerData.kind === 'custom'
178179

180+
useQuickActions(
181+
() =>
182+
canCreateNewRoute
183+
? [
184+
{
185+
value: 'New route',
186+
navGroup: 'Actions',
187+
action: pb.vpcRouterRoutesNew({ project, vpc, router }),
188+
},
189+
]
190+
: [],
191+
[canCreateNewRoute, project, vpc, router]
192+
)
193+
179194
return (
180195
<>
181196
<PageHeader>

app/pages/settings/SSHKeysPage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Key16Icon, Key24Icon } from '@oxide/design-system/icons/react'
1616
import { DocsPopover } from '~/components/DocsPopover'
1717
import { HL } from '~/components/HL'
1818
import { makeCrumb } from '~/hooks/use-crumbs'
19+
import { useQuickActions } from '~/hooks/use-quick-actions'
1920
import { confirmDelete } from '~/stores/confirm-delete'
2021
import { addToast } from '~/stores/toast'
2122
import { makeLinkCell } from '~/table/cells/LinkCell'
@@ -88,6 +89,11 @@ export default function SSHKeysPage() {
8889
onClick={() => navigate(pb.sshKeysNew())}
8990
/>
9091
)
92+
useQuickActions(
93+
() => [{ value: 'Add SSH key', navGroup: 'Actions', action: pb.sshKeysNew() }],
94+
[]
95+
)
96+
9197
const { table } = useQueryTable({ query: sshKeyList, columns, emptyState })
9298

9399
return (

app/pages/system/FleetAccessPage.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
FleetAccessEditUserSideModal,
3434
} from '~/forms/fleet-access'
3535
import { useCurrentUser } from '~/hooks/use-current-user'
36+
import { useQuickActions } from '~/hooks/use-quick-actions'
3637
import { confirmDelete } from '~/stores/confirm-delete'
3738
import { addToast } from '~/stores/toast'
3839
import { getActionsCol } from '~/table/columns/action-col'
@@ -238,6 +239,17 @@ export default function FleetAccessPage() {
238239
[fleetPolicy, updatePolicy, me, navigate]
239240
)
240241

242+
useQuickActions(
243+
() => [
244+
{
245+
value: 'Add user or group',
246+
navGroup: 'Actions',
247+
action: () => setAddModalOpen(true),
248+
},
249+
],
250+
[]
251+
)
252+
241253
const tableInstance = useReactTable({
242254
columns,
243255
data: rows,

app/pages/system/networking/IpPoolPage.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { MoreActionsMenu } from '~/components/MoreActionsMenu'
3434
import { QueryParamTabs } from '~/components/QueryParamTabs'
3535
import { makeCrumb } from '~/hooks/use-crumbs'
3636
import { getIpPoolSelector, useIpPoolSelector } from '~/hooks/use-params'
37+
import { useQuickActions } from '~/hooks/use-quick-actions'
3738
import { confirmAction } from '~/stores/confirm-action'
3839
import { confirmDelete } from '~/stores/confirm-delete'
3940
import { addToast } from '~/stores/toast'
@@ -272,6 +273,13 @@ function IpRangesTable() {
272273
],
273274
[pool, removeRange]
274275
)
276+
useQuickActions(
277+
() => [
278+
{ value: 'Add range', navGroup: 'Actions', action: pb.ipPoolRangeAdd({ pool }) },
279+
],
280+
[pool]
281+
)
282+
275283
const columns = useColsWithActions(ipRangesStaticCols, makeRangeActions)
276284
const { table } = useQueryTable({ query: ipPoolRangeList({ pool }), columns, emptyState })
277285

@@ -414,6 +422,13 @@ function LinkedSilosTable() {
414422

415423
const [showLinkModal, setShowLinkModal] = useState(false)
416424

425+
useQuickActions(
426+
() => [
427+
{ value: 'Link silo', navGroup: 'Actions', action: () => setShowLinkModal(true) },
428+
],
429+
[]
430+
)
431+
417432
const emptyState = (
418433
<EmptyMessage
419434
icon={<IpGlobal24Icon />}

app/pages/system/networking/SubnetPoolPage.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { MoreActionsMenu } from '~/components/MoreActionsMenu'
3434
import { QueryParamTabs } from '~/components/QueryParamTabs'
3535
import { makeCrumb } from '~/hooks/use-crumbs'
3636
import { getSubnetPoolSelector, useSubnetPoolSelector } from '~/hooks/use-params'
37+
import { useQuickActions } from '~/hooks/use-quick-actions'
3738
import { confirmAction } from '~/stores/confirm-action'
3839
import { confirmDelete } from '~/stores/confirm-delete'
3940
import { addToast } from '~/stores/toast'
@@ -231,6 +232,17 @@ function MembersTable() {
231232
],
232233
[subnetPool, removeMember]
233234
)
235+
useQuickActions(
236+
() => [
237+
{
238+
value: 'Add member',
239+
navGroup: 'Actions',
240+
action: pb.subnetPoolMemberAdd({ subnetPool }),
241+
},
242+
],
243+
[subnetPool]
244+
)
245+
234246
const columns = useColsWithActions(membersStaticCols, makeMemberActions)
235247
const { table } = useQueryTable({
236248
query: subnetPoolMemberList({ subnetPool }),
@@ -396,6 +408,13 @@ function LinkedSilosTable() {
396408

397409
const [showLinkModal, setShowLinkModal] = useState(false)
398410

411+
useQuickActions(
412+
() => [
413+
{ value: 'Link silo', navGroup: 'Actions', action: () => setShowLinkModal(true) },
414+
],
415+
[]
416+
)
417+
399418
const emptyState = (
400419
<EmptyMessage
401420
icon={<Subnet24Icon />}

app/pages/system/silos/SiloIdpsTab.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Badge } from '@oxide/design-system/ui'
1515
import { api, getListQFn, queryClient, type IdentityProvider } from '~/api'
1616
import { makeCrumb } from '~/hooks/use-crumbs'
1717
import { getSiloSelector, useSiloSelector } from '~/hooks/use-params'
18+
import { useQuickActions } from '~/hooks/use-quick-actions'
1819
import { LinkCell } from '~/table/cells/LinkCell'
1920
import { Columns } from '~/table/columns/common'
2021
import { useQueryTable } from '~/table/QueryTable'
@@ -59,6 +60,13 @@ export default function SiloIdpsTab() {
5960
[silo]
6061
)
6162

63+
useQuickActions(
64+
() => [
65+
{ value: 'New provider', navGroup: 'Actions', action: pb.siloIdpsNew({ silo }) },
66+
],
67+
[silo]
68+
)
69+
6270
const { table } = useQueryTable({
6371
query: siloIdpList(silo),
6472
columns,

app/pages/system/silos/SiloScimTab.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
} from '~/api'
2727
import { makeCrumb } from '~/hooks/use-crumbs'
2828
import { getSiloSelector, useSiloSelector } from '~/hooks/use-params'
29+
import { useQuickActions } from '~/hooks/use-quick-actions'
2930
import { confirmDelete } from '~/stores/confirm-delete'
3031
import { addToast } from '~/stores/toast'
3132
import { useColsWithActions, type MenuAction } from '~/table/columns/action-col'
@@ -103,6 +104,20 @@ export default function SiloScimTab() {
103104

104105
const [modalState, setModalState] = useState<ModalState>(false)
105106

107+
useQuickActions(
108+
() =>
109+
tokensResult.type === 'success'
110+
? [
111+
{
112+
value: 'Create token',
113+
navGroup: 'Actions',
114+
action: () => setModalState({ kind: 'create' }),
115+
},
116+
]
117+
: [],
118+
[tokensResult.type]
119+
)
120+
106121
return (
107122
<>
108123
<CardBlock>

0 commit comments

Comments
 (0)