66 * Copyright Oxide Computer Company
77 */
88import { useCallback } from 'react'
9- import { useNavigate } from 'react-router'
109
1110import { instanceCan , useApiMutation , type Instance } from '@oxide/api'
1211
1312import { HL } from '~/components/HL'
1413import { confirmAction } from '~/stores/confirm-action'
1514import { confirmDelete } from '~/stores/confirm-delete'
1615import { addToast } from '~/stores/toast'
16+ import type { MenuAction , MenuActionItem } from '~/table/columns/action-col'
1717import { pb } from '~/util/path-builder'
1818
1919import { fancifyStates } from './common'
@@ -50,7 +50,8 @@ export const useMakeInstanceActions = (
5050 const { onResizeClick } = options
5151
5252 const makeButtonActions = useCallback (
53- ( instance : Instance ) => {
53+ // restrict to items for now so we don't have to handle links in the calling code
54+ ( instance : Instance ) : MenuActionItem [ ] => {
5455 const instanceParams = { path : { instance : instance . name } , query : { project } }
5556 return [
5657 {
@@ -116,9 +117,8 @@ export const useMakeInstanceActions = (
116117 [ project , startInstanceAsync , stopInstanceAsync ]
117118 )
118119
119- const navigate = useNavigate ( )
120120 const makeMenuActions = useCallback (
121- ( instance : Instance ) => {
121+ ( instance : Instance ) : MenuAction [ ] => {
122122 const instanceParams = { path : { instance : instance . name } , query : { project } }
123123 return [
124124 {
@@ -153,9 +153,7 @@ export const useMakeInstanceActions = (
153153 } ,
154154 {
155155 label : 'View serial console' ,
156- onActivate ( ) {
157- navigate ( pb . serialConsole ( { project, instance : instance . name } ) )
158- } ,
156+ to : pb . serialConsole ( { project, instance : instance . name } ) ,
159157 } ,
160158 {
161159 label : 'Delete' ,
@@ -179,7 +177,7 @@ export const useMakeInstanceActions = (
179177 // Do not put `options` in here, refer to the property. options is not ref
180178 // stable. Extra renders here cause the row actions menu to close when it
181179 // shouldn't, like during polling on instance list.
182- [ project , deleteInstanceAsync , rebootInstanceAsync , onResizeClick , navigate ]
180+ [ project , deleteInstanceAsync , rebootInstanceAsync , onResizeClick ]
183181 )
184182
185183 return { makeButtonActions, makeMenuActions }
0 commit comments