fix: check compatiblity after delete selecor
This commit is contained in:
@@ -10,12 +10,14 @@ interface LabelSelectorProps {
|
|||||||
description?: React.ReactNode;
|
description?: React.ReactNode;
|
||||||
onChange?: (labels: Record<string, any>) => void;
|
onChange?: (labels: Record<string, any>) => void;
|
||||||
onBlur?: (e: any, type: string, index: number) => void;
|
onBlur?: (e: any, type: string, index: number) => void;
|
||||||
|
onDelete?: (index: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LabelSelector: React.FC<LabelSelectorProps> = ({
|
const LabelSelector: React.FC<LabelSelectorProps> = ({
|
||||||
labels,
|
labels,
|
||||||
onChange,
|
onChange,
|
||||||
onBlur,
|
onBlur,
|
||||||
|
onDelete,
|
||||||
label,
|
label,
|
||||||
btnText,
|
btnText,
|
||||||
description
|
description
|
||||||
@@ -90,6 +92,7 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
|
|||||||
onLabelListChange={handleLabelListChange}
|
onLabelListChange={handleLabelListChange}
|
||||||
onPaste={handleOnPaste}
|
onPaste={handleOnPaste}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
|
onDelete={onDelete}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ interface LabelSelectorProps {
|
|||||||
onChange?: (labels: Record<string, any>) => void;
|
onChange?: (labels: Record<string, any>) => void;
|
||||||
onPaste?: (e: any, index: number) => void;
|
onPaste?: (e: any, index: number) => void;
|
||||||
onBlur?: (e: any, type: string, index: number) => void;
|
onBlur?: (e: any, type: string, index: number) => void;
|
||||||
|
onDelete?: (index: number) => void;
|
||||||
description?: React.ReactNode;
|
description?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ const Inner: React.FC<LabelSelectorProps> = ({
|
|||||||
onLabelListChange,
|
onLabelListChange,
|
||||||
onPaste,
|
onPaste,
|
||||||
onBlur,
|
onBlur,
|
||||||
|
onDelete,
|
||||||
label,
|
label,
|
||||||
btnText,
|
btnText,
|
||||||
description
|
description
|
||||||
@@ -69,6 +71,7 @@ const Inner: React.FC<LabelSelectorProps> = ({
|
|||||||
list.splice(index, 1);
|
list.splice(index, 1);
|
||||||
onLabelListChange(list);
|
onLabelListChange(list);
|
||||||
updateLabels(list);
|
updateLabels(list);
|
||||||
|
onDelete?.(index);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ interface ListInputProps {
|
|||||||
labelExtra?: React.ReactNode;
|
labelExtra?: React.ReactNode;
|
||||||
onChange: (data: string[]) => void;
|
onChange: (data: string[]) => void;
|
||||||
onBlur?: (e: any, index: number) => void;
|
onBlur?: (e: any, index: number) => void;
|
||||||
|
onDelete?: (index: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ListInput: React.FC<ListInputProps> = (props) => {
|
const ListInput: React.FC<ListInputProps> = (props) => {
|
||||||
@@ -26,6 +27,7 @@ const ListInput: React.FC<ListInputProps> = (props) => {
|
|||||||
description,
|
description,
|
||||||
onChange,
|
onChange,
|
||||||
onBlur,
|
onBlur,
|
||||||
|
onDelete,
|
||||||
btnText,
|
btnText,
|
||||||
options,
|
options,
|
||||||
labelExtra
|
labelExtra
|
||||||
@@ -44,6 +46,7 @@ const ListInput: React.FC<ListInputProps> = (props) => {
|
|||||||
const valueList = _.map(values, 'value').filter((val: string) => !!val);
|
const valueList = _.map(values, 'value').filter((val: string) => !!val);
|
||||||
setList(values);
|
setList(values);
|
||||||
onChange(valueList);
|
onChange(valueList);
|
||||||
|
onDelete?.(index);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnChange = (value: string, index: number) => {
|
const handleOnChange = (value: string, index: number) => {
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
onValuesChange?.({}, form.getFieldsValue());
|
onValuesChange?.({}, form.getFieldsValue());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDeleteBackendParameters = (index: number) => {
|
||||||
|
onValuesChange?.({}, form.getFieldsValue());
|
||||||
|
};
|
||||||
|
|
||||||
const handleSelectorOnBlur = () => {
|
const handleSelectorOnBlur = () => {
|
||||||
const workerSelector = form.getFieldValue('worker_selector');
|
const workerSelector = form.getFieldValue('worker_selector');
|
||||||
// check if all keys have values
|
// 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 handleBackendVersionOnBlur = () => {
|
||||||
const backendVersion = form.getFieldValue('backend_version');
|
const backendVersion = form.getFieldValue('backend_version');
|
||||||
onValuesChange?.({}, form.getFieldsValue());
|
onValuesChange?.({}, form.getFieldsValue());
|
||||||
@@ -257,6 +265,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
labels={wokerSelector}
|
labels={wokerSelector}
|
||||||
onChange={handleWorkerLabelsChange}
|
onChange={handleWorkerLabelsChange}
|
||||||
onBlur={handleSelectorOnBlur}
|
onBlur={handleSelectorOnBlur}
|
||||||
|
onDelete={handleDeleteWorkerSelector}
|
||||||
description={
|
description={
|
||||||
<span>
|
<span>
|
||||||
{intl.formatMessage({
|
{intl.formatMessage({
|
||||||
@@ -350,6 +359,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
dataList={form.getFieldValue('backend_parameters') || []}
|
dataList={form.getFieldValue('backend_parameters') || []}
|
||||||
onChange={handleBackendParametersChange}
|
onChange={handleBackendParametersChange}
|
||||||
onBlur={handleBackendParametersOnBlur}
|
onBlur={handleBackendParametersOnBlur}
|
||||||
|
onDelete={handleDeleteBackendParameters}
|
||||||
options={paramsConfig}
|
options={paramsConfig}
|
||||||
description={
|
description={
|
||||||
backendParamsTips && (
|
backendParamsTips && (
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
handleShowCompatibleAlert,
|
handleShowCompatibleAlert,
|
||||||
setWarningStatus,
|
setWarningStatus,
|
||||||
handleBackendChangeBefore,
|
handleBackendChangeBefore,
|
||||||
|
cancelEvaluate,
|
||||||
handleOnValuesChange,
|
handleOnValuesChange,
|
||||||
checkTokenRef,
|
|
||||||
warningStatus,
|
warningStatus,
|
||||||
submitAnyway
|
submitAnyway
|
||||||
} = useCheckCompatibility();
|
} = useCheckCompatibility();
|
||||||
@@ -182,11 +182,17 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
onCancel?.();
|
onCancel?.();
|
||||||
}, [onCancel]);
|
}, [onCancel]);
|
||||||
|
|
||||||
const handleOnOpen = useCallback(() => {
|
const handleOnOpen = () => {
|
||||||
|
console.log('handleOnOpen----------', props.source, props.deploymentType);
|
||||||
if (props.deploymentType === 'modelFiles') {
|
if (props.deploymentType === 'modelFiles') {
|
||||||
form.current?.form?.setFieldsValue({
|
form.current?.form?.setFieldsValue({
|
||||||
...props.initialValues
|
...props.initialValues
|
||||||
});
|
});
|
||||||
|
handleOnValuesChange?.({
|
||||||
|
changedValues: {},
|
||||||
|
allValues: props.initialValues,
|
||||||
|
source: source
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const backend =
|
const backend =
|
||||||
source === modelSourceMap.ollama_library_value
|
source === modelSourceMap.ollama_library_value
|
||||||
@@ -194,15 +200,14 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
: backendOptionsMap.vllm;
|
: backendOptionsMap.vllm;
|
||||||
form.current?.setFieldValue?.('backend', backend);
|
form.current?.setFieldValue?.('backend', backend);
|
||||||
}
|
}
|
||||||
}, [source, props.initialValues, props.deploymentType]);
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) {
|
if (open) {
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
handleOnOpen();
|
handleOnOpen();
|
||||||
|
} else {
|
||||||
|
cancelEvaluate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
setSelectedModel({});
|
setSelectedModel({});
|
||||||
setWarningStatus({
|
setWarningStatus({
|
||||||
@@ -210,9 +215,8 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
title: '',
|
title: '',
|
||||||
message: []
|
message: []
|
||||||
});
|
});
|
||||||
checkTokenRef.current?.cancel();
|
|
||||||
};
|
};
|
||||||
}, [open, handleOnOpen]);
|
}, [open]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
|
|||||||
@@ -474,12 +474,12 @@ export const useCheckCompatibility = () => {
|
|||||||
const cancelEvaluate = () => {
|
const cancelEvaluate = () => {
|
||||||
checkTokenRef.current?.cancel();
|
checkTokenRef.current?.cancel();
|
||||||
checkTokenRef.current = null;
|
checkTokenRef.current = null;
|
||||||
|
cacheFormValuesRef.current = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
checkTokenRef.current?.cancel();
|
cancelEvaluate();
|
||||||
checkTokenRef.current = null;
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user