Fix issue where the job would hang in the ui if it failed to start

This commit is contained in:
Jaret Burkett
2025-03-21 09:46:41 -06:00
parent 6c5eb0cf87
commit 0bbc69c135
4 changed files with 185 additions and 63 deletions

View File

@@ -62,26 +62,34 @@ export default function JobActionBar({ job, onRefresh, afterDelete, className, h
<Pen />
</Link>
)}
{canDelete && (
<Button
onClick={() => {
if (!canDelete) return;
openConfirm({
title: 'Delete Job',
message: `Are you sure you want to delete the job "${job.name}"? This will also permanently remove it from your disk.`,
type: 'warning',
confirmText: 'Delete',
onConfirm: async () => {
await deleteJob(job.id);
if (afterDelete) afterDelete();
},
});
}}
className={`ml-2 opacity-100`}
>
<Trash2 />
</Button>
)}
<Button
onClick={() => {
let message = `Are you sure you want to delete the job "${job.name}"? This will also permanently remove it from your disk.`;
if (job.status === 'running') {
message += ' WARNING: The job is currently running. You should stop it first if you can.';
}
openConfirm({
title: 'Delete Job',
message: message,
type: 'warning',
confirmText: 'Delete',
onConfirm: async () => {
if (job.status === 'running') {
try {
await stopJob(job.id);
} catch (e) {
console.error('Error stopping job before deleting:', e);
}
}
await deleteJob(job.id);
if (afterDelete) afterDelete();
},
});
}}
className={`ml-2 opacity-100`}
>
<Trash2 />
</Button>
</div>
);
}