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

likyh 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 a8e93588 fix: fix the wrong router when adding a connection (#2893)
a8e93588 is described below

commit a8e935886047520b378714d9c30c0026605765a4
Author: likyh <[email protected]>
AuthorDate: Wed Aug 31 22:19:43 2022 +0800

    fix: fix the wrong router when adding a connection (#2893)
    
    * fix: fix wrong router when adding connection
    
    * refactor: replace connectionLimit with existing state
    
    Co-authored-by: linyh <[email protected]>
---
 config-ui/src/hooks/useConnectionManager.jsx       |  2 +-
 .../src/pages/configure/integration/manage.jsx     | 30 ++++------------------
 2 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/config-ui/src/hooks/useConnectionManager.jsx 
b/config-ui/src/hooks/useConnectionManager.jsx
index 4633118e..37bb6271 100644
--- a/config-ui/src/hooks/useConnectionManager.jsx
+++ b/config-ui/src/hooks/useConnectionManager.jsx
@@ -286,7 +286,7 @@ function useConnectionManager (
           testConnection()
         }
         if (!updateMode) {
-          history.push(`/integrations/${provider.id}`)
+          history.replace(`/integrations/${provider.id}`)
         }
       }
     })
diff --git a/config-ui/src/pages/configure/integration/manage.jsx 
b/config-ui/src/pages/configure/integration/manage.jsx
index 9e9a6886..c18238a1 100644
--- a/config-ui/src/pages/configure/integration/manage.jsx
+++ b/config-ui/src/pages/configure/integration/manage.jsx
@@ -55,7 +55,7 @@ export default function ManageIntegration () {
   const [deleteId, setDeleteId] = useState()
 
   const {
-    sourceLimits,
+    connectionLimitReached,
     allConnections: connections,
     testedConnections,
     isFetching: isLoading,
@@ -69,10 +69,6 @@ export default function ManageIntegration () {
     activeProvider
   })
 
-  useEffect(() => {
-
-  }, [activeProvider])
-
   const addConnection = () => {
     history.push(`/connections/add/${activeProvider.id}`)
   }
@@ -90,14 +86,6 @@ export default function ManageIntegration () {
     console.log('>> editing/modifying connection: ', id, endpoint)
   }
 
-  // @todo: Implement
-  // const runCollection = (connection) => {
-  //   const { id, endpoint } = connection
-  //   ToastNotification.clear()
-  //   ToastNotification.show({ message: `Triggered Collection Process on 
${connection.name}`, icon: 'info-sign' })
-  //   console.log('>> running connection: ', id, endpoint)
-  // }
-
   const runDeletion = (connection) => {
     setIsRunningDelete(true)
     try {
@@ -111,10 +99,6 @@ export default function ManageIntegration () {
     fetchAllConnections(false)
   }
 
-  const maxConnectionsExceeded = (limit, totalConnections) => {
-    return totalConnections > 0 && totalConnections >= limit
-  }
-
   const getTestedConnection = (connection) => {
     return testedConnections.find(tC => tC.ID === connection.ID)
   }
@@ -148,10 +132,6 @@ export default function ManageIntegration () {
     setActiveProvider(integrations.find(p => p.id === providerId))
   }, [])
 
-  useEffect(() => {
-    console.log('>> CONNECTION SOURCE LIMITS', sourceLimits)
-  }, [connections, sourceLimits])
-
   useEffect(() => {
     let flushTimeout
     if (deleteComplete && deleteComplete.connection) {
@@ -250,7 +230,7 @@ export default function ManageIntegration () {
                     <Button
                       id='btn-add-new-connection'
                       className='add-new-connection'
-                      
disabled={maxConnectionsExceeded(sourceLimits[activeProvider.id], 
connections.length)}
+                      disabled={connectionLimitReached}
                       onClick={addConnection}
                       rightIcon='add'
                       intent='primary'
@@ -263,7 +243,7 @@ export default function ManageIntegration () {
                     <table className='bp3-html-table bp3-html-table-bordered 
connections-table' style={{ width: '100%' }}>
                       <thead>
                         <tr>
-                          {!sourceLimits[activeProvider.id] && (<th>ID</th>)}
+                          {!connectionLimitReached && (<th>ID</th>)}
                           <th>Connection Name</th>
                           <th>Endpoint</th>
                           <th>Status</th>
@@ -277,7 +257,7 @@ export default function ManageIntegration () {
                             // eslint-disable-next-line max-len
                             className={getTestedConnection(connection) && 
getTestedConnection(connection).status !== 1 ? 'connection-offline' : 
'connection-online'}
                           >
-                            {!sourceLimits[activeProvider.id] && (
+                            {!connectionLimitReached && (
                               <td
                                 style={{ cursor: 'pointer' }}
                                 className='cell-name'
@@ -364,7 +344,7 @@ export default function ManageIntegration () {
                         ))}
                       </tbody>
                     </table>
-                    {maxConnectionsExceeded(sourceLimits[activeProvider.id], 
connections.length) && (
+                    {connectionLimitReached && (
                       <p style={{ margin: 0, padding: '10px', backgroundColor: 
'#f0f0f0', borderTop: '1px solid #cccccc' }}>
                         <Icon icon='warning-sign' size='16' 
color={Colors.GRAY1} style={{ marginRight: '5px' }} />
                         You have reached the maximum number of allowed 
connections for this provider.

Reply via email to