fix: workflow search blocks (#7097)

This commit is contained in:
zxhlyh
2024-08-08 15:33:02 +08:00
committed by GitHub
parent b6d206e095
commit 925f0d2e09
4 changed files with 29 additions and 7 deletions

View File

@@ -1,8 +1,5 @@
import type { FC } from 'react'
import {
memo,
useState,
} from 'react'
import { memo } from 'react'
import type { BlockEnum } from '../types'
import { useTabs } from './hooks'
import type { ToolDefaultValue } from './types'
@@ -12,19 +9,22 @@ import AllTools from './all-tools'
import cn from '@/utils/classnames'
export type TabsProps = {
activeTab: TabsEnum
onActiveTabChange: (activeTab: TabsEnum) => void
searchText: string
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
availableBlocksTypes?: BlockEnum[]
noBlocks?: boolean
}
const Tabs: FC<TabsProps> = ({
activeTab,
onActiveTabChange,
searchText,
onSelect,
availableBlocksTypes,
noBlocks,
}) => {
const tabs = useTabs()
const [activeTab, setActiveTab] = useState(noBlocks ? TabsEnum.Tools : TabsEnum.Blocks)
return (
<div onClick={e => e.stopPropagation()}>
@@ -41,7 +41,7 @@ const Tabs: FC<TabsProps> = ({
? 'text-gray-700 after:absolute after:bottom-0 after:left-0 after:h-0.5 after:w-full after:bg-primary-600'
: 'text-gray-500',
)}
onClick={() => setActiveTab(tab.key)}
onClick={() => onActiveTabChange(tab.key)}
>
{tab.name}
</div>