revert(nodes): remove server auto-setup feature
Drop the /api/servers/auto-setup endpoint, the AutoSetupDialog UI and the useAutoSetupServer hook. Rename the auto_setup locale strings to auto_create_token. Also normalize the storages response to an array. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -68,7 +68,9 @@ export function useClusterTopology() {
|
||||
export function useStorages(serverId: number, node: string) {
|
||||
return useQuery({
|
||||
queryKey: nodeKeys.storages(serverId, node),
|
||||
queryFn: () => apiClient.get<unknown[]>(`/proxmox/api/${serverId}/storages?node=${node}`),
|
||||
queryFn: () => apiClient
|
||||
.get<{ storages: unknown[] } | unknown[]>(`/proxmox/api/${serverId}/storages?node=${node}`)
|
||||
.then(r => Array.isArray(r) ? r : (r as { storages: unknown[] }).storages),
|
||||
enabled: serverId > 0 && !!node,
|
||||
});
|
||||
}
|
||||
@@ -146,38 +148,6 @@ export function useClusterInfo(serverId: number) {
|
||||
});
|
||||
}
|
||||
|
||||
export interface AutoSetupArgs {
|
||||
name: string;
|
||||
hostname?: string;
|
||||
ip_address: string;
|
||||
port?: number;
|
||||
api_user?: string;
|
||||
password: string;
|
||||
verify_ssl?: boolean;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface AutoSetupResult {
|
||||
cluster?: boolean;
|
||||
nodes_count?: number;
|
||||
servers?: Array<{ name: string; node: string; ip: string; status: string }>;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
// Add a server by password — the backend auto-creates an API token.
|
||||
export function useAutoSetupServer() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (data: AutoSetupArgs) => apiClient.post<AutoSetupResult>('/proxmox/api/servers/auto-setup', data),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: nodeKeys.servers });
|
||||
qc.invalidateQueries({ queryKey: nodeKeys.topology });
|
||||
qc.invalidateQueries({ queryKey: vmKeys.all });
|
||||
qc.invalidateQueries({ queryKey: vmKeys.resourcesAll });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== Node network interfaces ====================
|
||||
|
||||
export function useNodeNetworks(serverId: number, node: string) {
|
||||
|
||||
Reference in New Issue
Block a user