* 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 { confirm } = useConfirm()
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const updateChatflowApi = useApi(chatflowsApi.updateChatflow)
|
const updateChatflowApi = useApi(chatflowsApi.updateChatflow)
|
||||||
|
|
@ -166,10 +166,16 @@ export default function FlowListMenu({ chatflow, isAgentCanvas, isAgentflowV2, s
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await updateChatflowApi.request(chatflow.id, updateBody)
|
await updateChatflowApi.request(chatflow.id, updateBody)
|
||||||
|
const params = {
|
||||||
|
page: currentPage,
|
||||||
|
limit: pageLimit
|
||||||
|
}
|
||||||
if (isAgentCanvas && isAgentflowV2) {
|
if (isAgentCanvas && isAgentflowV2) {
|
||||||
await updateFlowsApi.request('AGENTFLOW')
|
await updateFlowsApi.request('AGENTFLOW', params)
|
||||||
|
} else if (isAgentCanvas) {
|
||||||
|
await updateFlowsApi.request('MULTIAGENT', params)
|
||||||
} else {
|
} else {
|
||||||
await updateFlowsApi.request(isAgentCanvas ? 'MULTIAGENT' : undefined)
|
await updateFlowsApi.request(params)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (setError) setError(error)
|
if (setError) setError(error)
|
||||||
|
|
@ -209,7 +215,15 @@ export default function FlowListMenu({ chatflow, isAgentCanvas, isAgentflowV2, s
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await updateChatflowApi.request(chatflow.id, updateBody)
|
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) {
|
} catch (error) {
|
||||||
if (setError) setError(error)
|
if (setError) setError(error)
|
||||||
enqueueSnackbar({
|
enqueueSnackbar({
|
||||||
|
|
@ -241,10 +255,16 @@ export default function FlowListMenu({ chatflow, isAgentCanvas, isAgentflowV2, s
|
||||||
if (isConfirmed) {
|
if (isConfirmed) {
|
||||||
try {
|
try {
|
||||||
await chatflowsApi.deleteChatflow(chatflow.id)
|
await chatflowsApi.deleteChatflow(chatflow.id)
|
||||||
|
const params = {
|
||||||
|
page: currentPage,
|
||||||
|
limit: pageLimit
|
||||||
|
}
|
||||||
if (isAgentCanvas && isAgentflowV2) {
|
if (isAgentCanvas && isAgentflowV2) {
|
||||||
await updateFlowsApi.request('AGENTFLOW')
|
await updateFlowsApi.request('AGENTFLOW', params)
|
||||||
|
} else if (isAgentCanvas) {
|
||||||
|
await updateFlowsApi.request('MULTIAGENT', params)
|
||||||
} else {
|
} else {
|
||||||
await updateFlowsApi.request(isAgentCanvas ? 'MULTIAGENT' : undefined)
|
await updateFlowsApi.request(params)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (setError) setError(error)
|
if (setError) setError(error)
|
||||||
|
|
@ -454,5 +474,7 @@ FlowListMenu.propTypes = {
|
||||||
isAgentCanvas: PropTypes.bool,
|
isAgentCanvas: PropTypes.bool,
|
||||||
isAgentflowV2: PropTypes.bool,
|
isAgentflowV2: PropTypes.bool,
|
||||||
setError: PropTypes.func,
|
setError: PropTypes.func,
|
||||||
updateFlowsApi: PropTypes.object
|
updateFlowsApi: PropTypes.object,
|
||||||
|
currentPage: PropTypes.number,
|
||||||
|
pageLimit: PropTypes.number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,9 @@ export const FlowListTable = ({
|
||||||
updateFlowsApi,
|
updateFlowsApi,
|
||||||
setError,
|
setError,
|
||||||
isAgentCanvas,
|
isAgentCanvas,
|
||||||
isAgentflowV2
|
isAgentflowV2,
|
||||||
|
currentPage,
|
||||||
|
pageLimit
|
||||||
}) => {
|
}) => {
|
||||||
const { hasPermission } = useAuth()
|
const { hasPermission } = useAuth()
|
||||||
const isActionsAvailable = isAgentCanvas
|
const isActionsAvailable = isAgentCanvas
|
||||||
|
|
@ -331,6 +333,8 @@ export const FlowListTable = ({
|
||||||
chatflow={row}
|
chatflow={row}
|
||||||
setError={setError}
|
setError={setError}
|
||||||
updateFlowsApi={updateFlowsApi}
|
updateFlowsApi={updateFlowsApi}
|
||||||
|
currentPage={currentPage}
|
||||||
|
pageLimit={pageLimit}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</StyledTableCell>
|
</StyledTableCell>
|
||||||
|
|
@ -355,5 +359,7 @@ FlowListTable.propTypes = {
|
||||||
updateFlowsApi: PropTypes.object,
|
updateFlowsApi: PropTypes.object,
|
||||||
setError: PropTypes.func,
|
setError: PropTypes.func,
|
||||||
isAgentCanvas: PropTypes.bool,
|
isAgentCanvas: PropTypes.bool,
|
||||||
isAgentflowV2: PropTypes.bool
|
isAgentflowV2: PropTypes.bool,
|
||||||
|
currentPage: PropTypes.number,
|
||||||
|
pageLimit: PropTypes.number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,8 @@ const Agentflows = () => {
|
||||||
filterFunction={filterFlows}
|
filterFunction={filterFlows}
|
||||||
updateFlowsApi={getAllAgentflows}
|
updateFlowsApi={getAllAgentflows}
|
||||||
setError={setError}
|
setError={setError}
|
||||||
|
currentPage={currentPage}
|
||||||
|
pageLimit={pageLimit}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{/* Pagination and Page Size Controls */}
|
{/* Pagination and Page Size Controls */}
|
||||||
|
|
|
||||||
|
|
@ -208,6 +208,8 @@ const Chatflows = () => {
|
||||||
filterFunction={filterFlows}
|
filterFunction={filterFlows}
|
||||||
updateFlowsApi={getAllChatflowsApi}
|
updateFlowsApi={getAllChatflowsApi}
|
||||||
setError={setError}
|
setError={setError}
|
||||||
|
currentPage={currentPage}
|
||||||
|
pageLimit={pageLimit}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{/* Pagination and Page Size Controls */}
|
{/* Pagination and Page Size Controls */}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue