fix: the fields for trigger checking
This commit is contained in:
@@ -162,14 +162,18 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
|
||||
const handleSelectorOnBlur = () => {
|
||||
const workerSelector = form.getFieldValue('worker_selector');
|
||||
onValuesChange?.({}, form.getFieldsValue());
|
||||
// check if all keys have values
|
||||
const hasEmptyValue = _.some(_.keys(workerSelector), (k: string) => {
|
||||
return !workerSelector[k];
|
||||
});
|
||||
if (!hasEmptyValue) {
|
||||
onValuesChange?.({}, form.getFieldsValue());
|
||||
}
|
||||
};
|
||||
|
||||
const handleBackendVersionOnBlur = () => {
|
||||
const backendVersion = form.getFieldValue('backend_version');
|
||||
if (backendVersion) {
|
||||
onValuesChange?.({}, form.getFieldsValue());
|
||||
}
|
||||
onValuesChange?.({}, form.getFieldsValue());
|
||||
};
|
||||
|
||||
const collapseItems = useMemo(() => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import AlertBlockInfo from '@/components/alert-info/block';
|
||||
import {
|
||||
CheckCircleFilled,
|
||||
CloseOutlined,
|
||||
LoadingOutlined,
|
||||
WarningFilled
|
||||
@@ -13,7 +14,7 @@ interface CompatibilityAlertProps {
|
||||
show: boolean;
|
||||
title?: string;
|
||||
isHtml?: boolean;
|
||||
type?: 'danger' | 'warning' | 'transition';
|
||||
type?: Global.MessageType;
|
||||
message: string | string[];
|
||||
};
|
||||
contentStyle?: React.CSSProperties;
|
||||
@@ -28,7 +29,7 @@ const DivWrapper = styled.div`
|
||||
|
||||
const CloseWrapper = styled.div`
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
top: 10px;
|
||||
right: 18px;
|
||||
cursor: pointer;
|
||||
background-color: var(--ant-color-warning-bg);
|
||||
@@ -43,7 +44,7 @@ const MessageWrapper = styled.div`
|
||||
|
||||
const CompatibilityAlert: React.FC<CompatibilityAlertProps> = (props) => {
|
||||
const { warningStatus, contentStyle, showClose, onClose } = props;
|
||||
const { title, show, message, isHtml, type } = warningStatus;
|
||||
const { title, show, message, isHtml, type = 'warning' } = warningStatus;
|
||||
|
||||
const renderMessage = useMemo(() => {
|
||||
if (!message || !show) {
|
||||
@@ -73,6 +74,16 @@ const CompatibilityAlert: React.FC<CompatibilityAlertProps> = (props) => {
|
||||
return '';
|
||||
}, [message, show]);
|
||||
|
||||
const renderIcon = useMemo(() => {
|
||||
if (type === 'transition') {
|
||||
return <LoadingOutlined />;
|
||||
}
|
||||
if (type === 'success') {
|
||||
return <CheckCircleFilled />;
|
||||
}
|
||||
return <WarningFilled />;
|
||||
}, [type]);
|
||||
|
||||
return (
|
||||
show && (
|
||||
<DivWrapper>
|
||||
@@ -82,9 +93,9 @@ const CompatibilityAlert: React.FC<CompatibilityAlertProps> = (props) => {
|
||||
title={title}
|
||||
contentStyle={contentStyle}
|
||||
type={type || 'warning'}
|
||||
icon={type === 'transition' ? <LoadingOutlined /> : <WarningFilled />}
|
||||
icon={renderIcon}
|
||||
></AlertBlockInfo>
|
||||
{showClose && type !== 'transition' && (
|
||||
{showClose && !['transition', 'success'].includes(type) && (
|
||||
<CloseWrapper onClick={onClose}>
|
||||
<CloseOutlined />
|
||||
</CloseWrapper>
|
||||
|
||||
@@ -79,9 +79,8 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
width = 600
|
||||
} = props || {};
|
||||
const {
|
||||
handleShowCompatibleAlert,
|
||||
setWarningStatus,
|
||||
handleEvaluate,
|
||||
handleDoEvalute,
|
||||
generateGPUIds,
|
||||
cancelEvaluate,
|
||||
submitAnyway,
|
||||
@@ -228,17 +227,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
};
|
||||
|
||||
const handleCheckCompatibility = async (formData: FormData) => {
|
||||
const evalutionData = await handleEvaluate(formData);
|
||||
|
||||
if (evalutionData?.compatible) {
|
||||
setWarningStatus({
|
||||
show: false,
|
||||
message: ''
|
||||
});
|
||||
} else {
|
||||
handleShowCompatibleAlert?.(evalutionData);
|
||||
}
|
||||
return evalutionData;
|
||||
handleDoEvalute(formData);
|
||||
};
|
||||
|
||||
const handleCheckFormData = () => {
|
||||
@@ -551,9 +540,12 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
<ModalFooter
|
||||
onCancel={handleCancel}
|
||||
onOk={handleSumit}
|
||||
showOkBtn={!warningStatus.show}
|
||||
showOkBtn={
|
||||
!warningStatus.show || warningStatus.type === 'success'
|
||||
}
|
||||
extra={
|
||||
warningStatus.show && (
|
||||
warningStatus.show &&
|
||||
warningStatus.type !== 'success' && (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={handleSubmitAnyway}
|
||||
|
||||
@@ -78,6 +78,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
const {
|
||||
handleShowCompatibleAlert,
|
||||
setWarningStatus,
|
||||
handleBackendChangeBefore,
|
||||
handleOnValuesChange,
|
||||
checkTokenRef,
|
||||
warningStatus,
|
||||
@@ -144,7 +145,12 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
} else {
|
||||
setIsGGUF(false);
|
||||
}
|
||||
|
||||
const data = form.current.form.getFieldsValue?.();
|
||||
const res = handleBackendChangeBefore(data);
|
||||
if (res.show) {
|
||||
return;
|
||||
}
|
||||
if (data.local_path || props.source !== modelSourceMap.local_path_value) {
|
||||
handleOnValuesChange?.({
|
||||
changedValues: {},
|
||||
@@ -303,9 +309,12 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
<ModalFooter
|
||||
onCancel={handleCancel}
|
||||
onOk={handleSumit}
|
||||
showOkBtn={!warningStatus.show}
|
||||
showOkBtn={
|
||||
!warningStatus.show || warningStatus.type === 'success'
|
||||
}
|
||||
extra={
|
||||
warningStatus.show && (
|
||||
warningStatus.show &&
|
||||
warningStatus.type !== 'success' && (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={handleSubmitAnyway}
|
||||
|
||||
@@ -83,6 +83,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
||||
});
|
||||
const [sortType, setSortType] = useState<string>('size');
|
||||
const [current, setCurrent] = useState<string>('');
|
||||
const currentPathRef = useRef<string>('');
|
||||
const modelFilesSortOptions = useRef<any[]>([
|
||||
{
|
||||
label: intl.formatMessage({ id: 'models.sort.size' }),
|
||||
@@ -100,6 +101,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
||||
const handleSelectModelFile = (item: any) => {
|
||||
props.onSelectFile?.(item);
|
||||
setCurrent(item.path);
|
||||
currentPathRef.current = item.path;
|
||||
};
|
||||
|
||||
const parseFilename = (filename: string) => {
|
||||
@@ -274,7 +276,13 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
||||
evaluateResult: evaluationList[index]
|
||||
};
|
||||
});
|
||||
handleSelectModelFile(resultList[0]);
|
||||
const currentItem = _.find(
|
||||
resultList,
|
||||
(item: any) => item.path === currentPathRef.current
|
||||
);
|
||||
if (currentItem) {
|
||||
handleSelectModelFile(currentItem);
|
||||
}
|
||||
setDataSource({ fileList: resultList, loading: false });
|
||||
setIsEvaluating(false);
|
||||
} catch (error) {
|
||||
|
||||
@@ -18,6 +18,12 @@ const CompatibleTag = styled(Tag)`
|
||||
background: transparent !important;
|
||||
`;
|
||||
|
||||
const ClaimTag = styled(Tag)`
|
||||
margin: 0;
|
||||
opacity: 0.7;
|
||||
border-radius: var(--border-radius-base);
|
||||
`;
|
||||
|
||||
const IncompatibleInfo = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -61,6 +61,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
||||
];
|
||||
const [isEvaluating, setIsEvaluating] = useState<boolean>(false);
|
||||
const [current, setCurrent] = useState<string>('');
|
||||
const currentRef = useRef<string>('');
|
||||
const cacheRepoOptions = useRef<any[]>([]);
|
||||
const axiosTokenRef = useRef<any>(null);
|
||||
const checkTokenRef = useRef<any>(null);
|
||||
@@ -100,6 +101,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
||||
const handleOnSelectModel = (item: any) => {
|
||||
onSelectModel(item);
|
||||
setCurrent(item.id);
|
||||
currentRef.current = item.id;
|
||||
};
|
||||
|
||||
// huggeface
|
||||
@@ -222,7 +224,12 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
||||
repoOptions: resultList
|
||||
};
|
||||
});
|
||||
handleOnSelectModel(resultList[0]);
|
||||
const currentItem = resultList.find(
|
||||
(item) => item.id === currentRef.current
|
||||
);
|
||||
if (currentItem) {
|
||||
handleOnSelectModel(currentItem);
|
||||
}
|
||||
} catch (error) {
|
||||
setIsEvaluating(false);
|
||||
}
|
||||
@@ -264,9 +271,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
||||
handleOnSelectModel(list[0]);
|
||||
setLoadingModel?.(false);
|
||||
|
||||
timer.current = setTimeout(() => {
|
||||
handleEvaluate(list);
|
||||
}, 200);
|
||||
handleEvaluate(list);
|
||||
} catch (error: any) {
|
||||
setDataSource({
|
||||
repoOptions: [],
|
||||
|
||||
@@ -740,7 +740,7 @@ const Models: React.FC<ModelsProps> = ({
|
||||
placeholder={intl.formatMessage({
|
||||
id: 'models.filter.category'
|
||||
})}
|
||||
style={{ width: 230 }}
|
||||
style={{ width: 180 }}
|
||||
size="large"
|
||||
maxTagCount={1}
|
||||
onChange={handleCategoryChange}
|
||||
|
||||
@@ -58,7 +58,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
const {
|
||||
setWarningStatus,
|
||||
generateGPUIds,
|
||||
handleOnValuesChange,
|
||||
handleBackendChangeBefore,
|
||||
checkTokenRef,
|
||||
warningStatus
|
||||
} = useCheckCompatibility();
|
||||
@@ -68,6 +68,8 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
const localPathCache = useRef<string>('');
|
||||
const submitAnyway = useRef<boolean>(false);
|
||||
|
||||
const handleOnValuesChange = (data: any) => {};
|
||||
|
||||
// voxbox is not support multi gpu
|
||||
const handleSetGPUIds = (backend: string) => {
|
||||
const gpuids = form.getFieldValue(['gpu_selector', 'gpu_ids']) || [];
|
||||
@@ -91,6 +93,10 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
handleSetGPUIds(backend);
|
||||
|
||||
const data = form.getFieldsValue?.();
|
||||
const res = handleBackendChangeBefore(data);
|
||||
if (res.show) {
|
||||
return;
|
||||
}
|
||||
if (data.local_path || data.source !== modelSourceMap.local_path_value) {
|
||||
handleOnValuesChange?.({
|
||||
changedValues: {},
|
||||
@@ -390,9 +396,10 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
<ModalFooter
|
||||
onCancel={onCancel}
|
||||
onOk={handleSumit}
|
||||
showOkBtn={!warningStatus.show}
|
||||
showOkBtn={!warningStatus.show || warningStatus.type === 'success'}
|
||||
extra={
|
||||
warningStatus.show && (
|
||||
warningStatus.show &&
|
||||
warningStatus.type !== 'success' && (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={handleSubmitAnyway}
|
||||
|
||||
Reference in New Issue
Block a user