chore: wording and formatting
This commit is contained in:
parent
e350843d4e
commit
a985c95a31
4 changed files with 65 additions and 53 deletions
|
|
@ -88,11 +88,8 @@ const backupScheduleToFormValues = (schedule?: BackupSchedule): InternalFormValu
|
||||||
const isDaily = !isHourly && dayOfMonthPart === "*" && dayOfWeekPart === "*";
|
const isDaily = !isHourly && dayOfMonthPart === "*" && dayOfWeekPart === "*";
|
||||||
|
|
||||||
const frequency = isHourly ? "hourly" : isMonthly ? "monthly" : isDaily ? "daily" : "weekly";
|
const frequency = isHourly ? "hourly" : isMonthly ? "monthly" : isDaily ? "daily" : "weekly";
|
||||||
|
|
||||||
const dailyTime = isHourly ? undefined : `${hourPart.padStart(2, "0")}:${minutePart.padStart(2, "0")}`;
|
const dailyTime = isHourly ? undefined : `${hourPart.padStart(2, "0")}:${minutePart.padStart(2, "0")}`;
|
||||||
|
|
||||||
const weeklyDay = frequency === "weekly" ? dayOfWeekPart : undefined;
|
const weeklyDay = frequency === "weekly" ? dayOfWeekPart : undefined;
|
||||||
|
|
||||||
const monthlyDays = isMonthly ? dayOfMonthPart.split(",") : undefined;
|
const monthlyDays = isMonthly ? dayOfMonthPart.split(",") : undefined;
|
||||||
|
|
||||||
const patterns = schedule.includePatterns || [];
|
const patterns = schedule.includePatterns || [];
|
||||||
|
|
@ -257,7 +254,7 @@ export const CreateScheduleForm = ({ initialValues, formId, onSubmit, volume }:
|
||||||
<SelectItem value="hourly">Hourly</SelectItem>
|
<SelectItem value="hourly">Hourly</SelectItem>
|
||||||
<SelectItem value="daily">Daily</SelectItem>
|
<SelectItem value="daily">Daily</SelectItem>
|
||||||
<SelectItem value="weekly">Weekly</SelectItem>
|
<SelectItem value="weekly">Weekly</SelectItem>
|
||||||
<SelectItem value="monthly">Monthly</SelectItem>
|
<SelectItem value="monthly">Specific days</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,12 @@ export default function ScheduleDetailsPage({ params, loaderData }: Route.Compon
|
||||||
const handleSubmit = (formValues: BackupScheduleFormValues) => {
|
const handleSubmit = (formValues: BackupScheduleFormValues) => {
|
||||||
if (!schedule) return;
|
if (!schedule) return;
|
||||||
|
|
||||||
const cronExpression = getCronExpression(formValues.frequency, formValues.dailyTime, formValues.weeklyDay, formValues.monthlyDays);
|
const cronExpression = getCronExpression(
|
||||||
|
formValues.frequency,
|
||||||
|
formValues.dailyTime,
|
||||||
|
formValues.weeklyDay,
|
||||||
|
formValues.monthlyDays,
|
||||||
|
);
|
||||||
|
|
||||||
const retentionPolicy: Record<string, number> = {};
|
const retentionPolicy: Record<string, number> = {};
|
||||||
if (formValues.keepLast) retentionPolicy.keepLast = formValues.keepLast;
|
if (formValues.keepLast) retentionPolicy.keepLast = formValues.keepLast;
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,12 @@ export default function CreateBackup({ loaderData }: Route.ComponentProps) {
|
||||||
const handleSubmit = (formValues: BackupScheduleFormValues) => {
|
const handleSubmit = (formValues: BackupScheduleFormValues) => {
|
||||||
if (!selectedVolumeId) return;
|
if (!selectedVolumeId) return;
|
||||||
|
|
||||||
const cronExpression = getCronExpression(formValues.frequency, formValues.dailyTime, formValues.weeklyDay, formValues.monthlyDays);
|
const cronExpression = getCronExpression(
|
||||||
|
formValues.frequency,
|
||||||
|
formValues.dailyTime,
|
||||||
|
formValues.weeklyDay,
|
||||||
|
formValues.monthlyDays,
|
||||||
|
);
|
||||||
|
|
||||||
const retentionPolicy: Record<string, number> = {};
|
const retentionPolicy: Record<string, number> = {};
|
||||||
if (formValues.keepLast) retentionPolicy.keepLast = formValues.keepLast;
|
if (formValues.keepLast) retentionPolicy.keepLast = formValues.keepLast;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
import { intervalToDuration } from "date-fns";
|
import { intervalToDuration } from "date-fns";
|
||||||
|
|
||||||
export const getCronExpression = (frequency: string, dailyTime?: string, weeklyDay?: string, monthlyDays?: string[]): string => {
|
export const getCronExpression = (
|
||||||
|
frequency: string,
|
||||||
|
dailyTime?: string,
|
||||||
|
weeklyDay?: string,
|
||||||
|
monthlyDays?: string[],
|
||||||
|
): string => {
|
||||||
if (frequency === "hourly") {
|
if (frequency === "hourly") {
|
||||||
return "0 * * * *";
|
return "0 * * * *";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue