Files
Ivan Vasilov 54d11a6a7f feat: Queues v0 (#30300)
* Make the title prop on ProjectIntegrationLayout mandatory. Fix the title on some of the integration pages. Fix wrong layout on wrappers/new.

* Add code for the initial page.

* Make the FilterPopover more type-safe.

* Add a page to list message in a single queue.

* Add feature flag for queues.

* Handle the case where pgmq is not available on the database.

* Minor fixes.

* Some minor fixes.

* Fix the query when fetching only archived messages.

* Fix the filters when there's no choices selected.

* Add a comment for local dev.

* Add a max size to the queue name input.
2024-11-08 13:06:05 +01:00

63 lines
1.7 KiB
TypeScript

import { useRouter } from 'next/router'
import { toast } from 'sonner'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useDatabaseQueueDeleteMutation } from 'data/database-queues/database-queues-delete-mutation'
import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
interface DeleteQueueProps {
queueName: string
visible: boolean
onClose: () => void
}
const DeleteQueue = ({ queueName, visible, onClose }: DeleteQueueProps) => {
const { project } = useProjectContext()
const router = useRouter()
const { mutate: deleteDatabaseQueue, isLoading } = useDatabaseQueueDeleteMutation({
onSuccess: () => {
toast.success(`Successfully removed queue ${queueName}`)
router.push(`/project/${project?.ref}/integrations/queues`)
onClose()
},
})
async function handleDelete() {
if (!project) return console.error('Project is required')
deleteDatabaseQueue({
queueName: queueName,
projectRef: project.ref,
connectionString: project.connectionString,
})
}
if (!queueName) {
return null
}
return (
<TextConfirmModal
variant="destructive"
visible={visible}
onCancel={() => onClose()}
onConfirm={handleDelete}
title="Delete this queue"
loading={isLoading}
confirmLabel={`Delete queue ${queueName}`}
confirmPlaceholder="Type in name of queue"
confirmString={queueName ?? 'Unknown'}
text={
<>
<span>This will delete the queue</span>{' '}
<span className="text-bold text-foreground">{queueName}</span>
</>
}
alert={{ title: 'You cannot recover this queue and its messages once deleted.' }}
/>
)
}
export default DeleteQueue