The header menu had Tasks but nothing for the schedules whose results land in that conversation. It now has Schedules, right under Tasks, opened in a modal that lists only what runs there: a bot's own chat holds the routines that run nowhere, a workspace only that bot's routines in it (`routineScopeSql`, tested against SQLite). The list loads when the modal opens, through `api/admin/bots/list-routines`, which checks the user chats in that conversation first, so the page props stay small. `grabCronJobs` gained an optional `workspace_id`: left out it still means everywhere. The routines page's row, form and edit modal moved to `src/components/general/`, and its subtitle to `src/utils/`, since both the page and the modal use them.
29 lines
957 B
TypeScript
29 lines
957 B
TypeScript
import AddModalShell from "@/src/layouts/bots/(partials)/add-modal-shell";
|
|
import type { CronJobWithNames } from "@/src/types";
|
|
import RoutineForm from "./routine-form";
|
|
|
|
type Props = {
|
|
/**
|
|
* Open while set.
|
|
*/
|
|
cron_job?: CronJobWithNames;
|
|
onClose: () => void;
|
|
onSaved: (params: { cron_job: CronJobWithNames }) => void;
|
|
};
|
|
|
|
/**
|
|
* Edits a routine in a modal: its name, schedule and brief.
|
|
*/
|
|
export default function RoutineEditModal({ cron_job, onClose, onSaved }: Props) {
|
|
return (
|
|
<AddModalShell
|
|
open={Boolean(cron_job)}
|
|
setOpen={(open) => !open && onClose()}
|
|
title={`Edit ${cron_job?.title || "the routine"}`}
|
|
description={`${cron_job?.bot_name || "The bot"} gets the brief as a task at every run.`}
|
|
>
|
|
{cron_job ? <RoutineForm key={cron_job.id} cron_job={cron_job} onCancel={onClose} onSaved={onSaved} /> : null}
|
|
</AddModalShell>
|
|
);
|
|
}
|