mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Creating a data flow from a template page #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -46,6 +46,7 @@ export declare interface IFlow {
|
|||||||
export interface IFlowTemplate {
|
export interface IFlowTemplate {
|
||||||
avatar: string;
|
avatar: string;
|
||||||
canvas_type: string;
|
canvas_type: string;
|
||||||
|
canvas_category?: string;
|
||||||
create_date: string;
|
create_date: string;
|
||||||
create_time: number;
|
create_time: number;
|
||||||
description: {
|
description: {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
|||||||
import { useFetchAgentTemplates, useSetAgent } from '@/hooks/use-agent-request';
|
import { useFetchAgentTemplates, useSetAgent } from '@/hooks/use-agent-request';
|
||||||
import { IFlowTemplate } from '@/interfaces/database/flow';
|
import { IFlowTemplate } from '@/interfaces/database/flow';
|
||||||
|
|
||||||
|
import { AgentCategory } from '@/constants/agent';
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { CreateAgentDialog } from './create-agent-dialog';
|
import { CreateAgentDialog } from './create-agent-dialog';
|
||||||
@ -48,27 +49,36 @@ export default function AgentTemplates() {
|
|||||||
[showCreatingModal],
|
[showCreatingModal],
|
||||||
);
|
);
|
||||||
|
|
||||||
const { navigateToAgent } = useNavigatePage();
|
const { navigateToAgent, navigateToDataflow } = useNavigatePage();
|
||||||
|
|
||||||
const handleOk = useCallback(
|
const handleOk = useCallback(
|
||||||
async (payload: any) => {
|
async (payload: any) => {
|
||||||
let dsl = template?.dsl;
|
let dsl = template?.dsl;
|
||||||
|
const canvasCategory = template?.canvas_category;
|
||||||
|
|
||||||
const ret = await setAgent({
|
const ret = await setAgent({
|
||||||
title: payload.name,
|
title: payload.name,
|
||||||
dsl,
|
dsl,
|
||||||
avatar: template?.avatar,
|
avatar: template?.avatar,
|
||||||
|
canvas_category: canvasCategory,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ret?.code === 0) {
|
if (ret?.code === 0) {
|
||||||
hideCreatingModal();
|
hideCreatingModal();
|
||||||
|
if (canvasCategory === AgentCategory.DataflowCanvas) {
|
||||||
|
navigateToDataflow(ret.data.id)();
|
||||||
|
} else {
|
||||||
navigateToAgent(ret.data.id)();
|
navigateToAgent(ret.data.id)();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
hideCreatingModal,
|
hideCreatingModal,
|
||||||
navigateToAgent,
|
navigateToAgent,
|
||||||
|
navigateToDataflow,
|
||||||
setAgent,
|
setAgent,
|
||||||
template?.avatar,
|
template?.avatar,
|
||||||
|
template?.canvas_category,
|
||||||
template?.dsl,
|
template?.dsl,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -128,6 +138,7 @@ export default function AgentTemplates() {
|
|||||||
visible={creatingVisible}
|
visible={creatingVisible}
|
||||||
hideModal={hideCreatingModal}
|
hideModal={hideCreatingModal}
|
||||||
onOk={handleOk}
|
onOk={handleOk}
|
||||||
|
canvasCategory={template?.canvas_category}
|
||||||
></CreateAgentDialog>
|
></CreateAgentDialog>
|
||||||
)}
|
)}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export enum MenuItemKey {
|
|||||||
CustomerSupport = 'Customer Support',
|
CustomerSupport = 'Customer Support',
|
||||||
Marketing = 'Marketing',
|
Marketing = 'Marketing',
|
||||||
ConsumerApp = 'Consumer App',
|
ConsumerApp = 'Consumer App',
|
||||||
Pipeline = 'Pipeline',
|
Pipeline = 'Ingestion Pipeline',
|
||||||
Other = 'Other',
|
Other = 'Other',
|
||||||
}
|
}
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
|
|||||||
Reference in New Issue
Block a user