From de2a4fe3a5182d5b9db0b7b5be4e2fce32d02f65 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Mon, 29 Dec 2025 11:31:58 +0800 Subject: [PATCH] type check --- .../billing/upgrade-btn/index.spec.tsx | 12 ++++++------ web/app/components/billing/upgrade-btn/index.tsx | 2 +- web/app/components/datasets/create/index.tsx | 7 ++++--- .../datasets/create/step-three/index.spec.tsx | 3 ++- .../datasets/create/step-two/index.tsx | 6 +++--- .../detail/completed/common/batch-action.tsx | 2 +- web/app/components/datasets/documents/list.tsx | 4 ++-- .../components/plugins/marketplace/context.tsx | 3 ++- web/app/components/plugins/utils.ts | 7 +++++-- .../workflow/block-selector/blocks.tsx | 1 + web/config/index.ts | 1 + web/i18n/en-US/dataset.json | 1 + web/types/i18n.d.ts | 16 +++++++++++----- 13 files changed, 40 insertions(+), 25 deletions(-) diff --git a/web/app/components/billing/upgrade-btn/index.spec.tsx b/web/app/components/billing/upgrade-btn/index.spec.tsx index 92756bfea2..a9db6c946f 100644 --- a/web/app/components/billing/upgrade-btn/index.spec.tsx +++ b/web/app/components/billing/upgrade-btn/index.spec.tsx @@ -66,7 +66,7 @@ describe('UpgradeBtn', () => { it('should render custom label when labelKey is provided', () => { // Act - render() + render() // Assert expect(screen.getByText(/custom\.label\.key/i)).toBeInTheDocument() @@ -74,7 +74,7 @@ describe('UpgradeBtn', () => { it('should render custom label in plain button when labelKey is provided with isPlain', () => { // Act - render() + render() // Assert const button = screen.getByRole('button') @@ -372,7 +372,7 @@ describe('UpgradeBtn', () => { it('should handle empty string labelKey', () => { // Act - render() + render() // Assert - empty labelKey is falsy, so it falls back to default label expect(screen.getByText(/billing\.upgradeBtn\.encourage/i)).toBeInTheDocument() @@ -391,7 +391,7 @@ describe('UpgradeBtn', () => { it('should handle isPlain with custom labelKey', () => { // Act - render() + render() // Assert - labelKey should override plain text expect(screen.getByText(/custom\.key/i)).toBeInTheDocument() @@ -400,7 +400,7 @@ describe('UpgradeBtn', () => { it('should handle isShort with custom labelKey', () => { // Act - render() + render() // Assert - labelKey should override isShort behavior expect(screen.getByText(/custom\.short\.key/i)).toBeInTheDocument() @@ -423,7 +423,7 @@ describe('UpgradeBtn', () => { isShort onClick={handleClick} loc="test-loc" - labelKey="custom.all" + labelKey={'custom.all' as any} />, ) const badge = screen.getByText(/custom\.all/i) diff --git a/web/app/components/billing/upgrade-btn/index.tsx b/web/app/components/billing/upgrade-btn/index.tsx index 79c9ba52a1..737ec03fc8 100644 --- a/web/app/components/billing/upgrade-btn/index.tsx +++ b/web/app/components/billing/upgrade-btn/index.tsx @@ -17,7 +17,7 @@ type Props = { isShort?: boolean onClick?: () => void loc?: string - labelKey?: I18nKeysWithPrefix<'billing', 'upgradeBtn.'> + labelKey?: Exclude, 'plans.community.features' | 'plans.enterprise.features' | 'plans.premium.features'> } const UpgradeBtn: FC = ({ diff --git a/web/app/components/datasets/create/index.tsx b/web/app/components/datasets/create/index.tsx index 498113e775..a028bc0775 100644 --- a/web/app/components/datasets/create/index.tsx +++ b/web/app/components/datasets/create/index.tsx @@ -1,6 +1,7 @@ 'use client' import type { NotionPage } from '@/models/common' import type { CrawlOptions, CrawlResultItem, createDocumentResponse, FileItem } from '@/models/datasets' +import type { RETRIEVE_METHOD } from '@/types/app' import { produce } from 'immer' import * as React from 'react' import { useCallback, useState } from 'react' @@ -43,7 +44,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { const [dataSourceType, setDataSourceType] = useState(DataSourceType.FILE) const [step, setStep] = useState(1) const [indexingTypeCache, setIndexTypeCache] = useState('') - const [retrievalMethodCache, setRetrievalMethodCache] = useState('') + const [retrievalMethodCache, setRetrievalMethodCache] = useState('') const [fileList, setFiles] = useState([]) const [result, setResult] = useState() const [notionPages, setNotionPages] = useState([]) @@ -90,7 +91,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { setResult(res) }, []) - const updateRetrievalMethodCache = useCallback((method: string) => { + const updateRetrievalMethodCache = useCallback((method: RETRIEVE_METHOD | '') => { setRetrievalMethodCache(method) }, []) @@ -166,7 +167,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { datasetId={datasetId} datasetName={datasetDetail?.name} indexingType={datasetDetail?.indexing_technique || indexingTypeCache} - retrievalMethod={datasetDetail?.retrieval_model_dict?.search_method || retrievalMethodCache} + retrievalMethod={datasetDetail?.retrieval_model_dict?.search_method || retrievalMethodCache || undefined} creationCache={result} /> )} diff --git a/web/app/components/datasets/create/step-three/index.spec.tsx b/web/app/components/datasets/create/step-three/index.spec.tsx index 65d20b92d5..66abec755f 100644 --- a/web/app/components/datasets/create/step-three/index.spec.tsx +++ b/web/app/components/datasets/create/step-three/index.spec.tsx @@ -1,5 +1,6 @@ import type { createDocumentResponse, FullDocumentDetail, IconInfo } from '@/models/datasets' import { render, screen } from '@testing-library/react' +import { RETRIEVE_METHOD } from '@/types/app' import StepThree from './index' // Mock the EmbeddingProcess component since it has complex async logic @@ -321,7 +322,7 @@ describe('StepThree', () => { describe('retrievalMethod prop', () => { it('should pass retrievalMethod to EmbeddingProcess', () => { // Arrange & Act - renderStepThree({ retrievalMethod: 'semantic_search' }) + renderStepThree({ retrievalMethod: RETRIEVE_METHOD.semantic }) // Assert expect(screen.getByTestId('ep-retrieval-method')).toHaveTextContent('semantic_search') diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index 3c97afd947..7f3b4b3589 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -88,7 +88,7 @@ type StepTwoProps = { websiteCrawlJobId?: string onStepChange?: (delta: number) => void updateIndexingTypeCache?: (type: string) => void - updateRetrievalMethodCache?: (method: string) => void + updateRetrievalMethodCache?: (method: RETRIEVE_METHOD | '') => void updateResultCache?: (res: createDocumentResponse) => void onSave?: () => void onCancel?: () => void @@ -552,7 +552,7 @@ const StepTwo = ({ onSuccess(data) { updateIndexingTypeCache?.(indexType as string) updateResultCache?.(data) - updateRetrievalMethodCache?.(retrievalConfig.search_method as string) + updateRetrievalMethodCache?.(retrievalConfig.search_method as RETRIEVE_METHOD) }, }, ) @@ -562,7 +562,7 @@ const StepTwo = ({ onSuccess(data) { updateIndexingTypeCache?.(indexType as string) updateResultCache?.(data) - updateRetrievalMethodCache?.(retrievalConfig.search_method as string) + updateRetrievalMethodCache?.(retrievalConfig.search_method as RETRIEVE_METHOD) }, }) } diff --git a/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx b/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx index 1cf9ccae13..db36ca471a 100644 --- a/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx +++ b/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx @@ -100,7 +100,7 @@ const BatchAction: FC = ({ onClick={onBatchReIndex} > - {t(`${i18nPrefix}.reIndex`)} + {t(`${i18nPrefix}.reIndex`, { ns: 'dataset' })} )}