feat: set default cluster

This commit is contained in:
jialin
2025-12-23 20:54:16 +08:00
parent 530e8f7537
commit 1b661bb8cd
17 changed files with 102 additions and 14 deletions
@@ -191,6 +191,10 @@ const AddModal: React.FC<AddModalProps> = (props) => {
};
const initClusterId = (): number => {
const defaultCluster = clusterList?.find((item) => item.is_default);
if (defaultCluster) {
return defaultCluster.value;
}
const cluster_id =
clusterList?.find((item) => item.state === ClusterStatusValueMap.Ready)
?.value || clusterList?.[0]?.value;
@@ -75,7 +75,7 @@ type AddModalProps = {
deploymentType?: 'modelList' | 'modelFiles';
clusterList: Global.BaseOption<
number,
{ provider: string; state: string | number }
{ provider: string; state: string | number; is_default: boolean }
>[];
onOk: (values: FormData) => void;
onCancel: () => void;
@@ -441,6 +441,12 @@ const AddModal: FC<AddModalProps> = (props) => {
if (initialValues?.cluster_id) {
return initialValues.cluster_id;
}
// Find default cluster
const defaultCluster = clusterList?.find((item) => item.is_default);
if (defaultCluster) {
return defaultCluster.value;
}
const cluster_id =
clusterList?.find((item) => item.state === ClusterStatusValueMap.Ready)
?.value || clusterList?.[0]?.value;