mirror of
https://github.com/langgenius/dify.git
synced 2026-04-13 22:57:26 +08:00
- Refactored `PluginFetchDynamicSelectOptionsApi` to replace the `extra` argument with `credential_id`, improving clarity in dynamic option fetching. - Updated `ProviderConfigEncrypter` to rename `mask_tool_credentials` to `mask_credentials` for consistency, and added a new method to maintain backward compatibility. - Enhanced `PluginParameterService` to utilize `credential_id` for fetching subscriptions, improving the handling of trigger credentials. - Adjusted various components and types in the frontend to replace `tool_name` with `trigger_name`, ensuring consistency across the application. - Introduced `multiple` property in `TriggerParameter` to support multi-select functionality. These changes improve the integration of triggers and plugins, enhance code clarity, and align naming conventions across the codebase.
111 lines
3.3 KiB
TypeScript
111 lines
3.3 KiB
TypeScript
import type { FC } from 'react'
|
|
import { memo } from 'react'
|
|
import { useAllBuiltInTools, useAllCustomTools, useAllMCPTools, useAllWorkflowTools } from '@/service/use-tools'
|
|
import type { BlockEnum } from '../types'
|
|
import { useTabs } from './hooks'
|
|
import type { PluginDefaultValue } from './types'
|
|
import { TabsEnum } from './types'
|
|
import Blocks from './blocks'
|
|
import AllStartBlocks from './all-start-blocks'
|
|
import AllTools from './all-tools'
|
|
import cn from '@/utils/classnames'
|
|
|
|
export type TabsProps = {
|
|
activeTab: TabsEnum
|
|
onActiveTabChange: (activeTab: TabsEnum) => void
|
|
searchText: string
|
|
tags: string[]
|
|
onSelect: (type: BlockEnum, plugin?: PluginDefaultValue) => void
|
|
availableBlocksTypes?: BlockEnum[]
|
|
filterElem: React.ReactNode
|
|
noBlocks?: boolean
|
|
showStartTab?: boolean
|
|
forceShowStartContent?: boolean // Force show Start content even when noBlocks=true
|
|
}
|
|
const Tabs: FC<TabsProps> = ({
|
|
activeTab,
|
|
onActiveTabChange,
|
|
tags,
|
|
searchText,
|
|
onSelect,
|
|
availableBlocksTypes,
|
|
filterElem,
|
|
noBlocks,
|
|
showStartTab = false,
|
|
forceShowStartContent = false,
|
|
}) => {
|
|
const tabs = useTabs(showStartTab)
|
|
const { data: buildInTools } = useAllBuiltInTools()
|
|
const { data: customTools } = useAllCustomTools()
|
|
const { data: workflowTools } = useAllWorkflowTools()
|
|
const { data: mcpTools } = useAllMCPTools()
|
|
|
|
return (
|
|
<div onClick={e => e.stopPropagation()}>
|
|
{
|
|
!noBlocks && (
|
|
<div className='relative flex bg-background-section-burn pl-1 pt-1'>
|
|
{
|
|
tabs.map(tab => (
|
|
<div
|
|
key={tab.key}
|
|
className={cn(
|
|
'system-sm-medium relative mr-0.5 flex h-8 cursor-pointer items-center rounded-t-lg px-3 ',
|
|
activeTab === tab.key
|
|
? 'sm-no-bottom cursor-default bg-components-panel-bg text-text-accent'
|
|
: 'text-text-tertiary',
|
|
)}
|
|
onClick={() => onActiveTabChange(tab.key)}
|
|
>
|
|
{tab.name}
|
|
</div>
|
|
))
|
|
}
|
|
</div>
|
|
)
|
|
}
|
|
{filterElem}
|
|
{
|
|
activeTab === TabsEnum.Start && (!noBlocks || forceShowStartContent) && (
|
|
<div className='border-t border-divider-subtle'>
|
|
<AllStartBlocks
|
|
searchText={searchText}
|
|
onSelect={onSelect}
|
|
availableBlocksTypes={availableBlocksTypes}
|
|
tags={tags}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
{
|
|
activeTab === TabsEnum.Blocks && !noBlocks && (
|
|
<div className='border-t border-divider-subtle'>
|
|
<Blocks
|
|
searchText={searchText}
|
|
onSelect={onSelect}
|
|
availableBlocksTypes={availableBlocksTypes}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
{
|
|
activeTab === TabsEnum.Tools && (
|
|
<AllTools
|
|
searchText={searchText}
|
|
onSelect={onSelect}
|
|
tags={tags}
|
|
canNotSelectMultiple
|
|
buildInTools={buildInTools || []}
|
|
customTools={customTools || []}
|
|
workflowTools={workflowTools || []}
|
|
mcpTools={mcpTools || []}
|
|
canChooseMCPTool
|
|
/>
|
|
)
|
|
}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default memo(Tabs)
|