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 a4c23da5e fix(config-ui): distinguish undeletable connection reasons 
(#5607)
a4c23da5e is described below

commit a4c23da5e866f7b3d75170b5b313454141a71acc
Author: 青湛 <[email protected]>
AuthorDate: Fri Jun 30 17:08:04 2023 +1200

    fix(config-ui): distinguish undeletable connection reasons (#5607)
---
 config-ui/src/pages/connection/detail/index.tsx | 42 +++++++++++++++++++++----
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/config-ui/src/pages/connection/detail/index.tsx 
b/config-ui/src/pages/connection/detail/index.tsx
index f0ef64f6d..01331b951 100644
--- a/config-ui/src/pages/connection/detail/index.tsx
+++ b/config-ui/src/pages/connection/detail/index.tsx
@@ -94,7 +94,10 @@ const ConnectionDetail = ({ plugin, connectionId }: Props) 
=> {
           return { status: 'success' };
         } catch (err: any) {
           const { status, data } = err.response;
-          return { status: status === 409 ? 'conflict' : 'error', conflict: 
[...data.projects, ...data.blueprints] };
+          return {
+            status: status === 409 ? 'conflict' : 'error',
+            conflict: data ? [...data.projects, ...data.blueprints] : [],
+          };
         }
       },
       {
@@ -429,19 +432,46 @@ const ConnectionDetail = ({ plugin, connectionId }: 
Props) => {
           )}
         </Dialog>
       )}
-      {(type === 'deleteConnectionFailed' || type === 'deleteDataScopeFailed') 
&& (
+      {type === 'deleteConnectionFailed' && (
+        <Dialog
+          isOpen
+          style={{ width: 820 }}
+          footer={null}
+          title={`This Data Connection can not be deleted.`}
+          onCancel={handleHideDialog}
+        >
+          <S.DialogBody>
+            {!conflict.length ? (
+              <Message content="Please delete all data scope(s) before you 
delete this Data Connection." />
+            ) : (
+              <>
+                <Message
+                  content={`This Data Connection can not be deleted because it 
has been used in the following projects/blueprints:`}
+                />
+                <ul>
+                  {conflict.map((it) => (
+                    <li>{it}</li>
+                  ))}
+                </ul>
+              </>
+            )}
+            <Buttons position="bottom" align="right">
+              <Button intent={Intent.PRIMARY} text="OK" 
onClick={handleHideDialog} />
+            </Buttons>
+          </S.DialogBody>
+        </Dialog>
+      )}
+      {type === 'deleteDataScopeFailed' && (
         <Dialog
           isOpen
           style={{ width: 820 }}
           footer={null}
-          title={`This Data ${type === 'deleteConnectionFailed' ? 'Connection' 
: 'Scope'} can not be deleted.`}
+          title={`This Data Scope can not be deleted.`}
           onCancel={handleHideDialog}
         >
           <S.DialogBody>
             <Message
-              content={`This Data ${
-                type === 'deleteConnectionFailed' ? 'Connection' : 'Scope'
-              } can not be deleted because it has been used in the following 
projects/blueprints:`}
+              content={`This Data Scope can not be deleted because it has been 
used in the following projects/blueprints:`}
             />
             <ul>
               {conflict.map((it) => (

Reply via email to