From 81ec39d1f0bd93aa1e035e7584a0e687871c7bbf Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Wed, 11 Jun 2025 05:14:23 +0300 Subject: [PATCH] Fix drop down --- frontend/src/components/RestoreForm.jsx | 72 +++++++++++++++++-------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/RestoreForm.jsx b/frontend/src/components/RestoreForm.jsx index 57ad21a..3438e90 100644 --- a/frontend/src/components/RestoreForm.jsx +++ b/frontend/src/components/RestoreForm.jsx @@ -1,12 +1,26 @@ -import { useState } from 'react'; -import { restoreBackup } from '../api/snapix'; -import { Button, Input } from '@mui/base' -import '../style/RestoreForm.css'; // Assuming you have some styles for the form +import { useEffect, useState } from 'react'; +import { restoreBackup, getNamespaces, getPVCs } from '../api/snapix'; +import { Button, Input } from '@mui/base'; +import '../style/RestoreForm.css'; export default function RestoreForm() { const [backupName, setBackupName] = useState(''); const [targetNs, setTargetNs] = useState(''); const [targetPvc, setTargetPvc] = useState(''); + const [namespaces, setNamespaces] = useState([]); + const [pvcs, setPvcs] = useState([]); + + useEffect(() => { + getNamespaces().then(res => setNamespaces(res.data)); + }, []); + + useEffect(() => { + if (targetNs) { + getPVCs(targetNs).then(res => setPvcs(res.data)); + } else { + setPvcs([]); + } + }, [targetNs]); const handleRestore = () => { if (backupName && targetNs && targetPvc) { @@ -15,45 +29,57 @@ export default function RestoreForm() { target_namespace: targetNs, target_pvc: targetPvc, }).then(() => { - alert("Restore started!"); + alert('Restore started!'); }); } }; return ( -
+

🔁 Restore PVC

-
- + +
+ setBackupName(e.target.value)} - className='restore-input' + className="restore-input" + placeholder="The exact name of the backup to restore" />
-
+
- setTargetNs(e.target.value)} - className='restore-input' - /> +
-
- - + +
- +
); }