feat: set default cluster
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -217,7 +217,8 @@ export const useGenerateWorkerOptions = () => {
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
provider: item.provider as string,
|
||||
state: item.state
|
||||
state: item.state,
|
||||
is_default: item.is_default
|
||||
}))
|
||||
);
|
||||
};
|
||||
@@ -235,7 +236,10 @@ export default function useFormInitialValues() {
|
||||
const [, setWorkerListAtom] = useAtom(workerListAtom);
|
||||
|
||||
const [clusterList, setClusterList] = useState<
|
||||
Global.BaseOption<number, { provider: string; state: string }>[]
|
||||
Global.BaseOption<
|
||||
number,
|
||||
{ provider: string; state: string; is_default: boolean }
|
||||
>[]
|
||||
>([]);
|
||||
|
||||
const [workerList, setWorkerList] = useState<WorkerListItem[]>([]);
|
||||
@@ -249,7 +253,8 @@ export default function useFormInitialValues() {
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
provider: item.provider as string,
|
||||
state: item.state
|
||||
state: item.state,
|
||||
is_default: item.is_default
|
||||
}));
|
||||
setClusterList(list);
|
||||
setClusterListAtom(list);
|
||||
|
||||
Reference in New Issue
Block a user