Let a conversation's menu show the routines that run in it
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.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import type { CronJobWithNames } from "@/src/types";
|
||||
|
||||
/**
|
||||
* Replaces one routine in a list with its saved version, keeping the order.
|
||||
* Only the row that changed moves, so a pause or an edit never reshuffles
|
||||
* the list under the pointer.
|
||||
*/
|
||||
export function replaceRoutine({
|
||||
routines,
|
||||
cron_job,
|
||||
}: {
|
||||
routines: CronJobWithNames[];
|
||||
cron_job: CronJobWithNames;
|
||||
}): CronJobWithNames[] {
|
||||
return routines.map((item) => (item.id == cron_job.id ? cron_job : item));
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops a deleted routine from a list.
|
||||
*/
|
||||
export function dropRoutine({
|
||||
routines,
|
||||
cron_job_id,
|
||||
}: {
|
||||
routines: CronJobWithNames[];
|
||||
cron_job_id: string | number | undefined;
|
||||
}): CronJobWithNames[] {
|
||||
return routines.filter((item) => item.id != cron_job_id);
|
||||
}
|
||||
Reference in New Issue
Block a user