From ff511c6f315ac07cdeabe271593d9a7e44753d49 Mon Sep 17 00:00:00 2001 From: twwu Date: Mon, 30 Jun 2025 17:54:33 +0800 Subject: [PATCH] refactor: Remove unused variables and simplify next button logic in TestRunPanel --- .../components/panel/test-run/hooks.ts | 3 --- .../components/panel/test-run/index.tsx | 18 ++++-------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts b/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts index 46e5627184..262e4216a3 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts +++ b/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts @@ -84,8 +84,6 @@ export const useDatasourceOptions = () => { export const useLocalFile = () => { const [fileList, setFileList] = useState([]) - const allFileLoaded = useMemo(() => (fileList.length > 0 && fileList.every(file => file.file.id)), [fileList]) - const updateFile = (fileItem: FileItem, progress: number, list: FileItem[]) => { const newList = produce(list, (draft) => { const targetIndex = draft.findIndex(file => file.fileID === fileItem.fileID) @@ -103,7 +101,6 @@ export const useLocalFile = () => { return { fileList, - allFileLoaded, updateFile, updateFileList, } diff --git a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx index 5eb4c14dee..f2f909b26b 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx +++ b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx @@ -3,9 +3,7 @@ import { useCallback, useMemo, useState } from 'react' import { useLocalFile, useOnlineDocuments, useTestRunSteps, useWebsiteCrawl } from './hooks' import DataSourceOptions from './data-source-options' import LocalFile from './data-source/local-file' -import { useProviderContextSelector } from '@/context/provider-context' import OnlineDocuments from './data-source/online-documents' -import VectorSpaceFull from '@/app/components/billing/vector-space-full' import WebsiteCrawl from './data-source/website-crawl' import Actions from './data-source/actions' import DocumentProcessing from './document-processing' @@ -20,8 +18,6 @@ import OnlineDrive from './data-source/online-drive' const TestRunPanel = () => { const setShowDebugAndPreviewPanel = useWorkflowStoreWithSelector(state => state.setShowDebugAndPreviewPanel) - const plan = useProviderContextSelector(state => state.plan) - const enableBilling = useProviderContextSelector(state => state.enableBilling) const [datasource, setDatasource] = useState() const { @@ -32,7 +28,6 @@ const TestRunPanel = () => { } = useTestRunSteps() const { fileList, - allFileLoaded, updateFile, updateFileList, } = useLocalFile() @@ -50,20 +45,18 @@ const TestRunPanel = () => { } = useWebsiteCrawl() const { handleRun } = useWorkflowRun() - const isVectorSpaceFull = plan.usage.vectorSpace >= plan.total.vectorSpace - const isShowVectorSpaceFull = allFileLoaded && isVectorSpaceFull && enableBilling const datasourceType = datasource?.nodeData.provider_type const nextBtnDisabled = useMemo(() => { if (!datasource) return true if (datasourceType === DatasourceType.localFile) - return isShowVectorSpaceFull || !fileList.length || fileList.some(file => !file.file.id) + return !fileList.length || fileList.some(file => !file.file.id) if (datasourceType === DatasourceType.onlineDocument) - return isShowVectorSpaceFull || !onlineDocuments.length + return !onlineDocuments.length if (datasourceType === DatasourceType.websiteCrawl) - return isShowVectorSpaceFull || !websitePages.length + return !websitePages.length return false - }, [datasource, datasourceType, isShowVectorSpaceFull, fileList, onlineDocuments.length, websitePages.length]) + }, [datasource, datasourceType, fileList, onlineDocuments.length, websitePages.length]) const handleClose = () => { setShowDebugAndPreviewPanel(false) @@ -158,9 +151,6 @@ const TestRunPanel = () => { /> ) } - {isShowVectorSpaceFull && ( - - )}