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