2024-08-09 18:59:16 +08:00
|
|
|
import ChatOverviewModal from '@/components/api-service/chat-overview-modal';
|
|
|
|
|
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
|
2024-06-07 19:27:27 +08:00
|
|
|
import { useFetchFlow } from '@/hooks/flow-hooks';
|
|
|
|
|
import { ArrowLeftOutlined } from '@ant-design/icons';
|
2024-07-08 10:55:10 +08:00
|
|
|
import { Button, Flex, Space } from 'antd';
|
2024-08-09 18:59:16 +08:00
|
|
|
import { Link, useParams } from 'umi';
|
2024-07-05 14:16:03 +08:00
|
|
|
import { useSaveGraph, useSaveGraphBeforeOpeningDebugDrawer } from '../hooks';
|
2024-05-29 10:01:39 +08:00
|
|
|
import styles from './index.less';
|
|
|
|
|
|
2024-06-11 15:46:12 +08:00
|
|
|
interface IProps {
|
|
|
|
|
showChatDrawer(): void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FlowHeader = ({ showChatDrawer }: IProps) => {
|
2024-05-29 10:01:39 +08:00
|
|
|
const { saveGraph } = useSaveGraph();
|
2024-07-05 14:16:03 +08:00
|
|
|
const handleRun = useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer);
|
2024-06-07 19:27:27 +08:00
|
|
|
const { data } = useFetchFlow();
|
2024-07-08 10:55:10 +08:00
|
|
|
const { t } = useTranslate('flow');
|
2024-08-09 18:59:16 +08:00
|
|
|
const {
|
|
|
|
|
visible: overviewVisible,
|
|
|
|
|
hideModal: hideOverviewModal,
|
|
|
|
|
showModal: showOverviewModal,
|
|
|
|
|
} = useSetModalState();
|
|
|
|
|
const { id } = useParams();
|
2024-05-29 10:01:39 +08:00
|
|
|
|
|
|
|
|
return (
|
2024-06-07 19:27:27 +08:00
|
|
|
<>
|
|
|
|
|
<Flex
|
|
|
|
|
align="center"
|
|
|
|
|
justify={'space-between'}
|
|
|
|
|
gap={'large'}
|
|
|
|
|
className={styles.flowHeader}
|
|
|
|
|
>
|
|
|
|
|
<Space size={'large'}>
|
|
|
|
|
<Link to={`/flow`}>
|
|
|
|
|
<ArrowLeftOutlined />
|
|
|
|
|
</Link>
|
|
|
|
|
<h3>{data.title}</h3>
|
|
|
|
|
</Space>
|
|
|
|
|
<Space size={'large'}>
|
2024-07-05 14:16:03 +08:00
|
|
|
<Button onClick={handleRun}>
|
2024-07-08 10:55:10 +08:00
|
|
|
<b>{t('run')}</b>
|
2024-06-07 19:27:27 +08:00
|
|
|
</Button>
|
|
|
|
|
<Button type="primary" onClick={saveGraph}>
|
2024-07-08 10:55:10 +08:00
|
|
|
<b>{t('save')}</b>
|
2024-06-07 19:27:27 +08:00
|
|
|
</Button>
|
2024-08-09 18:59:16 +08:00
|
|
|
<Button type="primary" onClick={showOverviewModal}>
|
|
|
|
|
<b>{t('publish')}</b>
|
|
|
|
|
</Button>
|
2024-06-07 19:27:27 +08:00
|
|
|
</Space>
|
|
|
|
|
</Flex>
|
2024-08-09 18:59:16 +08:00
|
|
|
{overviewVisible && (
|
|
|
|
|
<ChatOverviewModal
|
|
|
|
|
visible={overviewVisible}
|
|
|
|
|
hideModal={hideOverviewModal}
|
|
|
|
|
id={id!}
|
|
|
|
|
idKey="canvasId"
|
|
|
|
|
></ChatOverviewModal>
|
|
|
|
|
)}
|
2024-06-07 19:27:27 +08:00
|
|
|
</>
|
2024-05-29 10:01:39 +08:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default FlowHeader;
|