This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 1d393462a fix(config-ui): not catch error when connection delete 
(#6416)
1d393462a is described below

commit 1d393462a7d6e99a7d39da664ba89b01c289d8ed
Author: 青湛 <[email protected]>
AuthorDate: Wed Nov 8 21:24:34 2023 +1300

    fix(config-ui): not catch error when connection delete (#6416)
---
 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,
           };
         }
       },

Reply via email to