import { getScheduleDeleteCronJobRunDetailsSql } from '@supabase/pg-meta'
import { CheckCircle2, XCircle } from 'lucide-react'
import {
Button,
Dialog,
DialogContent,
DialogHeader,
DialogSection,
DialogSectionSeparator,
DialogTitle,
DialogTrigger,
Progress,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
Tooltip,
TooltipContent,
TooltipTrigger,
} from 'ui'
import { Admonition } from 'ui-patterns/admonition'
import { CodeBlock } from 'ui-patterns/CodeBlock'
import { CLEANUP_INTERVALS } from './CronJobsTab.constants'
import {
useCronJobsCleanupActions,
type BatchDeletionProgress,
} from './CronJobsTab.useCleanupActions'
import { InlineLinkClassName } from '@/components/ui/InlineLink'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
interface CronJobRunDetailsOverflowNoticeV2Props {
queryCost?: number
refetchJobs: () => void
}
export const CronJobRunDetailsOverflowNotice = (props: CronJobRunDetailsOverflowNoticeV2Props) => {
return (
Last run for each cron job omitted due to high query cost
) } const CronJobRunDetailsOverflowDialog = ({ queryCost, refetchJobs, }: CronJobRunDetailsOverflowNoticeV2Props) => { const { data: project } = useSelectedProjectQuery() const { cleanupInterval, cleanupState, isScheduling, isScheduleSuccess, setCleanupInterval, runBatchedDeletion, scheduleCleanup, cancelDeletion, } = useCronJobsCleanupActions({ projectRef: project?.ref, connectionString: project?.connectionString, }) const isDeleting = cleanupState.status === 'deleting' const isDeleteSuccess = cleanupState.status === 'delete-success' const isDeleteError = cleanupState.status === 'delete-error' const isBusy = isDeleting || isScheduling const canSchedule = isDeleteSuccess || isScheduleSuccess return ( ) } interface DeletionProgressProps { progress: BatchDeletionProgress onCancel: () => void } const DeletionProgress = ({ progress, onCancel }: DeletionProgressProps) => { const { currentBatch, totalBatches, totalRowsDeleted } = progress const percentComplete = totalBatches > 0 ? Math.min(Math.round((currentBatch / totalBatches) * 100), 100) : 0 return (New cleanup job should now be visible in the cron jobs overview.