diff --git a/react/src/components/ImportFromHuggingFaceModal.tsx b/react/src/components/ImportFromHuggingFaceModal.tsx index 36777e2cb..d8d377e26 100644 --- a/react/src/components/ImportFromHuggingFaceModal.tsx +++ b/react/src/components/ImportFromHuggingFaceModal.tsx @@ -6,17 +6,14 @@ import Flex from './Flex'; import { useToggle } from 'ahooks'; import { Button, - Descriptions, Form, FormInstance, Input, - Space, Switch, theme, Typography, } from 'antd'; import _ from 'lodash'; -import { CheckIcon } from 'lucide-react'; import React, { useEffect, useRef, useState, useTransition } from 'react'; import { useTranslation } from 'react-i18next'; @@ -39,7 +36,6 @@ const ImportFromHuggingFaceModal: React.FC = ({ const formRef = useRef>(null); const [isImportOnly, { toggle: toggleIsImportOnly }] = useToggle(false); const [huggingFaceURL, setHuggingFaceURL] = useState(); - const [typedURL, setTypedURL] = useState(''); const baiClient = useSuspendedBackendaiClient(); const [isPendingCheck, startCheckTransition] = useTransition(); @@ -76,16 +72,6 @@ const ImportFromHuggingFaceModal: React.FC = ({ const isHuggingfaceURLExisted = !_.isEmpty( hugginFaceModelInfo.data.model_name, ); - const shouldSkipURLCheck = - isHuggingfaceURLExisted && huggingFaceURL === typedURL; - - // reset when modal is closed - useEffect(() => { - if (!baiModalProps.open) { - setHuggingFaceURL(undefined); - setTypedURL(''); - } - }, [baiModalProps.open]); // validate when huggingFaceModelInfo is updated useEffect(() => { @@ -98,19 +84,12 @@ const ImportFromHuggingFaceModal: React.FC = ({ formRef.current ?.validateFields() .then((values) => { - // TODO: Implement import from Hugging Face - onRequestClose(); - }) - .catch(() => {}); - }; - - const handleOnCheck = () => { - formRef.current - ?.validateFields(['url']) - .then((v) => { startCheckTransition(() => { - setHuggingFaceURL(v?.url); + setHuggingFaceURL(values?.url); }); + + // TODO: Implement import from Hugging Face + // onRequestClose(); }) .catch(() => {}); }; @@ -124,7 +103,7 @@ const ImportFromHuggingFaceModal: React.FC = ({ type="primary" htmlType="submit" onClick={handleOnClick} - disabled={!shouldSkipURLCheck} + loading={isPendingCheck} > {isImportOnly ? t('data.modelStore.Import') @@ -141,86 +120,43 @@ const ImportFromHuggingFaceModal: React.FC = ({ layout="vertical" requiredMark="optional" > - - - - { - handleOnCheck(); - }} - onChange={(e) => { - setTypedURL(e.target.value); - }} - /> - - - - { - if ( - !isHuggingfaceURLExisted && - hugginFaceModelInfo.data?.isError && - hugginFaceModelInfo.data.url === typedURL - ) { - return Promise.reject( - t('data.modelStore.InvalidHuggingFaceUrl'), - ); - } else { - if (shouldSkipURLCheck) { - return Promise.resolve(); - } else { - return Promise.reject( - t('data.modelStore.InvalidHuggingFaceUrl'), - ); - } - } - }, + { + if ( + !isHuggingfaceURLExisted && + hugginFaceModelInfo.data?.isError && + hugginFaceModelInfo.data.url === value + ) { + return Promise.reject( + t('data.modelStore.InvalidHuggingFaceUrl'), + ); + } else { + return Promise.resolve(); + } }, - ]} - > + }, + ]} + > + - - - {shouldSkipURLCheck && hugginFaceModelInfo.data?.model_name} - - - {shouldSkipURLCheck && hugginFaceModelInfo.data?.author} - - + + + + +