* fix: agentflow list refresh after deletion (Issue #5360) Root Cause: When deleting an Agentflow from the list view, updateFlowsApi.request() was called without pagination parameters. This caused the backend to return a plain array instead of the expected { data: [], total: 0 } format, leading to a TypeError when accessing .data.length. Solution: - Created refreshAgentflows callback that includes current pagination state - Passed callback through FlowListTable to FlowListMenu - Updated handleDelete to use callback instead of direct API call - Maintains backward compatibility for components without callback Fixes #5360 * reverting * add pagination support to FlowListMenu and FlowListTable --------- Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
parent
b5f7fac015
commit
c9db81096a
|
|
@ -74,7 +74,7 @@ const StyledMenu = styled((props) => (
|
|||
}
|
||||
}))
|
||||
|
||||
export default function FlowListMenu({ chatflow, isAgentCanvas, isAgentflowV2, setError, updateFlowsApi }) {
|
||||
export default function FlowListMenu({ chatflow, isAgentCanvas, isAgentflowV2, setError, updateFlowsApi, currentPage, pageLimit }) {
|
||||
const { confirm } = useConfirm()
|
||||
const dispatch = useDispatch()
|
||||
const updateChatflowApi = useApi(chatflowsApi.updateChatflow)
|
||||
|
|
@ -166,10 +166,16 @@ export default function FlowListMenu({ chatflow, isAgentCanvas, isAgentflowV2, s
|
|||
}
|
||||
try {
|
||||
await updateChatflowApi.request(chatflow.id, updateBody)
|
||||
const params = {
|
||||
page: currentPage,
|
||||
limit: pageLimit
|
||||
}
|
||||
if (isAgentCanvas && isAgentflowV2) {
|
||||
await updateFlowsApi.request('AGENTFLOW')
|
||||
await updateFlowsApi.request('AGENTFLOW', params)
|
||||
} else if (isAgentCanvas) {
|
||||
await updateFlowsApi.request('MULTIAGENT', params)
|
||||
} else {
|
||||
await updateFlowsApi.request(isAgentCanvas ? 'MULTIAGENT' : undefined)
|
||||
await updateFlowsApi.request(params)
|
||||
}
|
||||
} catch (error) {
|
||||
if (setError) setError(error)
|
||||
|
|
@ -209,7 +215,15 @@ export default function FlowListMenu({ chatflow, isAgentCanvas, isAgentflowV2, s
|
|||
}
|
||||
try {
|
||||
await updateChatflowApi.request(chatflow.id, updateBody)
|
||||
await updateFlowsApi.request(isAgentCanvas ? 'AGENTFLOW' : undefined)
|
||||
const params = {
|
||||
page: currentPage,
|
||||
limit: pageLimit
|
||||
}
|
||||
if (isAgentCanvas) {
|
||||
await updateFlowsApi.request('AGENTFLOW', params)
|
||||
} else {
|
||||
await updateFlowsApi.request(params)
|
||||
}
|
||||
} catch (error) {
|
||||
if (setError) setError(error)
|
||||
enqueueSnackbar({
|
||||
|
|
@ -241,10 +255,16 @@ export default function FlowListMenu({ chatflow, isAgentCanvas, isAgentflowV2, s
|
|||
if (isConfirmed) {
|
||||
try {
|
||||
await chatflowsApi.deleteChatflow(chatflow.id)
|
||||
const params = {
|
||||
page: currentPage,
|
||||
limit: pageLimit
|
||||
}
|
||||
if (isAgentCanvas && isAgentflowV2) {
|
||||
await updateFlowsApi.request('AGENTFLOW')
|
||||
await updateFlowsApi.request('AGENTFLOW', params)
|
||||
} else if (isAgentCanvas) {
|
||||
await updateFlowsApi.request('MULTIAGENT', params)
|
||||
} else {
|
||||
await updateFlowsApi.request(isAgentCanvas ? 'MULTIAGENT' : undefined)
|
||||
await updateFlowsApi.request(params)
|
||||
}
|
||||
} catch (error) {
|
||||
if (setError) setError(error)
|
||||
|
|
@ -454,5 +474,7 @@ FlowListMenu.propTypes = {
|
|||
isAgentCanvas: PropTypes.bool,
|
||||
isAgentflowV2: PropTypes.bool,
|
||||
setError: PropTypes.func,
|
||||
updateFlowsApi: PropTypes.object
|
||||
updateFlowsApi: PropTypes.object,
|
||||
currentPage: PropTypes.number,
|
||||
pageLimit: PropTypes.number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,9 @@ export const FlowListTable = ({
|
|||
updateFlowsApi,
|
||||
setError,
|
||||
isAgentCanvas,
|
||||
isAgentflowV2
|
||||
isAgentflowV2,
|
||||
currentPage,
|
||||
pageLimit
|
||||
}) => {
|
||||
const { hasPermission } = useAuth()
|
||||
const isActionsAvailable = isAgentCanvas
|
||||
|
|
@ -331,6 +333,8 @@ export const FlowListTable = ({
|
|||
chatflow={row}
|
||||
setError={setError}
|
||||
updateFlowsApi={updateFlowsApi}
|
||||
currentPage={currentPage}
|
||||
pageLimit={pageLimit}
|
||||
/>
|
||||
</Stack>
|
||||
</StyledTableCell>
|
||||
|
|
@ -355,5 +359,7 @@ FlowListTable.propTypes = {
|
|||
updateFlowsApi: PropTypes.object,
|
||||
setError: PropTypes.func,
|
||||
isAgentCanvas: PropTypes.bool,
|
||||
isAgentflowV2: PropTypes.bool
|
||||
isAgentflowV2: PropTypes.bool,
|
||||
currentPage: PropTypes.number,
|
||||
pageLimit: PropTypes.number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -325,6 +325,8 @@ const Agentflows = () => {
|
|||
filterFunction={filterFlows}
|
||||
updateFlowsApi={getAllAgentflows}
|
||||
setError={setError}
|
||||
currentPage={currentPage}
|
||||
pageLimit={pageLimit}
|
||||
/>
|
||||
)}
|
||||
{/* Pagination and Page Size Controls */}
|
||||
|
|
|
|||
|
|
@ -208,6 +208,8 @@ const Chatflows = () => {
|
|||
filterFunction={filterFlows}
|
||||
updateFlowsApi={getAllChatflowsApi}
|
||||
setError={setError}
|
||||
currentPage={currentPage}
|
||||
pageLimit={pageLimit}
|
||||
/>
|
||||
)}
|
||||
{/* Pagination and Page Size Controls */}
|
||||
|
|
|
|||
Loading…
Reference in New Issue