fix: do not trigger evaluation after switching model
This commit is contained in:
@@ -320,7 +320,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
||||
return {
|
||||
...pre,
|
||||
loading: false,
|
||||
repoOptions: resultList
|
||||
dataList: resultList
|
||||
};
|
||||
});
|
||||
// current selected item
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import SealInput from '@/components/seal-form/seal-input';
|
||||
import SealSelect from '@/components/seal-form/seal-select';
|
||||
import useAppUtils from '@/hooks/use-app-utils';
|
||||
import {
|
||||
ClusterStatusLabelMap,
|
||||
ClusterStatusValueMap
|
||||
} from '@/pages/cluster-management/config';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import { useMemo } from 'react';
|
||||
import { sourceOptions } from '../config';
|
||||
import { FormData } from '../config/types';
|
||||
import CatalogFrom from './catalog';
|
||||
@@ -13,7 +18,7 @@ interface BasicFormProps {
|
||||
fields?: string[];
|
||||
sourceDisable?: boolean;
|
||||
sourceList?: Global.BaseOption<string>[];
|
||||
clusterList: Global.BaseOption<number>[];
|
||||
clusterList: Global.BaseOption<number, { provider: string; state: string }>[];
|
||||
handleClusterChange: (value: number) => void;
|
||||
onSourceChange?: (value: string) => void;
|
||||
}
|
||||
@@ -35,6 +40,19 @@ const BasicForm: React.FC<BasicFormProps> = (props) => {
|
||||
onSourceChange?.(val);
|
||||
};
|
||||
|
||||
const clusterOptions = useMemo(() => {
|
||||
return clusterList?.map((item) => {
|
||||
return {
|
||||
label:
|
||||
item.state === ClusterStatusValueMap.Ready
|
||||
? item.label
|
||||
: `${item.label} [${ClusterStatusLabelMap[item.state as string]}]`,
|
||||
disabled: item.state !== ClusterStatusValueMap.Ready,
|
||||
value: item.value
|
||||
};
|
||||
});
|
||||
}, [clusterList]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item<FormData>
|
||||
@@ -93,7 +111,7 @@ const BasicForm: React.FC<BasicFormProps> = (props) => {
|
||||
<SealSelect
|
||||
onChange={handleClusterChange}
|
||||
label={intl.formatMessage({ id: 'clusters.title' })}
|
||||
options={clusterList}
|
||||
options={clusterOptions}
|
||||
required
|
||||
></SealSelect>
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { clusterListAtom } from '@/atoms/models';
|
||||
import { queryClusterList } from '@/pages/cluster-management/apis';
|
||||
import {
|
||||
ClusterStatusLabelMap,
|
||||
ClusterStatusValueMap
|
||||
} from '@/pages/cluster-management/config';
|
||||
import { ClusterListItem } from '@/pages/cluster-management/config/types';
|
||||
import { queryWorkersList } from '@/pages/resources/apis';
|
||||
import {
|
||||
@@ -239,7 +235,7 @@ export default function useFormInitialValues() {
|
||||
const [, setClusterListAtom] = useAtom(clusterListAtom);
|
||||
|
||||
const [clusterList, setClusterList] = useState<
|
||||
Global.BaseOption<number, { provider: string; state: string | number }>[]
|
||||
Global.BaseOption<number, { provider: string; state: string }>[]
|
||||
>([]);
|
||||
|
||||
const getClusterList = async (): Promise<Global.BaseOption<number>[]> => {
|
||||
@@ -249,12 +245,8 @@ export default function useFormInitialValues() {
|
||||
perPage: 100
|
||||
});
|
||||
const list = response.items.map((item) => ({
|
||||
label:
|
||||
item.state === ClusterStatusValueMap.Ready
|
||||
? item.name
|
||||
: `${item.name} [${ClusterStatusLabelMap[item.state]}]`,
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
disabled: item.state !== ClusterStatusValueMap.Ready,
|
||||
provider: item.provider as string,
|
||||
state: item.state
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user