mirror of https://github.com/langgenius/dify.git
fix: types
This commit is contained in:
parent
5e3e6b0bd8
commit
8106df1d7d
|
|
@ -22,7 +22,6 @@ import dynamic from 'next/dynamic'
|
|||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import type {
|
||||
PluginDefaultValue,
|
||||
ToolDefaultValue,
|
||||
TriggerDefaultValue,
|
||||
} from '@/app/components/workflow/block-selector/types'
|
||||
import { useAutoOnboarding } from '../hooks/use-auto-onboarding'
|
||||
|
|
@ -96,7 +95,7 @@ const WorkflowChildren = () => {
|
|||
handleOnboardingClose()
|
||||
}, [handleOnboardingClose])
|
||||
|
||||
const handleSelectStartNode = useCallback((nodeType: BlockEnum, toolConfig?: ToolDefaultValue | TriggerDefaultValue | PluginDefaultValue) => {
|
||||
const handleSelectStartNode = useCallback((nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => {
|
||||
const nodeDefault = availableNodesMetaData.nodesMap?.[nodeType]
|
||||
if (!nodeDefault?.defaultValue)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
|
||||
import type { PluginDefaultValue } from '@/app/components/workflow/block-selector/types'
|
||||
import Modal from '@/app/components/base/modal'
|
||||
import StartNodeSelectionPanel from './start-node-selection-panel'
|
||||
import { useDocLink } from '@/context/i18n'
|
||||
|
|
@ -14,7 +14,7 @@ import { useDocLink } from '@/context/i18n'
|
|||
type WorkflowOnboardingModalProps = {
|
||||
isShow: boolean
|
||||
onClose: () => void
|
||||
onSelectStartNode: (nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => void
|
||||
onSelectStartNode: (nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => void
|
||||
}
|
||||
|
||||
const WorkflowOnboardingModal: FC<WorkflowOnboardingModalProps> = ({
|
||||
|
|
@ -30,7 +30,7 @@ const WorkflowOnboardingModal: FC<WorkflowOnboardingModalProps> = ({
|
|||
onClose() // Close modal after selection
|
||||
}, [onSelectStartNode, onClose])
|
||||
|
||||
const handleTriggerSelect = useCallback((nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => {
|
||||
const handleTriggerSelect = useCallback((nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => {
|
||||
onSelectStartNode(nodeType, toolConfig)
|
||||
onClose() // Close modal after selection
|
||||
}, [onSelectStartNode, onClose])
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import NodeSelector from '@/app/components/workflow/block-selector'
|
|||
import { Home } from '@/app/components/base/icons/src/vender/workflow'
|
||||
import { TriggerAll } from '@/app/components/base/icons/src/vender/workflow'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
|
||||
import type { PluginDefaultValue } from '@/app/components/workflow/block-selector/types'
|
||||
import { TabsEnum } from '@/app/components/workflow/block-selector/types'
|
||||
|
||||
type StartNodeSelectionPanelProps = {
|
||||
onSelectUserInput: () => void
|
||||
onSelectTrigger: (nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => void
|
||||
onSelectTrigger: (nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => void
|
||||
}
|
||||
|
||||
const StartNodeSelectionPanel: FC<StartNodeSelectionPanelProps> = ({
|
||||
|
|
@ -26,7 +26,7 @@ const StartNodeSelectionPanel: FC<StartNodeSelectionPanelProps> = ({
|
|||
setShowTriggerSelector(true)
|
||||
}, [])
|
||||
|
||||
const handleTriggerSelect = useCallback((nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => {
|
||||
const handleTriggerSelect = useCallback((nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => {
|
||||
setShowTriggerSelector(false)
|
||||
onSelectTrigger(nodeType, toolConfig)
|
||||
}, [onSelectTrigger])
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@ export const useAutoOnboarding = () => {
|
|||
|
||||
// Show onboarding only if canvas is completely empty and we haven't shown it before in this session
|
||||
if (isCompletelyEmpty && !hasShownOnboarding) {
|
||||
setShowOnboarding(true)
|
||||
setHasShownOnboarding(true)
|
||||
setShowOnboarding?.(true)
|
||||
setHasShownOnboarding?.(true)
|
||||
}
|
||||
}, [store, workflowStore])
|
||||
|
||||
const handleOnboardingClose = useCallback(() => {
|
||||
const { setShowOnboarding, setHasShownOnboarding } = workflowStore.getState()
|
||||
setShowOnboarding(false)
|
||||
setHasShownOnboarding(true)
|
||||
setShowOnboarding?.(false)
|
||||
setHasShownOnboarding?.(true)
|
||||
}, [workflowStore])
|
||||
|
||||
// Check on mount and when nodes change
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import type {
|
||||
Dispatch,
|
||||
RefObject,
|
||||
SetStateAction,
|
||||
} from 'react'
|
||||
import {
|
||||
|
|
@ -10,7 +11,6 @@ import {
|
|||
} from 'react'
|
||||
import type {
|
||||
BlockEnum,
|
||||
OnSelectBlock,
|
||||
ToolWithProvider,
|
||||
} from '../types'
|
||||
import type { ToolDefaultValue, ToolValue } from './types'
|
||||
|
|
@ -36,12 +36,12 @@ type AllToolsProps = {
|
|||
customTools: ToolWithProvider[]
|
||||
workflowTools: ToolWithProvider[]
|
||||
mcpTools: ToolWithProvider[]
|
||||
onSelect: OnSelectBlock
|
||||
onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void
|
||||
canNotSelectMultiple?: boolean
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
selectedTools?: ToolValue[]
|
||||
canChooseMCPTool?: boolean
|
||||
onTagsChange: Dispatch<SetStateAction<string[]>>
|
||||
onTagsChange?: Dispatch<SetStateAction<string[]>>
|
||||
isInRAGPipeline?: boolean
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ const AllTools = ({
|
|||
className='max-h-[464px] overflow-y-auto'
|
||||
onScroll={pluginRef.current?.handleScroll}
|
||||
>
|
||||
{isShowRAGRecommendations && (
|
||||
{isShowRAGRecommendations && onTagsChange && (
|
||||
<RAGToolSuggestions
|
||||
viewType={isSupportGroupView ? activeView : ViewType.flat}
|
||||
onSelect={onSelect}
|
||||
|
|
@ -171,7 +171,7 @@ const AllTools = ({
|
|||
{enable_marketplace && (
|
||||
<PluginList
|
||||
ref={pluginRef}
|
||||
wrapElemRef={wrapElemRef}
|
||||
wrapElemRef={wrapElemRef as RefObject<HTMLElement>}
|
||||
list={notInstalledPlugins}
|
||||
searchText={searchText}
|
||||
toolContentClassName={toolContentClassName}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,12 @@ import { BlockEnum } from '../types'
|
|||
import type { NodeDefault } from '../types'
|
||||
import { BLOCK_CLASSIFICATIONS } from './constants'
|
||||
import { useBlocks } from './hooks'
|
||||
import type { ToolDefaultValue } from './types'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import Badge from '@/app/components/base/badge'
|
||||
|
||||
type BlocksProps = {
|
||||
searchText: string
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: (type: BlockEnum) => void
|
||||
availableBlocksTypes?: BlockEnum[]
|
||||
blocks?: NodeDefault[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const DataSources = ({
|
|||
const { t } = useTranslation()
|
||||
const pluginRef = useRef<ListRef>(null)
|
||||
const wrapElemRef = useRef<HTMLDivElement>(null)
|
||||
const handleSelect = useCallback((_: any, toolDefaultValue: ToolDefaultValue) => {
|
||||
const handleSelect = useCallback((_: BlockEnum, toolDefaultValue: ToolDefaultValue) => {
|
||||
let defaultValue: DataSourceDefaultValue = {
|
||||
plugin_id: toolDefaultValue?.provider_id,
|
||||
provider_type: toolDefaultValue?.provider_type,
|
||||
|
|
@ -67,7 +67,7 @@ const DataSources = ({
|
|||
<Tools
|
||||
className={toolContentClassName}
|
||||
tools={dataSources}
|
||||
onSelect={handleSelect as OnSelectBlock}
|
||||
onSelect={handleSelect}
|
||||
viewType={ViewType.flat}
|
||||
hasSearchText={!!searchText}
|
||||
canNotSelectMultiple
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
'use client'
|
||||
import React, { useEffect, useImperativeHandle, useMemo, useRef } from 'react'
|
||||
import { useEffect, useImperativeHandle, useMemo, useRef } from 'react'
|
||||
import type { RefObject } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import useStickyScroll, { ScrollPosition } from '../use-sticky-scroll'
|
||||
import Item from './item'
|
||||
|
|
@ -39,7 +40,7 @@ const List = ({
|
|||
|
||||
const { handleScroll, scrollPosition } = useStickyScroll({
|
||||
wrapElemRef,
|
||||
nextToStickyELemRef,
|
||||
nextToStickyELemRef: nextToStickyELemRef as RefObject<HTMLElement>,
|
||||
})
|
||||
const stickyClassName = useMemo(() => {
|
||||
switch (scrollPosition) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import type { Dispatch, SetStateAction } from 'react'
|
||||
import React, { useCallback, useMemo } from 'react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import type { OnSelectBlock } from '../types'
|
||||
import type { BlockEnum } from '../types'
|
||||
import Tools from './tools'
|
||||
import { ToolTypeEnum } from './types'
|
||||
import type { ToolDefaultValue } from './types'
|
||||
import type { ViewType } from './view-type-select'
|
||||
import { RiMoreLine } from '@remixicon/react'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
|
|
@ -13,7 +14,7 @@ import { useRAGRecommendedPlugins } from '@/service/use-tools'
|
|||
|
||||
type RAGToolSuggestionsProps = {
|
||||
viewType: ViewType
|
||||
onSelect: OnSelectBlock
|
||||
onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void
|
||||
onTagsChange: Dispatch<SetStateAction<string[]>>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ import type { BlockEnum, CommonNodeType } from '../types'
|
|||
import { BlockEnum as BlockEnumValues } from '../types'
|
||||
// import { useNodeMetaData } from '../hooks'
|
||||
import { START_BLOCKS } from './constants'
|
||||
import type { ToolDefaultValue } from './types'
|
||||
import type { TriggerDefaultValue } from './types'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import { useAvailableNodesMetaData } from '../../workflow-app/hooks'
|
||||
|
||||
type StartBlocksProps = {
|
||||
searchText: string
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: (type: BlockEnum, triggerDefaultValue?: TriggerDefaultValue) => void
|
||||
availableBlocksTypes?: BlockEnum[]
|
||||
onContentStateChange?: (hasContent: boolean) => void
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ type Props = {
|
|||
payload: Tool
|
||||
disabled?: boolean
|
||||
isAdded?: boolean
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void
|
||||
}
|
||||
|
||||
const ToolItem: FC<Props> = ({
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ type Props = {
|
|||
isShowLetterIndex: boolean
|
||||
indexBar: React.ReactNode
|
||||
hasSearchText: boolean
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void
|
||||
canNotSelectMultiple?: boolean
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
letters: string[]
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ type Props = {
|
|||
groupName: string
|
||||
toolList: ToolWithProvider[]
|
||||
hasSearchText: boolean
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void
|
||||
canNotSelectMultiple?: boolean
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
selectedTools?: ToolValue[]
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { AGENT_GROUP_NAME, CUSTOM_GROUP_NAME, WORKFLOW_GROUP_NAME } from '../../
|
|||
type Props = {
|
||||
payload: Record<string, ToolWithProvider[]>
|
||||
hasSearchText: boolean
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void
|
||||
canNotSelectMultiple?: boolean
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
selectedTools?: ToolValue[]
|
||||
|
|
|
|||
|
|
@ -22,11 +22,12 @@ type Props = {
|
|||
payload: ToolWithProvider
|
||||
viewType: ViewType
|
||||
hasSearchText: boolean
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void
|
||||
canNotSelectMultiple?: boolean
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
selectedTools?: ToolValue[]
|
||||
canChooseMCPTool?: boolean
|
||||
isShowLetterIndex?: boolean
|
||||
}
|
||||
|
||||
const Tool: FC<Props> = ({
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import ToolListFlatView from './tool/tool-list-flat-view/list'
|
|||
import classNames from '@/utils/classnames'
|
||||
|
||||
type ToolsProps = {
|
||||
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
||||
onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void
|
||||
canNotSelectMultiple?: boolean
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
tools: ToolWithProvider[]
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ export enum BlockClassificationEnum {
|
|||
Utilities = 'utilities',
|
||||
}
|
||||
|
||||
export type PluginDefaultValue = {
|
||||
type PluginCommonDefaultValue = {
|
||||
provider_id: string
|
||||
provider_type: string
|
||||
provider_name: string
|
||||
}
|
||||
|
||||
export type TriggerDefaultValue = PluginDefaultValue & {
|
||||
export type TriggerDefaultValue = PluginCommonDefaultValue & {
|
||||
trigger_name: string
|
||||
trigger_label: string
|
||||
trigger_description: string
|
||||
|
|
@ -45,7 +45,7 @@ export type TriggerDefaultValue = PluginDefaultValue & {
|
|||
meta?: PluginMeta
|
||||
}
|
||||
|
||||
export type ToolDefaultValue = PluginDefaultValue & {
|
||||
export type ToolDefaultValue = PluginCommonDefaultValue & {
|
||||
tool_name: string
|
||||
tool_label: string
|
||||
tool_description: string
|
||||
|
|
@ -53,12 +53,12 @@ export type ToolDefaultValue = PluginDefaultValue & {
|
|||
is_team_authorization: boolean
|
||||
params: Record<string, any>
|
||||
paramSchemas: Record<string, any>[]
|
||||
output_schema: Record<string, any>
|
||||
output_schema?: Record<string, any>
|
||||
credential_id?: string
|
||||
meta?: PluginMeta
|
||||
}
|
||||
|
||||
export type DataSourceDefaultValue = {
|
||||
export type DataSourceDefaultValue = Omit<PluginCommonDefaultValue, 'provider_id'> & {
|
||||
plugin_id: string
|
||||
provider_type: string
|
||||
provider_name: string
|
||||
|
|
@ -68,6 +68,8 @@ export type DataSourceDefaultValue = {
|
|||
fileExtensions?: string[]
|
||||
}
|
||||
|
||||
export type PluginDefaultValue = ToolDefaultValue | DataSourceDefaultValue | TriggerDefaultValue
|
||||
|
||||
export type ToolValue = {
|
||||
provider_name: string
|
||||
provider_show_name?: string
|
||||
|
|
|
|||
|
|
@ -83,11 +83,11 @@ const CustomEdge = ({
|
|||
setOpen(v)
|
||||
}, [])
|
||||
|
||||
const handleInsert = useCallback<OnSelectBlock>((nodeType, toolDefaultValue) => {
|
||||
const handleInsert = useCallback<OnSelectBlock>((nodeType, pluginDefaultValue) => {
|
||||
handleNodeAdd(
|
||||
{
|
||||
nodeType,
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
},
|
||||
{
|
||||
prevNodeId: source,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
useReactFlow,
|
||||
useStoreApi,
|
||||
} from 'reactflow'
|
||||
import type { ToolDefaultValue } from '../block-selector/types'
|
||||
import type { PluginDefaultValue } from '../block-selector/types'
|
||||
import type { Edge, Node, OnNodeAdd } from '../types'
|
||||
import { BlockEnum } from '../types'
|
||||
import { useWorkflowStore } from '../store'
|
||||
|
|
@ -737,7 +737,7 @@ export const useNodesInteractions = () => {
|
|||
nodeType,
|
||||
sourceHandle = 'source',
|
||||
targetHandle = 'target',
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
},
|
||||
{ prevNodeId, prevNodeSourceHandle, nextNodeId, nextNodeTargetHandle },
|
||||
) => {
|
||||
|
|
@ -758,7 +758,7 @@ export const useNodesInteractions = () => {
|
|||
nodesWithSameType.length > 0
|
||||
? `${defaultValue.title} ${nodesWithSameType.length + 1}`
|
||||
: defaultValue.title,
|
||||
...toolDefaultValue,
|
||||
...pluginDefaultValue,
|
||||
selected: true,
|
||||
_showAddVariablePopup:
|
||||
(nodeType === BlockEnum.VariableAssigner
|
||||
|
|
@ -1288,7 +1288,7 @@ export const useNodesInteractions = () => {
|
|||
currentNodeId: string,
|
||||
nodeType: BlockEnum,
|
||||
sourceHandle: string,
|
||||
toolDefaultValue?: ToolDefaultValue,
|
||||
pluginDefaultValue?: PluginDefaultValue,
|
||||
) => {
|
||||
if (getNodesReadOnly()) return
|
||||
|
||||
|
|
@ -1312,7 +1312,7 @@ export const useNodesInteractions = () => {
|
|||
nodesWithSameType.length > 0
|
||||
? `${defaultValue.title} ${nodesWithSameType.length + 1}`
|
||||
: defaultValue.title,
|
||||
...toolDefaultValue,
|
||||
...pluginDefaultValue,
|
||||
_connectedSourceHandleIds: [],
|
||||
_connectedTargetHandleIds: [],
|
||||
selected: currentNode.data.selected,
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ const Add = ({
|
|||
const { nodesReadOnly } = useNodesReadOnly()
|
||||
const { availableNextBlocks } = useAvailableBlocks(nodeData.type, nodeData.isInIteration || nodeData.isInLoop)
|
||||
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, pluginDefaultValue) => {
|
||||
handleNodeAdd(
|
||||
{
|
||||
nodeType: type,
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
},
|
||||
{
|
||||
prevNodeId: nodeId,
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ const ChangeItem = ({
|
|||
availableNextBlocks,
|
||||
} = useAvailableBlocks(data.type, data.isInIteration || data.isInLoop)
|
||||
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||
handleNodeChange(nodeId, type, sourceHandle, toolDefaultValue)
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, pluginDefaultValue) => {
|
||||
handleNodeChange(nodeId, type, sourceHandle, pluginDefaultValue)
|
||||
}, [nodeId, sourceHandle, handleNodeChange])
|
||||
|
||||
const renderTrigger = useCallback(() => {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
} from '../../../types'
|
||||
import type { Node } from '../../../types'
|
||||
import BlockSelector from '../../../block-selector'
|
||||
import type { ToolDefaultValue } from '../../../block-selector/types'
|
||||
import type { PluginDefaultValue } from '../../../block-selector/types'
|
||||
import {
|
||||
useAvailableBlocks,
|
||||
useIsChatMode,
|
||||
|
|
@ -57,11 +57,11 @@ export const NodeTargetHandle = memo(({
|
|||
if (!connected)
|
||||
setOpen(v => !v)
|
||||
}, [connected])
|
||||
const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => {
|
||||
const handleSelect = useCallback((type: BlockEnum, pluginDefaultValue?: PluginDefaultValue) => {
|
||||
handleNodeAdd(
|
||||
{
|
||||
nodeType: type,
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
},
|
||||
{
|
||||
nextNodeId: id,
|
||||
|
|
@ -143,11 +143,11 @@ export const NodeSourceHandle = memo(({
|
|||
e.stopPropagation()
|
||||
setOpen(v => !v)
|
||||
}, [])
|
||||
const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => {
|
||||
const handleSelect = useCallback((type: BlockEnum, pluginDefaultValue?: PluginDefaultValue) => {
|
||||
handleNodeAdd(
|
||||
{
|
||||
nodeType: type,
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
},
|
||||
{
|
||||
prevNodeId: id,
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ const ChangeBlock = ({
|
|||
return availableNextBlocks
|
||||
}, [availablePrevBlocks, availableNextBlocks])
|
||||
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||
handleNodeChange(nodeId, type, sourceHandle, toolDefaultValue)
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, pluginDefaultValue) => {
|
||||
handleNodeChange(nodeId, type, sourceHandle, pluginDefaultValue)
|
||||
}, [handleNodeChange, nodeId, sourceHandle])
|
||||
|
||||
const renderTrigger = useCallback(() => {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const useReplaceDataSourceNode = (id: string) => {
|
|||
|
||||
const handleReplaceNode = useCallback<OnSelectBlock>((
|
||||
type,
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
) => {
|
||||
const {
|
||||
getNodes,
|
||||
|
|
@ -28,7 +28,7 @@ export const useReplaceDataSourceNode = (id: string) => {
|
|||
const { newNode } = generateNewNode({
|
||||
data: {
|
||||
...(defaultValue as any),
|
||||
...toolDefaultValue,
|
||||
...pluginDefaultValue,
|
||||
},
|
||||
position: {
|
||||
x: emptyNode.position.x,
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ const AddBlock = ({
|
|||
const { handleNodeAdd } = useNodesInteractions()
|
||||
const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, true)
|
||||
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, pluginDefaultValue) => {
|
||||
handleNodeAdd(
|
||||
{
|
||||
nodeType: type,
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
},
|
||||
{
|
||||
prevNodeId: iterationNodeData.start_node_id,
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ const AddBlock = ({
|
|||
const { handleNodeAdd } = useNodesInteractions()
|
||||
const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, true)
|
||||
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, pluginDefaultValue) => {
|
||||
handleNodeAdd(
|
||||
{
|
||||
nodeType: type,
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
},
|
||||
{
|
||||
prevNodeId: loopNodeData.start_node_id,
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ const InsertBlock = ({
|
|||
const handleOpenChange = useCallback((v: boolean) => {
|
||||
setOpen(v)
|
||||
}, [])
|
||||
const handleInsert = useCallback<OnSelectBlock>((nodeType, toolDefaultValue) => {
|
||||
const handleInsert = useCallback<OnSelectBlock>((nodeType, pluginDefaultValue) => {
|
||||
handleNodeAdd(
|
||||
{
|
||||
nodeType,
|
||||
toolDefaultValue,
|
||||
pluginDefaultValue,
|
||||
},
|
||||
{
|
||||
nextNodeId: startNodeId,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import BlockSelector from '../../../../block-selector'
|
|||
import type { Param, ParamType } from '../../types'
|
||||
import cn from '@/utils/classnames'
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
|
||||
import type { PluginDefaultValue } from '@/app/components/workflow/block-selector/types'
|
||||
import type { ToolParameter } from '@/app/components/tools/types'
|
||||
import { CollectionType } from '@/app/components/tools/types'
|
||||
import type { BlockEnum } from '@/app/components/workflow/types'
|
||||
|
|
@ -43,7 +43,9 @@ const ImportFromTool: FC<Props> = ({
|
|||
const customTools = useStore(s => s.customTools)
|
||||
const workflowTools = useStore(s => s.workflowTools)
|
||||
|
||||
const handleSelectTool = useCallback((_type: BlockEnum, toolInfo?: ToolDefaultValue) => {
|
||||
const handleSelectTool = useCallback((_type: BlockEnum, toolInfo?: PluginDefaultValue) => {
|
||||
if (!toolInfo || !('tool_name' in toolInfo))
|
||||
return
|
||||
const { provider_id, provider_type, tool_name: tool_name } = toolInfo!
|
||||
const currentTools = (() => {
|
||||
switch (provider_type) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const AddBlock = ({
|
|||
handlePaneContextmenuCancel()
|
||||
}, [handlePaneContextmenuCancel])
|
||||
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||
const handleSelect = useCallback<OnSelectBlock>((type, pluginDefaultValue) => {
|
||||
const {
|
||||
getNodes,
|
||||
} = store.getState()
|
||||
|
|
@ -67,7 +67,7 @@ const AddBlock = ({
|
|||
data: {
|
||||
...(defaultValue as any),
|
||||
title: nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title,
|
||||
...toolDefaultValue,
|
||||
...pluginDefaultValue,
|
||||
_isCandidate: true,
|
||||
},
|
||||
position: {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,7 @@ import type {
|
|||
XYPosition,
|
||||
} from 'reactflow'
|
||||
import type { Resolution, TransferMethod } from '@/types/app'
|
||||
import type {
|
||||
DataSourceDefaultValue,
|
||||
PluginDefaultValue,
|
||||
ToolDefaultValue,
|
||||
} from '@/app/components/workflow/block-selector/types'
|
||||
import type { PluginDefaultValue } from '@/app/components/workflow/block-selector/types'
|
||||
import type { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
||||
import type { FileResponse, NodeTracing, PanelProps } from '@/types/workflow'
|
||||
import type { Collection, Tool } from '@/app/components/tools/types'
|
||||
|
|
@ -109,8 +105,7 @@ export type CommonNodeType<T = {}> = {
|
|||
credential_id?: string
|
||||
subscription_id?: string
|
||||
_dimmed?: boolean
|
||||
} & T & Partial<Pick<ToolDefaultValue, 'provider_id' | 'provider_type' | 'provider_name' | 'tool_name'>>
|
||||
& Partial<Pick<DataSourceDefaultValue, 'plugin_id' | 'provider_type' | 'provider_name' | 'datasource_name'>>
|
||||
} & T & Partial<PluginDefaultValue>
|
||||
|
||||
export type CommonEdgeType = {
|
||||
_hovering?: boolean
|
||||
|
|
@ -346,7 +341,7 @@ export type NodeDefault<T = {}> = {
|
|||
}) => Var[]
|
||||
}
|
||||
|
||||
export type OnSelectBlock = (type: BlockEnum, toolDefaultValue?: ToolDefaultValue | PluginDefaultValue | DataSourceDefaultValue) => void
|
||||
export type OnSelectBlock = (type: BlockEnum, pluginDefaultValue?: PluginDefaultValue) => void
|
||||
|
||||
export enum WorkflowRunningStatus {
|
||||
Listening = 'listening',
|
||||
|
|
@ -378,7 +373,7 @@ export type OnNodeAdd = (
|
|||
nodeType: BlockEnum
|
||||
sourceHandle?: string
|
||||
targetHandle?: string
|
||||
toolDefaultValue?: ToolDefaultValue | DataSourceDefaultValue
|
||||
pluginDefaultValue?: PluginDefaultValue
|
||||
},
|
||||
oldNodesPayload: {
|
||||
prevNodeId?: string
|
||||
|
|
|
|||
Loading…
Reference in New Issue