Skip to content

Commit a68c7c8

Browse files
authored
Show mutation error on snapshot-to-image form (#1779)
pass mutation error to image from snapshot form, require submitError prop
1 parent b2b3a74 commit a68c7c8

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

app/components/form/SideModalForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type SideModalFormProps<TFieldValues extends FieldValues> = {
2929
/** Must be provided with a reason describing why it's disabled */
3030
submitDisabled?: string
3131
/** Error from the API call */
32-
submitError?: ApiError | null
32+
submitError: ApiError | null
3333
loading?: boolean
3434
title: string
3535
subtitle?: ReactNode

app/forms/idp/edit.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export function EditIdpSideModalForm() {
4848
<Access16Icon /> {idp.name}
4949
</ResourceLabel>
5050
}
51+
// TODO: pass actual error when this form is hooked up
52+
submitError={null}
5153
>
5254
<PropertiesTable>
5355
<PropertiesTable.Row label="ID">

app/forms/image-edit.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export function EditImageSideModalForm({
7575
<Images16Icon /> {image.name}
7676
</ResourceLabel>
7777
}
78+
// TODO: pass actual error when this form is hooked up
79+
submitError={null}
7880
>
7981
<PropertiesTable>
8082
<PropertiesTable.Row label="Shared with">{type}</PropertiesTable.Row>

app/forms/image-from-snapshot.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export function CreateImageFromSnapshotSideModalForm() {
7878
body: { ...body, source: { type: 'snapshot', id: data.id } },
7979
})
8080
}
81+
submitError={createImage.error}
8182
>
8283
<PropertiesTable>
8384
<PropertiesTable.Row label="Snapshot">{data.name}</PropertiesTable.Row>

app/test/e2e/snapshots.e2e.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,18 @@ test('Create image from snapshot', async ({ page }) => {
101101
description: 'image description',
102102
})
103103
})
104+
105+
test('Create image from snapshot, name taken', async ({ page }) => {
106+
await page.goto('/projects/mock-project/snapshots')
107+
108+
const row = page.getByRole('row', { name: 'snapshot-1' })
109+
await row.getByRole('button', { name: 'Row actions' }).click()
110+
await page.getByRole('menuitem', { name: 'Create image' }).click()
111+
112+
await expectVisible(page, ['role=dialog[name="Create image from snapshot"]'])
113+
114+
await page.fill('role=textbox[name="Name"]', 'image-1')
115+
await page.click('role=button[name="Create image"]')
116+
117+
await expect(page.getByText('name already exists').nth(0)).toBeVisible()
118+
})

0 commit comments

Comments
 (0)