fix: select tool can select all

This commit is contained in:
Joel 2025-05-12 13:37:40 +08:00
parent 274d5c02f6
commit 626f2524e2
7 changed files with 27 additions and 8 deletions

View File

@ -32,7 +32,8 @@ type AllToolsProps = {
workflowTools: ToolWithProvider[]
mcpTools: ToolWithProvider[]
onSelect: OnSelectBlock
onSelectMultiple: (type: BlockEnum, tools: ToolDefaultValue[]) => void
canNotSelectMultiple?: boolean
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
selectedTools?: ToolValue[]
}
@ -44,6 +45,7 @@ const AllTools = ({
searchText,
tags = DEFAULT_TAGS,
onSelect,
canNotSelectMultiple,
onSelectMultiple,
buildInTools,
workflowTools,
@ -139,6 +141,7 @@ const AllTools = ({
showWorkflowEmpty={activeTab === ToolTypeEnum.Workflow}
tools={tools}
onSelect={onSelect}
canNotSelectMultiple={canNotSelectMultiple}
onSelectMultiple={onSelectMultiple}
viewType={isSupportGroupView ? activeView : ViewType.flat}
hasSearchText={!!searchText}

View File

@ -73,6 +73,7 @@ const Tabs: FC<TabsProps> = ({
searchText={searchText}
onSelect={onSelect}
tags={tags}
canNotSelectMultiple
buildInTools={buildInTools || []}
customTools={customTools || []}
workflowTools={workflowTools || []}

View File

@ -13,7 +13,8 @@ type Props = {
isShowLetterIndex: boolean
hasSearchText: boolean
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
onSelectMultiple: (type: BlockEnum, tools: ToolDefaultValue[]) => void
canNotSelectMultiple?: boolean
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
letters: string[]
toolRefs: any
selectedTools?: ToolValue[]
@ -25,6 +26,7 @@ const ToolViewFlatView: FC<Props> = ({
isShowLetterIndex,
hasSearchText,
onSelect,
canNotSelectMultiple,
onSelectMultiple,
toolRefs,
selectedTools,
@ -55,6 +57,7 @@ const ToolViewFlatView: FC<Props> = ({
isShowLetterIndex={isShowLetterIndex}
hasSearchText={hasSearchText}
onSelect={onSelect}
canNotSelectMultiple={canNotSelectMultiple}
onSelectMultiple={onSelectMultiple}
selectedTools={selectedTools}
/>

View File

@ -12,7 +12,8 @@ type Props = {
toolList: ToolWithProvider[]
hasSearchText: boolean
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
onSelectMultiple: (type: BlockEnum, tools: ToolValue[]) => void
canNotSelectMultiple?: boolean
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
selectedTools?: ToolValue[]
}
@ -21,6 +22,7 @@ const Item: FC<Props> = ({
toolList,
hasSearchText,
onSelect,
canNotSelectMultiple,
onSelectMultiple,
selectedTools,
}) => {
@ -38,6 +40,7 @@ const Item: FC<Props> = ({
isShowLetterIndex={false}
hasSearchText={hasSearchText}
onSelect={onSelect}
canNotSelectMultiple={canNotSelectMultiple}
onSelectMultiple={onSelectMultiple}
selectedTools={selectedTools}
/>

View File

@ -12,7 +12,8 @@ type Props = {
payload: Record<string, ToolWithProvider[]>
hasSearchText: boolean
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
onSelectMultiple: (type: BlockEnum, tools: ToolValue[]) => void
canNotSelectMultiple?: boolean
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
selectedTools?: ToolValue[]
}
@ -20,6 +21,7 @@ const ToolListTreeView: FC<Props> = ({
payload,
hasSearchText,
onSelect,
canNotSelectMultiple,
onSelectMultiple,
selectedTools,
}) => {
@ -48,6 +50,7 @@ const ToolListTreeView: FC<Props> = ({
toolList={payload[groupName]}
hasSearchText={hasSearchText}
onSelect={onSelect}
canNotSelectMultiple={canNotSelectMultiple}
onSelectMultiple={onSelectMultiple}
selectedTools={selectedTools}
/>

View File

@ -22,7 +22,8 @@ type Props = {
isShowLetterIndex: boolean
hasSearchText: boolean
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
onSelectMultiple: (type: BlockEnum, tools: ToolDefaultValue[]) => void
canNotSelectMultiple?: boolean
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
selectedTools?: ToolValue[]
}
@ -33,6 +34,7 @@ const Tool: FC<Props> = ({
isShowLetterIndex,
hasSearchText,
onSelect,
canNotSelectMultiple,
onSelectMultiple,
selectedTools,
}) => {
@ -68,7 +70,7 @@ const Tool: FC<Props> = ({
return (
<span className='system-xs-regular text-components-button-secondary-accent-text'
onClick={(e) => {
onSelectMultiple(BlockEnum.Tool, actions.filter(action => !getIsDisabled(action)).map((tool) => {
onSelectMultiple?.(BlockEnum.Tool, actions.filter(action => !getIsDisabled(action)).map((tool) => {
const params: Record<string, string> = {}
if (tool.parameters) {
tool.parameters.forEach((item) => {
@ -186,7 +188,7 @@ const Tool: FC<Props> = ({
</div>
<div className='ml-2 flex items-center'>
{notShowProvider ? notShowProviderSelectInfo : selectedInfo}
{!canNotSelectMultiple && (notShowProvider ? notShowProviderSelectInfo : selectedInfo)}
{hasAction && (
<FoldIcon className={cn('h-4 w-4 shrink-0 text-text-quaternary', isFold && 'text-text-tertiary')} />
)}

View File

@ -17,7 +17,8 @@ import classNames from '@/utils/classnames'
type ToolsProps = {
showWorkflowEmpty: boolean
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
onSelectMultiple: (type: BlockEnum, tools: ToolDefaultValue[]) => void
canNotSelectMultiple?: boolean
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
tools: ToolWithProvider[]
viewType: ViewType
hasSearchText: boolean
@ -28,6 +29,7 @@ type ToolsProps = {
const Blocks = ({
showWorkflowEmpty,
onSelect,
canNotSelectMultiple,
onSelectMultiple,
tools,
viewType,
@ -109,6 +111,7 @@ const Blocks = ({
isShowLetterIndex={isShowLetterIndex}
hasSearchText={hasSearchText}
onSelect={onSelect}
canNotSelectMultiple={canNotSelectMultiple}
onSelectMultiple={onSelectMultiple}
selectedTools={selectedTools}
/>
@ -117,6 +120,7 @@ const Blocks = ({
payload={treeViewToolsData}
hasSearchText={hasSearchText}
onSelect={onSelect}
canNotSelectMultiple={canNotSelectMultiple}
onSelectMultiple={onSelectMultiple}
selectedTools={selectedTools}
/>