mintsweet commented on code in PR #2928:
URL: https://github.com/apache/incubator-devlake/pull/2928#discussion_r963200064


##########
config-ui/src/hooks/useConnectionManager.jsx:
##########
@@ -141,70 +154,66 @@ function useConnectionManager (
     [provider?.id, connectionTestPayload]
   )
 
-  const saveConnection = (configurationSettings = {}) => {
-    setIsSaving(true)
-    let connectionPayload = { ...configurationSettings }
-    switch (provider.id) {
-      case Providers.JIRA:
-        connectionPayload = {
-          name: name,
-          endpoint: endpointUrl,
-          username: username,
-          password: password,
-          proxy: proxy,
-          rateLimitPerHour: rateLimit,
-          ...connectionPayload,
-        }
-        break
-      case Providers.TAPD:
-        connectionPayload = {
-          name: name,
-          endpoint: endpointUrl,
-          username: username,
-          password: password,
-          proxy: proxy,
-          rateLimitPerHour: rateLimit,
-          ...connectionPayload,
-        }
-        break
-      case Providers.GITHUB:
-        connectionPayload = {
-          name: name,
-          endpoint: endpointUrl,
-          token: token,
-          proxy: proxy,
-          rateLimitPerHour: rateLimit,
-          ...connectionPayload,
-        }
-        break
-      case Providers.JENKINS:
-      // eslint-disable-next-line max-len
-        connectionPayload = {
-          name: name,
-          endpoint: endpointUrl,
-          username: username,
-          password: password,
-          proxy: proxy,
-          rateLimitPerHour: rateLimit,
-          ...connectionPayload,
-        }
-        break
-      case Providers.GITLAB:
-        connectionPayload = {
-          name: name,
-          endpoint: endpointUrl,
-          token: token,
-          proxy: proxy,
-          rateLimitPerHour: rateLimit,
-          ...connectionPayload,
+  const notifyConnectionSaveSuccess = useCallback((message = 'Connection saved 
successfully.') => {
+    ToastNotification.show({
+      message: message,
+      intent: 'success',
+      icon: 'small-tick',
+    })
+  }, [])
+
+  const notifyConnectionSaveFailure = useCallback((message = 'Connection 
failed to save, please try again.') => {
+    ToastNotification.show({
+      message: message,
+      intent: 'danger',
+      icon: 'error',
+    })
+  }, [])
+
+  const fetchConnection = useCallback(
+    (silent = false, notify = false, cId = null) => {
+      console.log(`>> FETCHING CONNECTION [PROVIDER = ${provider?.id}]....`)
+      try {
+        setIsFetching(!silent)
+        setErrors([])
+        console.log('>> FETCHING CONNECTION SOURCE')
+        const fetch = async () => {
+          const f = await request.get(
+            `${DEVLAKE_ENDPOINT}/plugins/${provider?.id}/connections/${cId || 
connectionId}`
+          )
+          const connectionData = f.data
+          console.log('>> RAW CONNECTION DATA FROM API...', connectionData)
+          setActiveConnection(new Connection({
+            ...connectionData
+          }))
+          setTimeout(() => {

Review Comment:
   I am talking about the problem of setTimeout. If the response time is 
greater than the set time, the pop-up prompt is wrong.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to