, 'children' | 'className' | 'variant' | 'render' | 'nativeButton'>
+
+type StaticRadioCardProps = BaseProps & {
+ noRadio: true
+ value?: never
+ checked?: never
+}
+
+type Props = SelectableRadioCardProps | StaticRadioCardProps
+
+function RadioCard(props: Props) {
+ if (props.noRadio) {
+ const {
+ icon,
+ iconBgClassName = 'bg-[#F5F3FF]',
+ title,
+ description,
+ chosenConfig,
+ chosenConfigWrapClassName,
+ className,
+ } = props
+
+ return (
+
-
{/* Child chunk for retrieval */}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/__tests__/index.spec.tsx
index 5b80b8ef31..04b8e16f17 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/__tests__/index.spec.tsx
@@ -1,5 +1,6 @@
import type { Mock } from 'vitest'
import type { OnlineDriveFile } from '@/models/pipeline'
+import { RadioGroup } from '@langgenius/dify-ui/radio-group'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import * as React from 'react'
import { OnlineDriveFileType } from '@/models/pipeline'
@@ -1378,7 +1379,11 @@ describe('Item', () => {
it('should show radio as checked when isSelected is true', () => {
const props = createItemProps({ isSelected: true, isMultipleChoice: false })
- render(
)
+ render(
+
+
+ ,
+ )
const radio = getRadio()
expect(radio).toHaveAttribute('aria-checked', 'true')
})
@@ -1481,7 +1486,17 @@ describe('Item', () => {
const onSelect = vi.fn()
const file = createMockOnlineDriveFile()
const props = createItemProps({ file, onSelect, isMultipleChoice: false })
- render(
)
+ render(
+
{
+ if (fileId === file.id)
+ onSelect(file)
+ }}
+ >
+
+ ,
+ )
const radio = getRadio()
fireEvent.click(radio)
expect(onSelect).toHaveBeenCalledWith(file)
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/__tests__/item.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/__tests__/item.spec.tsx
index f4ad53bbe7..a2bdd69d58 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/__tests__/item.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/__tests__/item.spec.tsx
@@ -1,14 +1,9 @@
import type { OnlineDriveFile } from '@/models/pipeline'
+import { RadioGroup } from '@langgenius/dify-ui/radio-group'
import { fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import Item from '../item'
-vi.mock('@/app/components/base/radio/ui', () => ({
- default: ({ isChecked, onCheck }: { isChecked: boolean, onCheck: () => void }) => (
-
- ),
-}))
-
vi.mock('../file-icon', () => ({
default: () =>
,
}))
@@ -43,8 +38,13 @@ describe('Item', () => {
})
it('should render radio for file type in single choice mode', () => {
- render(
)
- expect(screen.getByTestId('radio')).toBeInTheDocument()
+ render(
+
+
+ ,
+ )
+
+ expect(screen.getByRole('radio', { name: 'test.pdf' })).toBeInTheDocument()
})
it('should not render checkbox for bucket type', () => {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx
index 00386ec135..a74fd74324 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-drive/file-list/list/index.tsx
@@ -1,4 +1,5 @@
import type { OnlineDriveFile } from '@/models/pipeline'
+import { RadioGroup } from '@langgenius/dify-ui/radio-group'
import { RiLoader2Line } from '@remixicon/react'
import * as React from 'react'
import { useEffect, useRef } from 'react'
@@ -53,6 +54,25 @@ const List = ({
const isPartialLoading = isLoading && fileList.length > 0
const isEmptyFolder = !isLoading && fileList.length === 0 && keywords.length === 0
const isSearchResultEmpty = !isLoading && fileList.length === 0 && keywords.length > 0
+ const selectedFileId = selectedFileIds[0]
+ const handleRadioChange = (fileId: string) => {
+ const selectedFile = fileList.find(file => file.id === fileId)
+ if (selectedFile)
+ handleSelectFile(selectedFile)
+ }
+ const fileItems = fileList.map((file) => {
+ const isSelected = selectedFileIds.includes(file.id)
+ return (
+
+ )
+ })
return (
@@ -73,21 +93,18 @@ const List = ({
}
{fileList.length > 0 && (
- {
- fileList.map((file) => {
- const isSelected = selectedFileIds.includes(file.id)
- return (
-
- )
- })
- }
+ {supportBatchUpload
+ ? fileItems
+ : (
+
+ {fileItems}
+
+ )}
{
isPartialLoading && (
| React.KeyboardEvent
) => {
- e.stopPropagation()
- onSelect(file)
- }, [file, onSelect])
-
const handleCheckboxSelect = useCallback(() => {
onSelect(file)
}, [file, onSelect])
@@ -70,12 +65,14 @@ const Item = ({
)}
{!isBucket && !isMultipleChoice && (
-
+ event.stopPropagation()}>
+
+
)}
{disabled
? (
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result-item.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result-item.spec.tsx
index b1bfc208d0..ea7ef85a78 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result-item.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/crawled-result-item.spec.tsx
@@ -1,4 +1,5 @@
import type { CrawlResultItem as CrawlResultItemType } from '@/models/datasets'
+import { RadioGroup } from '@langgenius/dify-ui/radio-group'
import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import CrawledResultItem from '../crawled-result-item'
@@ -9,12 +10,6 @@ vi.mock('@langgenius/dify-ui/button', () => ({
),
}))
-vi.mock('@/app/components/base/radio/ui', () => ({
- default: ({ isChecked, onCheck }: { isChecked: boolean, onCheck: () => void }) => (
-
- ),
-}))
-
describe('CrawledResultItem', () => {
const defaultProps = {
payload: {
@@ -47,8 +42,13 @@ describe('CrawledResultItem', () => {
})
it('should render radio in single choice mode', () => {
- render()
- expect(screen.getByTestId('radio')).toBeInTheDocument()
+ render(
+
+
+ ,
+ )
+
+ expect(screen.getByRole('radio', { name: /Test Page/ })).toBeInTheDocument()
})
it('should show preview button when showPreview is true', () => {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/index.spec.tsx
index f594f5c918..c6f86e3ada 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/__tests__/index.spec.tsx
@@ -1,4 +1,5 @@
import type { CrawlResultItem as CrawlResultItemType } from '@/models/datasets'
+import { RadioGroup } from '@langgenius/dify-ui/radio-group'
import { fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
@@ -260,18 +261,24 @@ describe('CrawledResultItem', () => {
it('should toggle radio state when isMultipleChoice is false', () => {
const mockOnCheckChange = vi.fn()
- const { container } = render(
- ,
+ render(
+ {
+ if (sourceUrl === defaultProps.payload.source_url)
+ mockOnCheckChange(true)
+ }}
+ >
+
+ ,
)
- // Act - Radio uses size-4 rounded-full classes
- const radio = container.querySelector('.size-4.rounded-full')!
- fireEvent.click(radio)
+ fireEvent.click(screen.getByRole('radio', { name: /Test Page Title/ }))
expect(mockOnCheckChange).toHaveBeenCalledWith(true)
})
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result-item.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result-item.tsx
index a1df2ed33c..d7ca87ef88 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result-item.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/crawled-result-item.tsx
@@ -3,10 +3,9 @@ import type { CrawlResultItem as CrawlResultItemType } from '@/models/datasets'
import { Button } from '@langgenius/dify-ui/button'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { cn } from '@langgenius/dify-ui/cn'
+import { Radio } from '@langgenius/dify-ui/radio'
import * as React from 'react'
-import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
-import Radio from '@/app/components/base/radio/ui'
type CrawledResultItemProps = {
payload: CrawlResultItemType
@@ -29,10 +28,6 @@ const CrawledResultItem = ({
}: CrawledResultItemProps) => {
const { t } = useTranslation()
- const handleCheckChange = useCallback(() => {
- onCheckChange(!isChecked)
- }, [isChecked, onCheckChange])
-
return (
)
: (
- <>
+