|
|
|
@ -1,7 +1,6 @@
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
memo,
|
|
|
|
memo,
|
|
|
|
useCallback,
|
|
|
|
useCallback,
|
|
|
|
useState,
|
|
|
|
|
|
|
|
} from 'react'
|
|
|
|
} from 'react'
|
|
|
|
import { RiAddCircleFill } from '@remixicon/react'
|
|
|
|
import { RiAddCircleFill } from '@remixicon/react'
|
|
|
|
import { useStoreApi } from 'reactflow'
|
|
|
|
import { useStoreApi } from 'reactflow'
|
|
|
|
@ -16,7 +15,7 @@ import {
|
|
|
|
usePanelInteractions,
|
|
|
|
usePanelInteractions,
|
|
|
|
} from '../hooks'
|
|
|
|
} from '../hooks'
|
|
|
|
import { NODES_INITIAL_DATA } from '../constants'
|
|
|
|
import { NODES_INITIAL_DATA } from '../constants'
|
|
|
|
import { useWorkflowStore } from '../store'
|
|
|
|
import { useStore, useWorkflowStore } from '../store'
|
|
|
|
import TipPopup from './tip-popup'
|
|
|
|
import TipPopup from './tip-popup'
|
|
|
|
import cn from '@/utils/classnames'
|
|
|
|
import cn from '@/utils/classnames'
|
|
|
|
import BlockSelector from '@/app/components/workflow/block-selector'
|
|
|
|
import BlockSelector from '@/app/components/workflow/block-selector'
|
|
|
|
@ -39,15 +38,17 @@ const AddBlock = ({
|
|
|
|
const store = useStoreApi()
|
|
|
|
const store = useStoreApi()
|
|
|
|
const workflowStore = useWorkflowStore()
|
|
|
|
const workflowStore = useWorkflowStore()
|
|
|
|
const { nodesReadOnly } = useNodesReadOnly()
|
|
|
|
const { nodesReadOnly } = useNodesReadOnly()
|
|
|
|
const { handlePaneContextmenuCancel } = usePanelInteractions()
|
|
|
|
const { handlePanelContextmenuCancel } = usePanelInteractions()
|
|
|
|
const [open, setOpen] = useState(false)
|
|
|
|
|
|
|
|
const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, false)
|
|
|
|
const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const showAddBlock = useStore(state => state.showAddBlock)
|
|
|
|
|
|
|
|
const setShowAddBlock = useStore(state => state.setShowAddBlock)
|
|
|
|
|
|
|
|
|
|
|
|
const handleOpenChange = useCallback((open: boolean) => {
|
|
|
|
const handleOpenChange = useCallback((open: boolean) => {
|
|
|
|
setOpen(open)
|
|
|
|
setShowAddBlock(open)
|
|
|
|
if (!open)
|
|
|
|
if (!open)
|
|
|
|
handlePaneContextmenuCancel()
|
|
|
|
handlePanelContextmenuCancel()
|
|
|
|
}, [handlePaneContextmenuCancel])
|
|
|
|
}, [setShowAddBlock, handlePanelContextmenuCancel])
|
|
|
|
|
|
|
|
|
|
|
|
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
|
|
|
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
@ -90,7 +91,7 @@ const AddBlock = ({
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<BlockSelector
|
|
|
|
<BlockSelector
|
|
|
|
open={open}
|
|
|
|
open={showAddBlock}
|
|
|
|
onOpenChange={handleOpenChange}
|
|
|
|
onOpenChange={handleOpenChange}
|
|
|
|
disabled={nodesReadOnly}
|
|
|
|
disabled={nodesReadOnly}
|
|
|
|
onSelect={handleSelect}
|
|
|
|
onSelect={handleSelect}
|
|
|
|
|