Skip to content

Commit 8ba8a89

Browse files
authored
Put back serial console in instance actions (#2590)
put back serial console in instance actions
1 parent d7fd3c4 commit 8ba8a89

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

app/pages/project/instances/actions.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useCallback } from 'react'
9+
import { useNavigate } from 'react-router-dom'
910

1011
import { instanceCan, useApiMutation, type Instance } from '@oxide/api'
1112

1213
import { HL } from '~/components/HL'
1314
import { confirmAction } from '~/stores/confirm-action'
1415
import { confirmDelete } from '~/stores/confirm-delete'
1516
import { addToast } from '~/stores/toast'
17+
import { pb } from '~/util/path-builder'
1618

1719
import { fancifyStates } from './instance/tabs/common'
1820

@@ -114,6 +116,7 @@ export const useMakeInstanceActions = (
114116
[project, startInstanceAsync, stopInstanceAsync]
115117
)
116118

119+
const navigate = useNavigate()
117120
const makeMenuActions = useCallback(
118121
(instance: Instance) => {
119122
const instanceParams = { path: { instance: instance.name }, query: { project } }
@@ -148,6 +151,12 @@ export const useMakeInstanceActions = (
148151
<>Only {fancifyStates(instanceCan.update.states)} instances can be resized</>
149152
),
150153
},
154+
{
155+
label: 'View serial console',
156+
onActivate() {
157+
navigate(pb.serialConsole({ project, instance: instance.name }))
158+
},
159+
},
151160
{
152161
label: 'Delete',
153162
onActivate: confirmDelete({
@@ -170,7 +179,7 @@ export const useMakeInstanceActions = (
170179
// Do not put `options` in here, refer to the property. options is not ref
171180
// stable. Extra renders here cause the row actions menu to close when it
172181
// shouldn't, like during polling on instance list.
173-
[project, deleteInstanceAsync, rebootInstanceAsync, onResizeClick]
182+
[project, deleteInstanceAsync, rebootInstanceAsync, onResizeClick, navigate]
174183
)
175184

176185
return { makeButtonActions, makeMenuActions }

test/e2e/instance-serial.e2e.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright Oxide Computer Company
77
*/
8-
import { expect, test } from './utils'
8+
import { clickRowAction, expect, test } from './utils'
99

1010
test('serial console can connect while starting', async ({ page }) => {
1111
// create an instance
@@ -31,3 +31,14 @@ test('serial console can connect while starting', async ({ page }) => {
3131
// Here it would be nice to test that the serial console connects, but we
3232
// can't mock websockets with MSW yet: https://github.com/mswjs/msw/pull/2011
3333
})
34+
35+
test('links in instance actions', async ({ page }) => {
36+
await page.goto('/projects/mock-project/instances')
37+
await clickRowAction(page, 'db1', 'View serial console')
38+
await expect(page).toHaveURL('/projects/mock-project/instances/db1/serial-console')
39+
40+
await page.goto('/projects/mock-project/instances/db1')
41+
await page.getByRole('button', { name: 'Instance actions' }).click()
42+
await page.getByRole('menuitem', { name: 'View serial console' }).click()
43+
await expect(page).toHaveURL('/projects/mock-project/instances/db1/serial-console')
44+
})

0 commit comments

Comments
 (0)