e2corporation commented on code in PR #2928:
URL: https://github.com/apache/incubator-devlake/pull/2928#discussion_r962712554
##########
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(() => {
+ setIsFetching(false)
+ }, 500)
}
- break
- }
+ fetch()
Review Comment:
This `fetch` here is an internal helper method not the HTTP Fetch API.
--
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]