fix: add pool not work

This commit is contained in:
jialin
2025-09-16 11:26:17 +08:00
parent c467280170
commit f1bb305cbc
18 changed files with 185 additions and 79 deletions
@@ -1,12 +1,14 @@
import ModalFooter from '@/components/modal-footer';
import ScrollerModal from '@/components/scroller-modal';
import { PageActionType } from '@/config/types';
import React, { useRef } from 'react';
import React, { useEffect, useRef } from 'react';
import { ProviderType } from '../config';
import {
ClusterListItem,
NodePoolFormData as FormData,
NodePoolListItem as ListItem
} from '../config/types';
import { useProviderRegions } from '../hooks/use-provider-regions';
import PoolForm from './pool-form';
type AddModalProps = {
@@ -15,6 +17,7 @@ type AddModalProps = {
open: boolean;
provider: ProviderType; // 'kubernetes' | 'custom' | 'digitalocean';
currentData?: ListItem | null;
clusterData?: ClusterListItem | null;
onOk: (values: FormData) => void;
onCancel: () => void;
};
@@ -25,8 +28,11 @@ const AddPool: React.FC<AddModalProps> = ({
provider,
onOk,
currentData,
clusterData,
onCancel
}) => {
const { getInstanceTypes, getOSImages, updateInstanceTypes, updateOSImages } =
useProviderRegions();
const formRef = useRef<any>(null);
const handleSubmit = async () => {
@@ -42,6 +48,18 @@ const AddPool: React.FC<AddModalProps> = ({
onCancel();
};
useEffect(() => {
const init = async (clusterData: ClusterListItem) => {
const allTyps = await getInstanceTypes(clusterData.credential_id);
const allImages = await getOSImages(clusterData.credential_id);
updateInstanceTypes(clusterData.region, allTyps);
updateOSImages(clusterData.region, allImages);
};
if (open && clusterData && clusterData.credential_id) {
init(clusterData);
}
}, [clusterData, open]);
return (
<ScrollerModal
title={title}