6
6
* Copyright Oxide Computer Company
7
7
*/
8
8
import { useCallback } from 'react'
9
+ import { useNavigate } from 'react-router-dom'
9
10
10
11
import { instanceCan, useApiMutation, type Instance } from '@oxide/api'
11
12
12
13
import { HL } from '~/components/HL'
13
14
import { confirmAction } from '~/stores/confirm-action'
14
15
import { confirmDelete } from '~/stores/confirm-delete'
15
16
import { addToast } from '~/stores/toast'
17
+ import { pb } from '~/util/path-builder'
16
18
17
19
import { fancifyStates } from './instance/tabs/common'
18
20
@@ -114,6 +116,7 @@ export const useMakeInstanceActions = (
114
116
[project, startInstanceAsync, stopInstanceAsync]
115
117
)
116
118
119
+ const navigate = useNavigate()
117
120
const makeMenuActions = useCallback(
118
121
(instance: Instance) => {
119
122
const instanceParams = { path: { instance: instance.name }, query: { project } }
@@ -148,6 +151,12 @@ export const useMakeInstanceActions = (
148
151
<>Only {fancifyStates(instanceCan.update.states)} instances can be resized</>
149
152
),
150
153
},
154
+ {
155
+ label: 'View serial console',
156
+ onActivate() {
157
+ navigate(pb.serialConsole({ project, instance: instance.name }))
158
+ },
159
+ },
151
160
{
152
161
label: 'Delete',
153
162
onActivate: confirmDelete({
@@ -170,7 +179,7 @@ export const useMakeInstanceActions = (
170
179
// Do not put `options` in here, refer to the property. options is not ref
171
180
// stable. Extra renders here cause the row actions menu to close when it
172
181
// shouldn't, like during polling on instance list.
173
- [project, deleteInstanceAsync, rebootInstanceAsync, onResizeClick]
182
+ [project, deleteInstanceAsync, rebootInstanceAsync, onResizeClick, navigate ]
174
183
)
175
184
176
185
return { makeButtonActions, makeMenuActions }
0 commit comments