6
6
* Copyright Oxide Computer Company
7
7
*/
8
8
import { useCallback } from 'react'
9
- import { useNavigate } from 'react-router'
10
9
11
10
import { instanceCan , useApiMutation , type Instance } from '@oxide/api'
12
11
13
12
import { HL } from '~/components/HL'
14
13
import { confirmAction } from '~/stores/confirm-action'
15
14
import { confirmDelete } from '~/stores/confirm-delete'
16
15
import { addToast } from '~/stores/toast'
16
+ import type { MenuAction , MenuActionItem } from '~/table/columns/action-col'
17
17
import { pb } from '~/util/path-builder'
18
18
19
19
import { fancifyStates } from './common'
@@ -50,7 +50,8 @@ export const useMakeInstanceActions = (
50
50
const { onResizeClick } = options
51
51
52
52
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 [ ] => {
54
55
const instanceParams = { path : { instance : instance . name } , query : { project } }
55
56
return [
56
57
{
@@ -116,9 +117,8 @@ export const useMakeInstanceActions = (
116
117
[ project , startInstanceAsync , stopInstanceAsync ]
117
118
)
118
119
119
- const navigate = useNavigate ( )
120
120
const makeMenuActions = useCallback (
121
- ( instance : Instance ) => {
121
+ ( instance : Instance ) : MenuAction [ ] => {
122
122
const instanceParams = { path : { instance : instance . name } , query : { project } }
123
123
return [
124
124
{
@@ -153,9 +153,7 @@ export const useMakeInstanceActions = (
153
153
} ,
154
154
{
155
155
label : 'View serial console' ,
156
- onActivate ( ) {
157
- navigate ( pb . serialConsole ( { project, instance : instance . name } ) )
158
- } ,
156
+ to : pb . serialConsole ( { project, instance : instance . name } ) ,
159
157
} ,
160
158
{
161
159
label : 'Delete' ,
@@ -179,7 +177,7 @@ export const useMakeInstanceActions = (
179
177
// Do not put `options` in here, refer to the property. options is not ref
180
178
// stable. Extra renders here cause the row actions menu to close when it
181
179
// shouldn't, like during polling on instance list.
182
- [ project , deleteInstanceAsync , rebootInstanceAsync , onResizeClick , navigate ]
180
+ [ project , deleteInstanceAsync , rebootInstanceAsync , onResizeClick ]
183
181
)
184
182
185
183
return { makeButtonActions, makeMenuActions }
0 commit comments