import { useMutation } from "@tanstack/react-query"; import { useState } from "react"; import { toast } from "sonner"; import { CreateVolumeForm, type FormValues } from "~/client/components/create-volume-form"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "~/client/components/ui/alert-dialog"; import { Card } from "~/client/components/ui/card"; import type { StatFs, Volume } from "~/client/lib/types"; import { HealthchecksCard } from "../components/healthchecks-card"; import { StorageChart } from "../components/storage-chart"; import { updateVolumeMutation } from "~/client/api-client/@tanstack/react-query.gen"; type Props = { volume: Volume; statfs: StatFs; }; export const VolumeInfoTabContent = ({ volume, statfs }: Props) => { const updateMutation = useMutation({ ...updateVolumeMutation(), onSuccess: (_) => { toast.success("Volume updated successfully"); setOpen(false); setPendingValues(null); }, onError: (error) => { toast.error("Failed to update volume", { description: error.message }); setOpen(false); setPendingValues(null); }, }); const [open, setOpen] = useState(false); const [pendingValues, setPendingValues] = useState(null); const handleSubmit = (values: FormValues) => { setPendingValues(values); setOpen(true); }; const confirmUpdate = () => { if (pendingValues) { updateMutation.mutate({ path: { name: volume.name }, body: { config: pendingValues }, }); } }; return ( <>
Update Volume Configuration Editing the volume will remount it with the new config immediately. This may temporarily disrupt access to the volume. Continue? Cancel Update ); };