Files
Saxon FletcherandJoshen Lim 6490f6ecdc Refine the integrations page (#38113)
* integrations refine

* refactoring

* integration page updates

* div

* clean up

* prettier

* Couple of minor refactors and fixes

* Fix missing base path for integration card image

* Fix editing a cron job in the previous job run tab, not updating the cron job details in the page header

* Cron job bread crumb to use job name instead of id if available, and add loading state for cron job subtitle

* Fixy fix

* Small fi

* ANother one

* Do not reroute after purging queue

* nit

* Final final final v3

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-08-27 21:18:30 +07:00

61 lines
1.6 KiB
TypeScript

import { toast } from 'sonner'
import { useDatabaseQueuePurgeMutation } from 'data/database-queues/database-queues-purge-mutation'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
interface PurgeQueueProps {
queueName: string
visible: boolean
onClose: () => void
}
export const PurgeQueue = ({ queueName, visible, onClose }: PurgeQueueProps) => {
const { data: project } = useSelectedProjectQuery()
const { mutate: purgeDatabaseQueue, isLoading } = useDatabaseQueuePurgeMutation({
onSuccess: () => {
toast.success(`Successfully purged queue ${queueName}`)
onClose()
},
})
async function handlePurge() {
if (!project) return console.error('Project is required')
purgeDatabaseQueue({
queueName: queueName,
projectRef: project.ref,
connectionString: project.connectionString,
})
}
if (!queueName) {
return null
}
return (
<TextConfirmModal
variant="warning"
visible={visible}
onCancel={() => onClose()}
onConfirm={handlePurge}
title="Purge this queue"
loading={isLoading}
confirmLabel={`Purge queue ${queueName}`}
confirmPlaceholder="Type in name of queue"
confirmString={queueName ?? 'Unknown'}
text={
<>
<span>This will purge the queue</span>{' '}
<span className="text-bold text-foreground">{queueName}</span>
</>
}
alert={{
title:
"This action will delete all messages from the queue. They can't be recovered afterwards.",
}}
/>
)
}