mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
feature/export-import-3 (#4234)
* fix: add ASSISTANT chatflow * feat: add mvp export import for chatMessage, chatFeedback, customTemplate, documentStore * feat: add function to handle duplicate ids during import * chore: typo 'orginalData' to 'originalData' * feat: add import conditions for chatMessage and chatMessageFeedback * feat: reduce spacing before saving chatflows
This commit is contained in:
@@ -3,8 +3,8 @@ import { exportData, stringify } from '@/utils/exportImport'
|
||||
import useNotifier from '@/utils/useNotifier'
|
||||
import PropTypes from 'prop-types'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
|
||||
// material-ui
|
||||
import {
|
||||
@@ -12,22 +12,22 @@ import {
|
||||
Box,
|
||||
Button,
|
||||
ButtonBase,
|
||||
Checkbox,
|
||||
ClickAwayListener,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
Divider,
|
||||
FormControlLabel,
|
||||
List,
|
||||
ListItemButton,
|
||||
ListItemIcon,
|
||||
ListItemText,
|
||||
Paper,
|
||||
Popper,
|
||||
Typography,
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
DialogContent,
|
||||
Stack,
|
||||
FormControlLabel,
|
||||
Checkbox,
|
||||
DialogActions
|
||||
Typography
|
||||
} from '@mui/material'
|
||||
import { useTheme } from '@mui/material/styles'
|
||||
|
||||
@@ -40,9 +40,9 @@ import AboutDialog from '@/ui-component/dialog/AboutDialog'
|
||||
import Transitions from '@/ui-component/extended/Transitions'
|
||||
|
||||
// assets
|
||||
import ExportingGIF from '@/assets/images/Exporting.gif'
|
||||
import { IconFileExport, IconFileUpload, IconInfoCircle, IconLogout, IconSettings, IconX } from '@tabler/icons-react'
|
||||
import './index.css'
|
||||
import ExportingGIF from '@/assets/images/Exporting.gif'
|
||||
|
||||
//API
|
||||
import exportImportApi from '@/api/exportimport'
|
||||
@@ -52,12 +52,22 @@ import useApi from '@/hooks/useApi'
|
||||
import { getErrorMessage } from '@/utils/errorHandler'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
const dataToExport = ['Chatflows', 'Agentflows', 'Tools', 'Variables', 'Assistants']
|
||||
const dataToExport = [
|
||||
'Agentflows',
|
||||
'Assistants',
|
||||
'Chatflows',
|
||||
'Chat Messages',
|
||||
'Chat Feedbacks',
|
||||
'Custom Templates',
|
||||
'Document Stores',
|
||||
'Tools',
|
||||
'Variables'
|
||||
]
|
||||
|
||||
const ExportDialog = ({ show, onCancel, onExport }) => {
|
||||
const portalElement = document.getElementById('portal')
|
||||
|
||||
const [selectedData, setSelectedData] = useState(['Chatflows', 'Agentflows', 'Tools', 'Variables', 'Assistants'])
|
||||
const [selectedData, setSelectedData] = useState(dataToExport)
|
||||
const [isExporting, setIsExporting] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -243,11 +253,15 @@ const ProfileSection = ({ username, handleLogout }) => {
|
||||
|
||||
const onExport = (data) => {
|
||||
const body = {}
|
||||
if (data.includes('Chatflows')) body.chatflow = true
|
||||
if (data.includes('Agentflows')) body.agentflow = true
|
||||
if (data.includes('Assistants')) body.assistant = true
|
||||
if (data.includes('Chatflows')) body.chatflow = true
|
||||
if (data.includes('Chat Messages')) body.chat_message = true
|
||||
if (data.includes('Chat Feedbacks')) body.chat_feedback = true
|
||||
if (data.includes('Custom Templates')) body.custom_template = true
|
||||
if (data.includes('Document Stores')) body.document_store = true
|
||||
if (data.includes('Tools')) body.tool = true
|
||||
if (data.includes('Variables')) body.variable = true
|
||||
if (data.includes('Assistants')) body.assistant = true
|
||||
|
||||
exportAllApi.request(body)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,8 @@ const sanitizeAssistant = (Assistant) => {
|
||||
id: assistant.id,
|
||||
details: assistant.details,
|
||||
credential: assistant.credential,
|
||||
iconSrc: assistant.iconSrc
|
||||
iconSrc: assistant.iconSrc,
|
||||
type: assistant.type
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -76,11 +77,17 @@ export const stringify = (object) => {
|
||||
export const exportData = (exportAllData) => {
|
||||
try {
|
||||
return {
|
||||
Tool: sanitizeTool(exportAllData.Tool),
|
||||
ChatFlow: sanitizeChatflow(exportAllData.ChatFlow),
|
||||
AgentFlow: sanitizeChatflow(exportAllData.AgentFlow),
|
||||
Variable: sanitizeVariable(exportAllData.Variable),
|
||||
Assistant: sanitizeAssistant(exportAllData.Assistant)
|
||||
AssistantFlow: sanitizeChatflow(exportAllData.AssistantFlow),
|
||||
Assistant: sanitizeAssistant(exportAllData.Assistant),
|
||||
ChatFlow: sanitizeChatflow(exportAllData.ChatFlow),
|
||||
ChatMessage: exportAllData.ChatMessage,
|
||||
ChatMessageFeedback: exportAllData.ChatMessageFeedback,
|
||||
CustomTemplate: exportAllData.CustomTemplate,
|
||||
DocumentStore: exportAllData.DocumentStore,
|
||||
DocumentStoreFileChunk: exportAllData.DocumentStoreFileChunk,
|
||||
Tool: sanitizeTool(exportAllData.Tool),
|
||||
Variable: sanitizeVariable(exportAllData.Variable)
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(`exportImport.exportData ${getErrorMessage(error)}`)
|
||||
|
||||
Reference in New Issue
Block a user