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


##########
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.') => {

Review Comment:
   Have you given thought or used callbacks before at all prior to making 
comments? This is reusable notification success helper. No it's not 
meaningless, any funcs that are internal to the class are to be wrapped in 
callbacks to prevent unwanted re-renders.



-- 
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