mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
Update how chatflow data is updated when configuration dialog is open
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { useEffect, useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useSelector } from 'react-redux'
|
|
||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import { Box, Dialog, DialogContent, DialogTitle, Tabs, Tab } from '@mui/material'
|
import { Box, Dialog, DialogContent, DialogTitle, Tabs, Tab } from '@mui/material'
|
||||||
import SpeechToText from './SpeechToText'
|
import SpeechToText from './SpeechToText'
|
||||||
@@ -70,18 +69,6 @@ const ChatflowConfigurationDialog = ({ show, dialogProps, onCancel }) => {
|
|||||||
const portalElement = document.getElementById('portal')
|
const portalElement = document.getElementById('portal')
|
||||||
const [tabValue, setTabValue] = useState(0)
|
const [tabValue, setTabValue] = useState(0)
|
||||||
|
|
||||||
const canvas = useSelector((state) => state.canvas)
|
|
||||||
const [canvasDataStore, setCanvasDataStore] = useState(canvas)
|
|
||||||
const [chatflow, setChatflow] = useState(null)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setCanvasDataStore(canvas)
|
|
||||||
}, [canvas])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setChatflow(canvasDataStore.chatflow)
|
|
||||||
}, [canvasDataStore.chatflow])
|
|
||||||
|
|
||||||
const component = show ? (
|
const component = show ? (
|
||||||
<Dialog
|
<Dialog
|
||||||
onClose={onCancel}
|
onClose={onCancel}
|
||||||
@@ -113,11 +100,11 @@ const ChatflowConfigurationDialog = ({ show, dialogProps, onCancel }) => {
|
|||||||
{CHATFLOW_CONFIGURATION_TABS.map((item, index) => (
|
{CHATFLOW_CONFIGURATION_TABS.map((item, index) => (
|
||||||
<TabPanel key={index} value={tabValue} index={index}>
|
<TabPanel key={index} value={tabValue} index={index}>
|
||||||
{item.id === 'rateLimiting' && <Configuration />}
|
{item.id === 'rateLimiting' && <Configuration />}
|
||||||
{item.id === 'conversationStarters' ? <StarterPrompts dialogProps={{ chatflow }} /> : null}
|
{item.id === 'conversationStarters' ? <StarterPrompts dialogProps={dialogProps} /> : null}
|
||||||
{item.id === 'speechToText' ? <SpeechToText dialogProps={{ chatflow }} /> : null}
|
{item.id === 'speechToText' ? <SpeechToText dialogProps={dialogProps} /> : null}
|
||||||
{item.id === 'chatFeedback' ? <ChatFeedback dialogProps={{ chatflow }} /> : null}
|
{item.id === 'chatFeedback' ? <ChatFeedback dialogProps={dialogProps} /> : null}
|
||||||
{item.id === 'allowedDomains' ? <AllowedDomains dialogProps={{ chatflow }} /> : null}
|
{item.id === 'allowedDomains' ? <AllowedDomains dialogProps={dialogProps} /> : null}
|
||||||
{item.id === 'analyseChatflow' ? <AnalyseFlow dialogProps={{ chatflow }} /> : null}
|
{item.id === 'analyseChatflow' ? <AnalyseFlow dialogProps={dialogProps} /> : null}
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
))}
|
))}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@@ -171,6 +171,13 @@ const CanvasHeader = ({ chatflow, handleSaveFlow, handleDeleteFlow, handleLoadFl
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (chatflow) {
|
if (chatflow) {
|
||||||
setFlowName(chatflow.name)
|
setFlowName(chatflow.name)
|
||||||
|
// if configuration dialog is open, update its data
|
||||||
|
if (chatflowConfigurationDialogOpen) {
|
||||||
|
setChatflowConfigurationDialogProps({
|
||||||
|
title: 'Chatflow Configuration',
|
||||||
|
chatflow
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [chatflow])
|
}, [chatflow])
|
||||||
|
|
||||||
@@ -381,6 +388,7 @@ const CanvasHeader = ({ chatflow, handleSaveFlow, handleDeleteFlow, handleLoadFl
|
|||||||
onCancel={() => setViewMessagesDialogOpen(false)}
|
onCancel={() => setViewMessagesDialogOpen(false)}
|
||||||
/>
|
/>
|
||||||
<ChatflowConfigurationDialog
|
<ChatflowConfigurationDialog
|
||||||
|
key='chatflowConfiguration'
|
||||||
show={chatflowConfigurationDialogOpen}
|
show={chatflowConfigurationDialogOpen}
|
||||||
dialogProps={chatflowConfigurationDialogProps}
|
dialogProps={chatflowConfigurationDialogProps}
|
||||||
onCancel={() => setChatflowConfigurationDialogOpen(false)}
|
onCancel={() => setChatflowConfigurationDialogOpen(false)}
|
||||||
|
|||||||
Reference in New Issue
Block a user