datasource

This commit is contained in:
zxhlyh
2025-05-23 10:46:28 +08:00
parent e3708bfa85
commit 23adc7d8a8
6 changed files with 105 additions and 22 deletions

View File

@ -1,6 +1,8 @@
import {
useCallback,
useRef,
} from 'react'
import { BlockEnum } from '../types'
import type {
OnSelectBlock,
ToolWithProvider,
@ -27,6 +29,10 @@ const DataSources = ({
}: AllToolsProps) => {
const pluginRef = useRef<ListRef>(null)
const wrapElemRef = useRef<HTMLDivElement>(null)
const formatedDataSources = dataSources.map(item => ({ ...item, tools: item.datasources || [] }))
const handleSelect = useCallback<OnSelectBlock>((_, toolDefaultValue) => {
onSelect(BlockEnum.DataSource, toolDefaultValue)
}, [onSelect])
return (
<div className={cn(className)}>
@ -38,8 +44,8 @@ const DataSources = ({
<Tools
className={toolContentClassName}
showWorkflowEmpty={false}
tools={dataSources}
onSelect={onSelect}
tools={formatedDataSources}
onSelect={handleSelect}
viewType={ViewType.flat}
hasSearchText={!!searchText}
/>

View File

@ -6,6 +6,7 @@ import classNames from '@/utils/classnames'
export const CUSTOM_GROUP_NAME = '@@@custom@@@'
export const WORKFLOW_GROUP_NAME = '@@@workflow@@@'
export const DATA_SOURCE_GROUP_NAME = '@@@data_source@@@'
export const AGENT_GROUP_NAME = '@@@agent@@@'
/*
{
@ -49,6 +50,8 @@ export const groupItems = (items: ToolWithProvider[], getFirstChar: (item: ToolW
groupName = CUSTOM_GROUP_NAME
else if (item.type === CollectionType.workflow)
groupName = WORKFLOW_GROUP_NAME
else if (item.type === CollectionType.datasource)
groupName = DATA_SOURCE_GROUP_NAME
else
groupName = AGENT_GROUP_NAME