Fix drop down
This commit is contained in:
parent
ec145e4531
commit
81ec39d1f0
@ -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 (
|
||||
<div className='form-group'>
|
||||
<div className="form-group">
|
||||
<h2>🔁 Restore PVC</h2>
|
||||
<div className='form-content'>
|
||||
<label>Backup Name:</label>
|
||||
|
||||
<div className="form-content">
|
||||
<label>Backup Name:</label>
|
||||
<Input
|
||||
type="text"
|
||||
value={backupName}
|
||||
onChange={e => setBackupName(e.target.value)}
|
||||
className='restore-input'
|
||||
className="restore-input"
|
||||
placeholder="The exact name of the backup to restore"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='form-content'>
|
||||
<div className="form-content">
|
||||
<label>Target Namespace:</label>
|
||||
<Input
|
||||
type="text"
|
||||
value={targetNs}
|
||||
onChange={e => setTargetNs(e.target.value)}
|
||||
className='restore-input'
|
||||
/>
|
||||
<select value={targetNs} onChange={e => setTargetNs(e.target.value)}>
|
||||
<option value="">-- Select Namespace --</option>
|
||||
{namespaces.map(ns => (
|
||||
<option key={ns} value={ns}>
|
||||
{ns}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className='form-content'>
|
||||
<label>Target PVC:</label>
|
||||
<Input
|
||||
type="text"
|
||||
<div className="form-content">
|
||||
<label>Target PVC:</label>
|
||||
<select
|
||||
value={targetPvc}
|
||||
onChange={e => setTargetPvc(e.target.value)}
|
||||
className='restore-input'
|
||||
/>
|
||||
disabled={!targetNs}
|
||||
>
|
||||
<option value="">-- Select PVC --</option>
|
||||
{pvcs.map(pvc => (
|
||||
<option key={pvc} value={pvc}>
|
||||
{pvc}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<Button id='restore-btn' className='btn' onClick={handleRestore}>Restore</Button>
|
||||
<Button id="restore-btn" className="btn" onClick={handleRestore}>
|
||||
Restore
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user