import EmbedModal from '@/components/api-service/embed-modal'; import { useShowEmbedModal } from '@/components/api-service/hooks'; import { SharedFrom } from '@/constants/chat'; import { useTranslate } from '@/hooks/common-hooks'; import { useFetchFlow } from '@/hooks/flow-hooks'; import { ArrowLeftOutlined } from '@ant-design/icons'; import { Button, Flex, Space } from 'antd'; import { useCallback } from 'react'; import { Link, useParams } from 'umi'; import { useGetBeginNodeDataQuery, useGetBeginNodeDataQueryIsEmpty, useSaveGraph, useSaveGraphBeforeOpeningDebugDrawer, useWatchAgentChange, } from '../hooks'; import { BeginQuery } from '../interface'; import styles from './index.less'; interface IProps { showChatDrawer(): void; chatDrawerVisible: boolean; } const FlowHeader = ({ showChatDrawer, chatDrawerVisible }: IProps) => { const { saveGraph } = useSaveGraph(); const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer); const { data } = useFetchFlow(); const { t } = useTranslate('flow'); const { id } = useParams(); const time = useWatchAgentChange(chatDrawerVisible); const getBeginNodeDataQuery = useGetBeginNodeDataQuery(); const { showEmbedModal, hideEmbedModal, embedVisible, beta } = useShowEmbedModal(); const isBeginNodeDataQueryEmpty = useGetBeginNodeDataQueryIsEmpty(); const handleShowEmbedModal = useCallback(() => { showEmbedModal(); }, [showEmbedModal]); const handleRunAgent = useCallback(() => { const query: BeginQuery[] = getBeginNodeDataQuery(); if (query.length > 0) { showChatDrawer(); } else { handleRun(); } }, [getBeginNodeDataQuery, handleRun, showChatDrawer]); return ( <>
{data.title} {t('autosaved')} {time}
{embedVisible && ( )} ); }; export default FlowHeader;