mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: Disable automatic saving of agent during running agent #3349 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import ChatOverviewModal from '@/components/api-service/chat-overview-modal';
|
|
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
|
|
import { useFetchFlow } from '@/hooks/flow-hooks';
|
|
import { ArrowLeftOutlined } from '@ant-design/icons';
|
|
import { Button, Flex, Space } from 'antd';
|
|
import { Link, useParams } from 'umi';
|
|
import FlowIdModal from '../flow-id-modal';
|
|
import {
|
|
useSaveGraph,
|
|
useSaveGraphBeforeOpeningDebugDrawer,
|
|
useWatchAgentChange,
|
|
} from '../hooks';
|
|
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 {
|
|
visible: overviewVisible,
|
|
hideModal: hideOverviewModal,
|
|
// showModal: showOverviewModal,
|
|
} = useSetModalState();
|
|
const { visible, hideModal, showModal } = useSetModalState();
|
|
const { id } = useParams();
|
|
const time = useWatchAgentChange(chatDrawerVisible);
|
|
|
|
return (
|
|
<>
|
|
<Flex
|
|
align="center"
|
|
justify={'space-between'}
|
|
gap={'large'}
|
|
className={styles.flowHeader}
|
|
>
|
|
<Space size={'large'}>
|
|
<Link to={`/flow`}>
|
|
<ArrowLeftOutlined />
|
|
</Link>
|
|
<div className="flex flex-col">
|
|
<span className="font-semibold text-[18px]">{data.title}</span>
|
|
<span className="font-normal text-sm">
|
|
{t('autosaved')} {time}
|
|
</span>
|
|
</div>
|
|
</Space>
|
|
<Space size={'large'}>
|
|
<Button onClick={handleRun}>
|
|
<b>{t('run')}</b>
|
|
</Button>
|
|
<Button type="primary" onClick={saveGraph}>
|
|
<b>{t('save')}</b>
|
|
</Button>
|
|
{/* <Button type="primary" onClick={showOverviewModal} disabled>
|
|
<b>{t('publish')}</b>
|
|
</Button> */}
|
|
<Button type="primary" onClick={showModal}>
|
|
<b>Agent ID</b>
|
|
</Button>
|
|
</Space>
|
|
</Flex>
|
|
{overviewVisible && (
|
|
<ChatOverviewModal
|
|
visible={overviewVisible}
|
|
hideModal={hideOverviewModal}
|
|
id={id!}
|
|
idKey="canvasId"
|
|
></ChatOverviewModal>
|
|
)}
|
|
{visible && <FlowIdModal hideModal={hideModal}></FlowIdModal>}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default FlowHeader;
|