mirror of https://github.com/langgenius/dify.git
fix: remove duplicate RAG tool heading and fix select callback type
This commit is contained in:
parent
bebcbfd80e
commit
c94dc52310
|
|
@ -3,12 +3,7 @@ import type {
|
|||
RefObject,
|
||||
SetStateAction,
|
||||
} from 'react'
|
||||
import {
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import type {
|
||||
BlockEnum,
|
||||
|
|
@ -35,6 +30,7 @@ import Divider from '@/app/components/base/divider'
|
|||
import { RiArrowRightUpLine } from '@remixicon/react'
|
||||
import { getMarketplaceUrl } from '@/utils/var'
|
||||
import { useGetLanguage } from '@/context/i18n'
|
||||
import type { OnSelectBlock } from '@/app/components/workflow/types'
|
||||
|
||||
const marketplaceFooterClassName = 'system-sm-medium z-10 flex h-8 flex-none cursor-pointer items-center rounded-b-lg border-[0.5px] border-t border-components-panel-border bg-components-panel-bg-blur px-4 py-1 text-text-accent-light-mode-only shadow-lg'
|
||||
|
||||
|
|
@ -202,6 +198,12 @@ const AllTools = ({
|
|||
&& (featuredLoading || featuredPlugins.length > 0)
|
||||
const shouldShowMarketplaceFooter = enable_marketplace && !hasFilter
|
||||
|
||||
const handleRAGSelect = useCallback<OnSelectBlock>((type, pluginDefaultValue) => {
|
||||
if (!pluginDefaultValue)
|
||||
return
|
||||
onSelect(type, pluginDefaultValue as ToolDefaultValue)
|
||||
}, [onSelect])
|
||||
|
||||
return (
|
||||
<div className={cn('min-w-[400px] max-w-[500px]', className)}>
|
||||
<div className='flex items-center justify-between border-b border-divider-subtle px-3'>
|
||||
|
|
@ -236,7 +238,7 @@ const AllTools = ({
|
|||
{isShowRAGRecommendations && onTagsChange && (
|
||||
<RAGToolRecommendations
|
||||
viewType={isSupportGroupView ? activeView : ViewType.flat}
|
||||
onSelect={onSelect}
|
||||
onSelect={handleRAGSelect}
|
||||
onTagsChange={onTagsChange}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -274,7 +276,6 @@ const AllTools = ({
|
|||
hasSearchText={hasSearchText}
|
||||
selectedTools={selectedTools}
|
||||
canChooseMCPTool={canChooseMCPTool}
|
||||
isShowRAGRecommendations={isShowRAGRecommendations}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import {
|
||||
useMemo,
|
||||
useRef,
|
||||
} from 'react'
|
||||
import { useCallback, useMemo, useRef } from 'react'
|
||||
import type { BlockEnum, ToolWithProvider } from '../../types'
|
||||
import type { ToolDefaultValue } from '../types'
|
||||
import { ViewType } from '../view-type-select'
|
||||
|
|
@ -12,9 +9,10 @@ import ToolListTreeView from '../tool/tool-list-tree-view/list'
|
|||
import ToolListFlatView from '../tool/tool-list-flat-view/list'
|
||||
import UninstalledItem from './uninstalled-item'
|
||||
import type { Plugin } from '@/app/components/plugins/types'
|
||||
import type { OnSelectBlock } from '@/app/components/workflow/types'
|
||||
|
||||
type ListProps = {
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: OnSelectBlock
|
||||
tools: ToolWithProvider[]
|
||||
viewType: ViewType
|
||||
unInstalledPlugins: Plugin[]
|
||||
|
|
@ -62,6 +60,10 @@ const List = ({
|
|||
|
||||
const toolRefs = useRef({})
|
||||
|
||||
const handleSelect = useCallback((type: BlockEnum, tool: ToolDefaultValue) => {
|
||||
onSelect(type, tool)
|
||||
}, [onSelect])
|
||||
|
||||
return (
|
||||
<div className={cn('max-w-[100%] p-1', className)}>
|
||||
{!!tools.length && (
|
||||
|
|
@ -72,7 +74,7 @@ const List = ({
|
|||
payload={listViewToolData}
|
||||
isShowLetterIndex={false}
|
||||
hasSearchText={false}
|
||||
onSelect={onSelect}
|
||||
onSelect={handleSelect}
|
||||
canNotSelectMultiple
|
||||
indexBar={null}
|
||||
/>
|
||||
|
|
@ -80,7 +82,7 @@ const List = ({
|
|||
<ToolListTreeView
|
||||
payload={treeViewToolsData}
|
||||
hasSearchText={false}
|
||||
onSelect={onSelect}
|
||||
onSelect={handleSelect}
|
||||
canNotSelectMultiple
|
||||
/>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
import {
|
||||
memo,
|
||||
useMemo,
|
||||
useRef,
|
||||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { memo, useMemo, useRef } from 'react'
|
||||
import type { BlockEnum, ToolWithProvider } from '../types'
|
||||
import IndexBar, { groupItems } from './index-bar'
|
||||
import type { ToolDefaultValue, ToolValue } from './types'
|
||||
|
|
@ -28,7 +23,6 @@ type ToolsProps = {
|
|||
indexBarClassName?: string
|
||||
selectedTools?: ToolValue[]
|
||||
canChooseMCPTool?: boolean
|
||||
isShowRAGRecommendations?: boolean
|
||||
}
|
||||
const Tools = ({
|
||||
onSelect,
|
||||
|
|
@ -43,10 +37,8 @@ const Tools = ({
|
|||
indexBarClassName,
|
||||
selectedTools,
|
||||
canChooseMCPTool,
|
||||
isShowRAGRecommendations = false,
|
||||
}: ToolsProps) => {
|
||||
// const tools: any = []
|
||||
const { t } = useTranslation()
|
||||
const language = useGetLanguage()
|
||||
const isFlatView = viewType === ViewType.flat
|
||||
const isShowLetterIndex = isFlatView && tools.length > 10
|
||||
|
|
@ -105,11 +97,6 @@ const Tools = ({
|
|||
<Empty type={toolType!} isAgent={isAgent} />
|
||||
</div>
|
||||
)}
|
||||
{!!tools.length && isShowRAGRecommendations && (
|
||||
<div className='system-xs-medium px-3 pb-0.5 pt-1 text-text-tertiary'>
|
||||
{t('tools.allTools')}
|
||||
</div>
|
||||
)}
|
||||
{!!tools.length && (
|
||||
isFlatView ? (
|
||||
<ToolListFlatView
|
||||
|
|
|
|||
Loading…
Reference in New Issue