mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: run backup now
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
listRepositoriesOptions,
|
||||
upsertBackupScheduleMutation,
|
||||
getBackupScheduleForVolumeOptions,
|
||||
runBackupNowMutation,
|
||||
} from "~/api-client/@tanstack/react-query.gen";
|
||||
import { parseError } from "~/lib/errors";
|
||||
import { CreateScheduleForm, type BackupScheduleFormValues } from "../components/create-schedule-form";
|
||||
@@ -65,6 +66,19 @@ export const VolumeBackupsTabContent = ({ volume }: Props) => {
|
||||
},
|
||||
});
|
||||
|
||||
const runBackupNow = useMutation({
|
||||
...runBackupNowMutation(),
|
||||
onSuccess: () => {
|
||||
toast.success("Backup started successfully");
|
||||
queryClient.invalidateQueries({ queryKey: ["getBackupScheduleForVolume", volume.id.toString()] });
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Failed to start backup", {
|
||||
description: parseError(error)?.message,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit = (formValues: BackupScheduleFormValues) => {
|
||||
const cronExpression = getCronExpression(formValues.frequency, formValues.dailyTime, formValues.weeklyDay);
|
||||
|
||||
@@ -145,12 +159,23 @@ export const VolumeBackupsTabContent = ({ volume }: Props) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleRunBackupNow = () => {
|
||||
if (!existingSchedule) return;
|
||||
|
||||
runBackupNow.mutate({
|
||||
path: {
|
||||
scheduleId: existingSchedule.id.toString(),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const repository = repositories.find((repo) => repo.id === existingSchedule?.repositoryId);
|
||||
|
||||
if (existingSchedule && repository && !isEditMode) {
|
||||
return (
|
||||
<ScheduleSummary
|
||||
handleToggleEnabled={handleToggleEnabled}
|
||||
handleRunBackupNow={handleRunBackupNow}
|
||||
repository={repository}
|
||||
setIsEditMode={setIsEditMode}
|
||||
schedule={existingSchedule}
|
||||
|
||||
Reference in New Issue
Block a user