mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 20:05:06 +03:00
* Add settings for queues: toggle expose through postgrest + permissions via table privileges * Ensure appropriate grants are granted when toggling, and revoked when disabling * Update to use queues_public schema * Update queue schema to pgmq_public and add/remove from data api when enabling/disabling * Fix query for retrieving toggle state * Add schema invalidation * Remove hard code * Use QueuesSettings from Queues folder, remove from NewQueues * Update SQL for toggling exposure + support RLS enabling * Support toggling RLS for a queue * Update admonition copy in queues for enabling/disable postgrest exposure * Add custom RLS policy for queue * Minor style fixes * Fix * Remove hard code * Update RLS to add message regarding relevancy only if exposure to PostgREST is enabled * Update message in exposing queues to postgREST * Address feedback * Address feedback * Don't revoke postgres role stuff * Remove hard code * Update copy * Update * Address Oli's feedback, ensure that queues ALL have RLS enabled prior to allowing exposure to PostgREST * Address remaining feedback * Remove hardcode * Update * Address feedback
63 lines
1.7 KiB
TypeScript
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/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
|