Files
supabase/apps/studio/components/interfaces/Integrations/Wrappers/DeleteWrapperModal.tsx
T
Ivan Vasilov bff3d56eef fix: Integrations followup - clean up extra files (#30653)
* Remove all extra files obsoleted by integrations redesign.

* Move all wrappers files into integrations/wrappers.

* Move the Vault files into Integrations.

* Move all Queues files into the correct folder.

* Move all CronJobs related files into the correct folder.

* Change the case of the CronJobsTab file.

* Add a comment and a correct URL to the vault.
2024-11-26 01:15:25 +08:00

58 lines
1.8 KiB
TypeScript

import { toast } from 'sonner'
import { Modal } from 'ui'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useFDWDeleteMutation } from 'data/fdw/fdw-delete-mutation'
import type { FDW } from 'data/fdw/fdws-query'
import { getWrapperMetaForWrapper } from './Wrappers.utils'
interface DeleteWrapperModalProps {
selectedWrapper?: FDW
onClose: () => void
}
const DeleteWrapperModal = ({ selectedWrapper, onClose }: DeleteWrapperModalProps) => {
const { project } = useProjectContext()
const { mutate: deleteFDW, isLoading: isDeleting } = useFDWDeleteMutation({
onSuccess: () => {
toast.success(`Successfully disabled ${selectedWrapper?.name} foreign data wrapper`)
onClose()
},
})
const wrapperMeta = getWrapperMetaForWrapper(selectedWrapper)
const onConfirmDelete = async () => {
if (!project?.ref) return console.error('Project ref is required')
if (!selectedWrapper) return console.error('Wrapper is required')
if (!wrapperMeta) return console.error('Wrapper meta is required')
deleteFDW({
projectRef: project?.ref,
connectionString: project?.connectionString,
wrapper: selectedWrapper,
wrapperMeta: wrapperMeta,
})
}
return (
<Modal
size="medium"
alignFooter="right"
loading={isDeleting}
visible={selectedWrapper !== undefined}
onCancel={() => onClose()}
onConfirm={() => onConfirmDelete()}
header={`Confirm to disable ${selectedWrapper?.name}`}
>
<Modal.Content>
<p className="text-sm">
Are you sure you want to disable {selectedWrapper?.name}? This will also remove all tables
created with this wrapper.
</p>
</Modal.Content>
</Modal>
)
}
export default DeleteWrapperModal