import Link from 'next/link'; import { Eye, Trash2, Pen, Play, Pause, Cog, X } from 'lucide-react'; import { Button } from '@headlessui/react'; import { openConfirm } from '@/components/ConfirmModal'; import { Job } from '@prisma/client'; import { startJob, stopJob, deleteJob, getAvaliableJobActions, markJobAsStopped } from '@/utils/jobs'; import { startQueue } from '@/utils/queue'; import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react'; import { redirect } from 'next/navigation'; interface JobActionBarProps { job: Job; onRefresh?: () => void; afterDelete?: () => void; hideView?: boolean; className?: string; autoStartQueue?: boolean; } export default function JobActionBar({ job, onRefresh, afterDelete, className, hideView, autoStartQueue = false, }: JobActionBarProps) { const { canStart, canStop, canDelete, canEdit, canRemoveFromQueue } = getAvaliableJobActions(job); if (!afterDelete) afterDelete = onRefresh; return (
{canStart && ( )} {canRemoveFromQueue && ( )} {canStop && ( )} {!hideView && ( )} {canEdit && ( )}
Clone Job
{ let message = `Are you sure you want to mark this job as stopped? This will set the job status to 'stopped' if the status is hung. Only do this if you are 100% sure the job is stopped. This will NOT stop the job.`; openConfirm({ title: 'Mark Job as Stopped', message: message, type: 'warning', confirmText: 'Mark as Stopped', onConfirm: async () => { await markJobAsStopped(job.id); onRefresh && onRefresh(); }, }); }} > Mark as Stopped
); }