Fix schedule time picker: cleaner hour labels, hide selectors for every-minute
- Change hour labels from "10:00 AM" to "10 AM" to avoid confusion with the separate minute selector - Hide hour/minute selectors when "Every minute" preset is selected (no time config needed) - Fix describeSchedule to work with updated hour label format Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
e341abb99c
commit
9998cc0683
1 changed files with 4 additions and 3 deletions
|
|
@ -18,7 +18,7 @@ const PRESETS: { value: SchedulePreset; label: string }[] = [
|
||||||
|
|
||||||
const HOURS = Array.from({ length: 24 }, (_, i) => ({
|
const HOURS = Array.from({ length: 24 }, (_, i) => ({
|
||||||
value: String(i),
|
value: String(i),
|
||||||
label: i === 0 ? "12:00 AM" : i < 12 ? `${i}:00 AM` : i === 12 ? "12:00 PM" : `${i - 12}:00 PM`,
|
label: i === 0 ? "12 AM" : i < 12 ? `${i} AM` : i === 12 ? "12 PM" : `${i - 12} PM`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const MINUTES = Array.from({ length: 12 }, (_, i) => ({
|
const MINUTES = Array.from({ length: 12 }, (_, i) => ({
|
||||||
|
|
@ -115,7 +115,8 @@ function buildCron(preset: SchedulePreset, hour: string, minute: string, dayOfWe
|
||||||
|
|
||||||
function describeSchedule(cron: string): string {
|
function describeSchedule(cron: string): string {
|
||||||
const { preset, hour, minute, dayOfWeek, dayOfMonth } = parseCronToPreset(cron);
|
const { preset, hour, minute, dayOfWeek, dayOfMonth } = parseCronToPreset(cron);
|
||||||
const timeStr = HOURS.find((h) => h.value === hour)?.label?.replace(":00", `:${minute.padStart(2, "0")}`) ?? `${hour}:${minute.padStart(2, "0")}`;
|
const hourLabel = HOURS.find((h) => h.value === hour)?.label ?? `${hour}`;
|
||||||
|
const timeStr = `${hourLabel.replace(/ (AM|PM)$/, "")}:${minute.padStart(2, "0")} ${hourLabel.match(/(AM|PM)$/)?.[0] ?? ""}`;
|
||||||
|
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case "every_minute":
|
case "every_minute":
|
||||||
|
|
@ -223,7 +224,7 @@ export function ScheduleEditor({
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
{preset !== "every_hour" && (
|
{preset !== "every_minute" && preset !== "every_hour" && (
|
||||||
<>
|
<>
|
||||||
<span className="text-sm text-muted-foreground">at</span>
|
<span className="text-sm text-muted-foreground">at</span>
|
||||||
<Select
|
<Select
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue