Node delete should reset.
This commit is contained in:
@@ -4,7 +4,7 @@ import { Button } from './ui/button';
|
|||||||
import { Badge } from './ui/badge';
|
import { Badge } from './ui/badge';
|
||||||
import { Alert } from './ui/alert';
|
import { Alert } from './ui/alert';
|
||||||
import { Input } from './ui/input';
|
import { Input } from './ui/input';
|
||||||
import { Cpu, HardDrive, Network, Monitor, CheckCircle, AlertCircle, BookOpen, ExternalLink, Loader2, RotateCcw } from 'lucide-react';
|
import { Cpu, HardDrive, Network, Monitor, CheckCircle, AlertCircle, BookOpen, ExternalLink, Loader2 } from 'lucide-react';
|
||||||
import { useInstanceContext } from '../hooks/useInstanceContext';
|
import { useInstanceContext } from '../hooks/useInstanceContext';
|
||||||
import { useNodes, useDiscoveryStatus } from '../hooks/useNodes';
|
import { useNodes, useDiscoveryStatus } from '../hooks/useNodes';
|
||||||
import { useCluster } from '../hooks/useCluster';
|
import { useCluster } from '../hooks/useCluster';
|
||||||
@@ -37,8 +37,6 @@ export function ClusterNodesComponent() {
|
|||||||
updateNode,
|
updateNode,
|
||||||
applyNode,
|
applyNode,
|
||||||
isApplying,
|
isApplying,
|
||||||
resetNode,
|
|
||||||
isResetting,
|
|
||||||
refetch
|
refetch
|
||||||
} = useNodes(currentInstance);
|
} = useNodes(currentInstance);
|
||||||
|
|
||||||
@@ -68,6 +66,7 @@ export function ClusterNodesComponent() {
|
|||||||
open: false,
|
open: false,
|
||||||
mode: 'add',
|
mode: 'add',
|
||||||
});
|
});
|
||||||
|
const [deletingNodeHostname, setDeletingNodeHostname] = useState<string | null>(null);
|
||||||
|
|
||||||
const closeDrawer = () => setDrawerState({ ...drawerState, open: false });
|
const closeDrawer = () => setDrawerState({ ...drawerState, open: false });
|
||||||
|
|
||||||
@@ -217,20 +216,15 @@ export function ClusterNodesComponent() {
|
|||||||
await applyNode(drawerState.node.hostname);
|
await applyNode(drawerState.node.hostname);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleResetNode = (node: Node) => {
|
const handleDeleteNode = async (hostname: string) => {
|
||||||
if (
|
|
||||||
confirm(
|
|
||||||
`Reset node ${node.hostname}?\n\nThis will wipe the node and return it to maintenance mode. The node will need to be reconfigured.`
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
resetNode(node.hostname);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteNode = (hostname: string) => {
|
|
||||||
if (!currentInstance) return;
|
if (!currentInstance) return;
|
||||||
if (confirm(`Are you sure you want to remove node ${hostname}?`)) {
|
if (confirm(`Reset and remove node ${hostname}?\n\nThis will reset the node and remove it from the cluster. The node will reboot to maintenance mode and can be reconfigured.`)) {
|
||||||
deleteNode(hostname);
|
setDeletingNodeHostname(hostname);
|
||||||
|
try {
|
||||||
|
await deleteNode(hostname);
|
||||||
|
} finally {
|
||||||
|
setDeletingNodeHostname(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -274,7 +268,7 @@ export function ClusterNodesComponent() {
|
|||||||
|
|
||||||
// Check if cluster is already bootstrapped using cluster status
|
// Check if cluster is already bootstrapped using cluster status
|
||||||
// The backend checks for kubeconfig existence and cluster connectivity
|
// The backend checks for kubeconfig existence and cluster connectivity
|
||||||
const hasBootstrapped = clusterStatus?.status !== 'not_bootstrapped' && clusterStatus?.status !== undefined;
|
const hasBootstrapped = clusterStatus?.ready === true;
|
||||||
|
|
||||||
return hasReadyControlPlane && !hasBootstrapped;
|
return hasReadyControlPlane && !hasBootstrapped;
|
||||||
}, [assignedNodes, clusterStatus]);
|
}, [assignedNodes, clusterStatus]);
|
||||||
@@ -634,25 +628,13 @@ export function ClusterNodesComponent() {
|
|||||||
{isApplying ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Apply'}
|
{isApplying ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Apply'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{!node.maintenance && (node.configured || node.applied) && (
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
variant="outline"
|
|
||||||
onClick={() => handleResetNode(node)}
|
|
||||||
disabled={isResetting}
|
|
||||||
className="border-orange-500 text-orange-500 hover:bg-orange-50 hover:text-orange-600"
|
|
||||||
>
|
|
||||||
<RotateCcw className="h-4 w-4 mr-1" />
|
|
||||||
Reset
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
onClick={() => handleDeleteNode(node.hostname)}
|
onClick={() => handleDeleteNode(node.hostname)}
|
||||||
disabled={isDeleting}
|
disabled={deletingNodeHostname === node.hostname}
|
||||||
>
|
>
|
||||||
{isDeleting ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Delete'}
|
{deletingNodeHostname === node.hostname ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Delete'}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user