This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch feat-dora-config in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 8cfff2d31effa1926676ed50692255a7a990b0e5 Author: mintsweet <0x1304...@gmail.com> AuthorDate: Mon Sep 23 15:32:04 2024 +1200 fix: throw the error when check matched items request failed --- .../components/check-matched-items/index.tsx | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/config-ui/src/plugins/components/check-matched-items/index.tsx b/config-ui/src/plugins/components/check-matched-items/index.tsx index ee4a613f5..c3537827d 100644 --- a/config-ui/src/plugins/components/check-matched-items/index.tsx +++ b/config-ui/src/plugins/components/check-matched-items/index.tsx @@ -23,6 +23,7 @@ import { Flex, Button, Tag } from 'antd'; import API from '@/api'; import type { ITransform2deployments } from '@/api/scope-config/types'; import { ExternalLink } from '@/components'; +import { operator } from '@/utils'; const reducer = (state: ITransform2deployments[], action: { type: string; payload?: ITransform2deployments[] }) => { switch (action.type) { @@ -57,20 +58,26 @@ export const CheckMatchedItems = ({ plugin, connectionId, transformation }: Prop }, [transformation.deploymentPattern, transformation.productionPattern]); const handleLoadItems = async () => { - setLoading(true); - const res = await API.scopeConfig.transform2deployments(plugin, connectionId, { - deploymentPattern: transformation.deploymentPattern, - productionPattern: transformation.productionPattern, - page, - pageSize: 10, - }); + const [success, res] = await operator( + () => + API.scopeConfig.transform2deployments(plugin, connectionId, { + deploymentPattern: transformation.deploymentPattern, + productionPattern: transformation.productionPattern, + page, + pageSize: 10, + }), + { + setOperating: setLoading, + hideToast: true, + }, + ); - dispatch({ type: 'APPEND', payload: res.data ?? [] }); - - setInitial(true); - setPage(page + 1); - setTotal(res.total); - setLoading(false); + if (success) { + dispatch({ type: 'APPEND', payload: res.data ?? [] }); + setInitial(true); + setPage(page + 1); + setTotal(res.total); + } }; return (