33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
// Configuration and execution provenance are different facts. Never infer a
|
|
// timer-triggered run from its pipeline's current schedules or legacy Markdown.
|
|
export function pipelineScheduleState(pipeline) {
|
|
if (Number.isSafeInteger(pipeline?.schedule_count) && pipeline.schedule_count > 0) return true;
|
|
if (typeof pipeline?.scheduled === "boolean") return pipeline.scheduled;
|
|
if (pipeline?.schedule_count === 0) return false;
|
|
return null;
|
|
}
|
|
|
|
export function runScheduleState(run) {
|
|
if (run?.scheduled === true || (Number.isSafeInteger(run?.schedule_id) && run.schedule_id > 0)) return true;
|
|
return run?.scheduled === false ? false : null;
|
|
}
|
|
|
|
export function matchesScheduleState(state, filter) {
|
|
if (!filter || filter === "any") return true;
|
|
if (filter === "scheduled") return state === true;
|
|
if (filter === "unscheduled") return state === false;
|
|
return true;
|
|
}
|
|
|
|
export function pipelineScheduleLabel(pipeline) {
|
|
if (pipelineScheduleState(pipeline) !== true) return "";
|
|
const count = pipeline.schedule_count;
|
|
return Number.isSafeInteger(count) && count > 0 ? `${count} ${count === 1 ? "schedule" : "schedules"}` : "Has schedules";
|
|
}
|
|
|
|
export function scheduledRunLabel(run) {
|
|
if (runScheduleState(run) !== true) return "";
|
|
const name = String(run?.schedule_name ?? "").trim();
|
|
return name ? `Scheduled · ${name}` : "Scheduled";
|
|
}
|