'use client' import { useCallback, useEffect, useRef, useState, } from 'react' import { useTranslation } from 'react-i18next' import type { BlockEnum, OnSelectBlock } from '../types' import type { TriggerDefaultValue } from './types' import StartBlocks from './start-blocks' import TriggerPluginSelector from './trigger-plugin-selector' import { ENTRY_NODE_TYPES } from './constants' import cn from '@/utils/classnames' import Link from 'next/link' import { RiArrowRightUpLine } from '@remixicon/react' import { getMarketplaceUrl } from '@/utils/var' import Button from '@/app/components/base/button' import { SearchMenu } from '@/app/components/base/icons/src/vender/line/general' import { BlockEnum as BlockEnumValue } from '../types' type AllStartBlocksProps = { className?: string searchText: string onSelect: (type: BlockEnum, trigger?: TriggerDefaultValue) => void availableBlocksTypes?: BlockEnum[] tags?: string[] } const AllStartBlocks = ({ className, searchText, onSelect, availableBlocksTypes, tags = [], }: AllStartBlocksProps) => { const { t } = useTranslation() const wrapElemRef = useRef(null) const [hasStartBlocksContent, setHasStartBlocksContent] = useState(false) const [hasPluginContent, setHasPluginContent] = useState(false) const entryNodeTypes = availableBlocksTypes?.length ? availableBlocksTypes : ENTRY_NODE_TYPES const enableTriggerPlugin = entryNodeTypes.includes(BlockEnumValue.TriggerPlugin) const handleStartBlocksContentChange = useCallback((hasContent: boolean) => { setHasStartBlocksContent(hasContent) }, []) const handlePluginContentChange = useCallback((hasContent: boolean) => { setHasPluginContent(hasContent) }, []) const hasAnyContent = hasStartBlocksContent || hasPluginContent const shouldShowEmptyState = searchText && !hasAnyContent useEffect(() => { if (!enableTriggerPlugin && hasPluginContent) setHasPluginContent(false) }, [enableTriggerPlugin, hasPluginContent]) return (
{shouldShowEmptyState && (
{t('workflow.tabs.noPluginsFound')}
)} {!shouldShowEmptyState && ( <> { ( )} )}
{/* Footer - Same as Tools tab marketplace footer */} {t('plugin.findMoreInMarketplace')}
) } export default AllStartBlocks