You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by mi...@apache.org on 2023/11/08 07:25:59 UTC

(incubator-devlake) branch fix-connection-delete created (now a8352f9d8)

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

mintsweet pushed a change to branch fix-connection-delete
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


      at a8352f9d8 fix(config-ui): not catch error when connection delete

This branch includes the following new commits:

     new a8352f9d8 fix(config-ui): not catch error when connection delete

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-devlake) 01/01: fix(config-ui): not catch error when connection delete

Posted by mi...@apache.org.
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 <0x...@gmail.com>
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,
           };
         }
       },