Confirm on deletion

This commit is contained in:
Adria Navarro 2025-03-19 09:42:18 +01:00
parent 83d6d5aeab
commit 211b0144f8
2 changed files with 17 additions and 7 deletions

View File

@ -11,6 +11,7 @@ export async function confirm(props: {
onConfirm?: () => void
onCancel?: () => void
onClose?: () => void
warning?: boolean
}) {
return await new Promise(resolve => {
const dialog = new ConfirmDialog({
@ -21,7 +22,7 @@ export async function confirm(props: {
okText: props.okText,
cancelText: props.cancelText,
size: props.size,
warning: false,
warning: props.warning,
onOk: () => {
dialog.$destroy()
resolve(props.onConfirm?.() || true)

View File

@ -9,6 +9,7 @@
} from "@budibase/bbui"
import type { OAuth2Config } from "@budibase/types"
import OAuth2ConfigModalContent from "./OAuth2ConfigModalContent.svelte"
import { confirm } from "@/helpers"
export let row: OAuth2Config
@ -18,12 +19,20 @@
modal.show()
}
async function onDelete() {
try {
await oauth2.delete(row.id)
notifications.success(`Config '${row.name}' deleted successfully`)
} catch (e: any) {
notifications.error("Error deleting config")
}
await confirm({
title: "Confirm Deletion",
body: `Deleting "${row.name}" cannot be undone. Are you sure?`,
okText: "Delete Configuration",
warning: true,
onConfirm: async () => {
try {
await oauth2.delete(row.id)
notifications.success(`Config '${row.name}' deleted successfully`)
} catch (e: any) {
notifications.error("Error deleting config")
}
},
})
}
</script>