Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions app/pages/project/instances/instance/tabs/StorageTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function Component() {
[instanceName, project]
)

const { mutate: detachDisk } = useApiMutation('instanceDiskDetach', {
const { mutateAsync: detachDisk } = useApiMutation('instanceDiskDetach', {
onSuccess(disk) {
queryClient.invalidateQueries('instanceDiskList')
addToast(<>Disk <HL>{disk.name}</HL> detached</>) // prettier-ignore
Expand Down Expand Up @@ -257,9 +257,15 @@ export function Component() {
detached
</>
),
onActivate() {
detachDisk({ body: { disk: disk.name }, path: { instance: instance.id } })
},
onActivate: () =>
confirmAction({
doAction: () =>
detachDisk({ body: { disk: disk.name }, path: { instance: instance.id } }),
errorTitle: 'Could not detach disk',
modalTitle: 'Confirm detach disk',
modalContent: <p>Are you sure you want to detach <HL>{disk.name}</HL>?</p>, // prettier-ignore
actionType: 'danger',
}),
},
],
[detachDisk, instanceUpdate, instance, getSnapshotAction, bootDisks, ncpus, memory]
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/instance-disks.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ test('Detach disk', async ({ page }) => {
await expect(successMsg).toBeHidden()

await clickRowAction(page, 'disk-2', 'Detach')
await page.getByRole('button', { name: 'Confirm' }).click()
await expect(successMsg).toBeVisible()
await expect(row).toBeHidden() // disk row goes away
})
Expand Down Expand Up @@ -202,6 +203,7 @@ test('Change boot disk', async ({ page }) => {

// detach disk so there's only one
await clickRowAction(page, 'disk-2', 'Detach')
await page.getByRole('button', { name: 'Confirm' }).click()

await expect(page.getByText('Instance will boot from disk-1')).toBeVisible()

Expand All @@ -219,6 +221,8 @@ test('Change boot disk', async ({ page }) => {
await expectRowVisible(otherDisksTable, disk1)

await clickRowAction(page, 'disk-1', 'Detach')
await page.getByRole('button', { name: 'Confirm' }).click()

await expect(noBootDisk).toBeVisible()
await expect(noOtherDisks).toBeVisible()

Expand Down
Loading