mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
datasource
This commit is contained in:
@ -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}
|
||||
/>
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user