mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 23:59:08 +03:00
* Add crons option in the database menu. * Add react-hook-form to the studio package.json. * Refactor the functionSelector to be used by other features. * Add the bulk of the functionality for the cron UI. Some of the code is copy-pasted from functions feature, needs to be cleaned before merging. * Tons of changes, the Create Cron sheet works now. * Added some more functionality for the cronjob feature. * Convert the Cron table to a listing with cards. * Add click-to-copy in the Auth Hooks feature. * Remove extra prop. * Fix type errors. * Fix some random issues. Fix the tests. * Fix the tests. * Add a style for disabled radio button item. * Make the default SQL snippet. Handle the case pg_net is not installed. * Fix the heading and save button when creating a new cron job. * Change the name of the custom label in the schedule dropdown. * Minor fixes. * Rename all mentions of cronjobs to cron jobs. * Always show the cron jobs link. * Rename the link from crons to cron-jobs. * Fix the disabled state for the stacked radio group. * More minor fixes. * More small fixes. * Fix the tests. * Minor UI tweaks * More minor tweaks * Add padding bottom * Add feature flag for the cron ui. * Fix the SQL function option. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { toast } from 'sonner'
|
|
|
|
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
|
|
import { useDatabaseCronJobDeleteMutation } from 'data/database-cron-jobs/database-cron-jobs-delete-mutation'
|
|
import { CronJob } from 'data/database-cron-jobs/database-cron-jobs-query'
|
|
import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
|
|
|
|
interface DeleteCronJobProps {
|
|
cronJob: CronJob
|
|
visible: boolean
|
|
onClose: () => void
|
|
}
|
|
|
|
const DeleteCronJob = ({ cronJob, visible, onClose }: DeleteCronJobProps) => {
|
|
const { project } = useProjectContext()
|
|
|
|
const { mutate: deleteDatabaseCronJob, isLoading } = useDatabaseCronJobDeleteMutation({
|
|
onSuccess: () => {
|
|
toast.success(`Successfully removed cron job ${cronJob.jobname}`)
|
|
onClose()
|
|
},
|
|
})
|
|
|
|
async function handleDelete() {
|
|
if (!project) return console.error('Project is required')
|
|
|
|
deleteDatabaseCronJob({
|
|
jobId: cronJob.jobid,
|
|
projectRef: project.ref,
|
|
connectionString: project.connectionString,
|
|
})
|
|
}
|
|
|
|
if (!cronJob) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<TextConfirmModal
|
|
variant="warning"
|
|
visible={visible}
|
|
onCancel={() => onClose()}
|
|
onConfirm={handleDelete}
|
|
title="Delete this cron job"
|
|
loading={isLoading}
|
|
confirmLabel={`Delete cron job ${cronJob.jobname}`}
|
|
confirmPlaceholder="Type in name of cron job"
|
|
confirmString={cronJob.jobname ?? 'Unknown'}
|
|
text={
|
|
<>
|
|
<span>This will delete the cron job</span>{' '}
|
|
<span className="text-bold text-foreground">{cronJob.jobname}</span>
|
|
</>
|
|
}
|
|
alert={{ title: 'You cannot recover this cron job once deleted.' }}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default DeleteCronJob
|