This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch fix-connection-delete in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit a8352f9d89c4a17440f89ef3a3b47be6446dc554 Author: mintsweet <[email protected]> AuthorDate: Wed Nov 8 20:25:46 2023 +1300 fix(config-ui): not catch error when connection delete --- config-ui/src/features/connections/slice.ts | 10 +++++++--- config-ui/src/pages/connection/detail/index.tsx | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config-ui/src/features/connections/slice.ts b/config-ui/src/features/connections/slice.ts index 2908df406..40c8076d6 100644 --- a/config-ui/src/features/connections/slice.ts +++ b/config-ui/src/features/connections/slice.ts @@ -78,9 +78,13 @@ export const updateConnection = createAsyncThunk( export const removeConnection = createAsyncThunk( 'connections/removeConnection', - async ({ plugin, connectionId }: any) => { - await API.connection.remove(plugin, connectionId); - return `${plugin}-${connectionId}`; + async ({ plugin, connectionId }: any, { rejectWithValue }) => { + try { + await API.connection.remove(plugin, connectionId); + return `${plugin}-${connectionId}`; + } catch (err: any) { + return rejectWithValue({ ...err.response.data, status: err.response.status }); + } }, ); diff --git a/config-ui/src/pages/connection/detail/index.tsx b/config-ui/src/pages/connection/detail/index.tsx index 9ac4eccc1..da9d7c56c 100644 --- a/config-ui/src/pages/connection/detail/index.tsx +++ b/config-ui/src/pages/connection/detail/index.tsx @@ -104,14 +104,14 @@ export const ConnectionDetailPage = () => { const [, res] = await operator( async () => { try { - await dispatch(removeConnection({ plugin, connectionId })); + await dispatch(removeConnection({ plugin, connectionId })).unwrap(); return { status: 'success' }; } catch (err: any) { - const { status, data } = err.response; + const { status, data, message } = err; return { status: status === 409 ? 'conflict' : 'error', - conflict: data.data ? [...data.data.projects, ...data.data.blueprints] : [], - message: data.message, + conflict: data ? [...data.projects, ...data.blueprints] : [], + message, }; } },
