fix: check compatiblity after delete selecor

main
jialin 10 months ago
parent a23f9881ee
commit 9f24e765be

@ -10,12 +10,14 @@ interface LabelSelectorProps {
description?: React.ReactNode;
onChange?: (labels: Record<string, any>) => void;
onBlur?: (e: any, type: string, index: number) => void;
onDelete?: (index: number) => void;
}
const LabelSelector: React.FC<LabelSelectorProps> = ({
labels,
onChange,
onBlur,
onDelete,
label,
btnText,
description
@ -90,6 +92,7 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
onLabelListChange={handleLabelListChange}
onPaste={handleOnPaste}
onBlur={onBlur}
onDelete={onDelete}
/>
);
};

@ -14,6 +14,7 @@ interface LabelSelectorProps {
onChange?: (labels: Record<string, any>) => void;
onPaste?: (e: any, index: number) => void;
onBlur?: (e: any, type: string, index: number) => void;
onDelete?: (index: number) => void;
description?: React.ReactNode;
}
@ -24,6 +25,7 @@ const Inner: React.FC<LabelSelectorProps> = ({
onLabelListChange,
onPaste,
onBlur,
onDelete,
label,
btnText,
description
@ -69,6 +71,7 @@ const Inner: React.FC<LabelSelectorProps> = ({
list.splice(index, 1);
onLabelListChange(list);
updateLabels(list);
onDelete?.(index);
};
return (

@ -16,6 +16,7 @@ interface ListInputProps {
labelExtra?: React.ReactNode;
onChange: (data: string[]) => void;
onBlur?: (e: any, index: number) => void;
onDelete?: (index: number) => void;
}
const ListInput: React.FC<ListInputProps> = (props) => {
@ -26,6 +27,7 @@ const ListInput: React.FC<ListInputProps> = (props) => {
description,
onChange,
onBlur,
onDelete,
btnText,
options,
labelExtra
@ -44,6 +46,7 @@ const ListInput: React.FC<ListInputProps> = (props) => {
const valueList = _.map(values, 'value').filter((val: string) => !!val);
setList(values);
onChange(valueList);
onDelete?.(index);
};
const handleOnChange = (value: string, index: number) => {

@ -160,6 +160,10 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
onValuesChange?.({}, form.getFieldsValue());
};
const handleDeleteBackendParameters = (index: number) => {
onValuesChange?.({}, form.getFieldsValue());
};
const handleSelectorOnBlur = () => {
const workerSelector = form.getFieldValue('worker_selector');
// check if all keys have values
@ -171,6 +175,10 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
}
};
const handleDeleteWorkerSelector = (index: number) => {
onValuesChange?.({}, form.getFieldsValue());
};
const handleBackendVersionOnBlur = () => {
const backendVersion = form.getFieldValue('backend_version');
onValuesChange?.({}, form.getFieldsValue());
@ -257,6 +265,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
labels={wokerSelector}
onChange={handleWorkerLabelsChange}
onBlur={handleSelectorOnBlur}
onDelete={handleDeleteWorkerSelector}
description={
<span>
{intl.formatMessage({
@ -350,6 +359,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
dataList={form.getFieldValue('backend_parameters') || []}
onChange={handleBackendParametersChange}
onBlur={handleBackendParametersOnBlur}
onDelete={handleDeleteBackendParameters}
options={paramsConfig}
description={
backendParamsTips && (

@ -79,8 +79,8 @@ const AddModal: FC<AddModalProps> = (props) => {
handleShowCompatibleAlert,
setWarningStatus,
handleBackendChangeBefore,
cancelEvaluate,
handleOnValuesChange,
checkTokenRef,
warningStatus,
submitAnyway
} = useCheckCompatibility();
@ -182,11 +182,17 @@ const AddModal: FC<AddModalProps> = (props) => {
onCancel?.();
}, [onCancel]);
const handleOnOpen = useCallback(() => {
const handleOnOpen = () => {
console.log('handleOnOpen----------', props.source, props.deploymentType);
if (props.deploymentType === 'modelFiles') {
form.current?.form?.setFieldsValue({
...props.initialValues
});
handleOnValuesChange?.({
changedValues: {},
allValues: props.initialValues,
source: source
});
} else {
const backend =
source === modelSourceMap.ollama_library_value
@ -194,15 +200,14 @@ const AddModal: FC<AddModalProps> = (props) => {
: backendOptionsMap.vllm;
form.current?.setFieldValue?.('backend', backend);
}
}, [source, props.initialValues, props.deploymentType]);
};
useEffect(() => {
if (!open) {
return;
} else {
if (open) {
handleOnOpen();
} else {
cancelEvaluate();
}
return () => {
setSelectedModel({});
setWarningStatus({
@ -210,9 +215,8 @@ const AddModal: FC<AddModalProps> = (props) => {
title: '',
message: []
});
checkTokenRef.current?.cancel();
};
}, [open, handleOnOpen]);
}, [open]);
return (
<Drawer

@ -474,12 +474,12 @@ export const useCheckCompatibility = () => {
const cancelEvaluate = () => {
checkTokenRef.current?.cancel();
checkTokenRef.current = null;
cacheFormValuesRef.current = {};
};
useEffect(() => {
return () => {
checkTokenRef.current?.cancel();
checkTokenRef.current = null;
cancelEvaluate();
};
}, []);

Loading…
Cancel
Save