Skip to content

Commit 7c56214

Browse files
authored
Add success toasts for create and delete SSH key (#2188)
toasts for create and delete SSH key
1 parent d2a9345 commit 7c56214

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

app/forms/ssh-key-create.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { NameField } from '~/components/form/fields/NameField'
1414
import { TextField } from '~/components/form/fields/TextField'
1515
import { SideModalForm } from '~/components/form/SideModalForm'
1616
import { useForm } from '~/hooks'
17+
import { addToast } from '~/stores/toast'
1718
import { pb } from '~/util/path-builder'
1819

1920
const defaultValues: SshKeyCreate = {
@@ -22,13 +23,12 @@ const defaultValues: SshKeyCreate = {
2223
publicKey: '',
2324
}
2425

25-
export function CreateSSHKeySideModalForm({
26-
onDismiss,
27-
message,
28-
}: {
26+
type Props = {
2927
onDismiss?: () => void
3028
message?: React.ReactNode
31-
}) {
29+
}
30+
31+
export function CreateSSHKeySideModalForm({ onDismiss, message }: Props) {
3232
const queryClient = useApiQueryClient()
3333
const navigate = useNavigate()
3434

@@ -38,6 +38,7 @@ export function CreateSSHKeySideModalForm({
3838
onSuccess() {
3939
queryClient.invalidateQueries('currentUserSshKeyList')
4040
handleDismiss()
41+
addToast({ content: 'Your SSH key has been created' })
4142
},
4243
})
4344
const form = useForm({ defaultValues })

app/pages/settings/SSHKeysPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { apiQueryClient, useApiMutation, useApiQueryClient, type SshKey } from '
1313
import { Key16Icon, Key24Icon } from '@oxide/design-system/icons/react'
1414

1515
import { confirmDelete } from '~/stores/confirm-delete'
16+
import { addToast } from '~/stores/toast'
1617
import { useColsWithActions, type MenuAction } from '~/table/columns/action-col'
1718
import { Columns } from '~/table/columns/common'
1819
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
@@ -45,6 +46,7 @@ export function SSHKeysPage() {
4546
const deleteSshKey = useApiMutation('currentUserSshKeyDelete', {
4647
onSuccess: () => {
4748
queryClient.invalidateQueries('currentUserSshKeyList')
49+
addToast({ content: 'Your SSH key has been deleted' })
4850
},
4951
})
5052

test/e2e/ssh-keys.e2e.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { test } from '@playwright/test'
99

10-
import { expectNotVisible, expectRowVisible, expectVisible } from './utils'
10+
import { clickRowAction, expectNotVisible, expectRowVisible, expectVisible } from './utils'
1111

1212
test('SSH keys', async ({ page }) => {
1313
await page.goto('/settings/ssh-keys')
@@ -20,14 +20,12 @@ test('SSH keys', async ({ page }) => {
2020
])
2121

2222
// delete the two ssh keys
23-
await page.click('role=button[name="Row actions"]')
24-
await page.click('role=menuitem[name="Delete"]')
23+
await clickRowAction(page, 'm1-macbook-pro', 'Delete')
2524
await page.getByRole('button', { name: 'Confirm' }).click()
2625

2726
await expectNotVisible(page, ['role=cell[name="m1-macbook-pro"]'])
2827

29-
await page.click('role=button[name="Row actions"]')
30-
await page.click('role=menuitem[name="Delete"]')
28+
await clickRowAction(page, 'mac-mini', 'Delete')
3129
await page.getByRole('button', { name: 'Confirm' }).click()
3230

3331
// should show empty state

0 commit comments

Comments
 (0)