import { useNavigate } from "react-router-dom";
import { Play, PencilSimple, X } from "@phosphor-icons/react";
import paths from "@/utils/paths";
import { humanizeCron } from "../utils/cron";
import { useTranslation } from "react-i18next";
// One row of the scheduled-jobs list. Clicking the name navigates to the
// run history; CRUD callbacks come from the parent.
export default function JobRow({ job, onTrigger, onToggle, onEdit, onDelete }) {
const navigate = useNavigate();
const { t, i18n } = useTranslation();
// A job has at most one in-flight run; disable "Run now" while it's queued
// or running so users get visible feedback that their click registered and
// so the backend dedup never has to drop a manual trigger silently.
const inFlight =
job.latestRun?.status === "running" || job.latestRun?.status === "queued";
const statusText = job.latestRun
? t(`scheduledJobs.status.${job.latestRun.status}`, job.latestRun.status)
: t("scheduledJobs.row.neverRun");
const stop = (handler) => (e) => {
e.stopPropagation();
handler();
};
return (