Pārlūkot izejas kodu

Merge pull request #661 from smiclea/fix-edit-endpoint

Fix endpoint fields reverting to previous values
Nashwan Azhari 4 gadi atpakaļ
vecāks
revīzija
1d623f1fa1
3 mainītis faili ar 12 papildinājumiem un 3 dzēšanām
  1. 9 1
      src/stores/ProviderStore.ts
  2. 2 1
      src/utils/ApiCaller.ts
  3. 1 1
      src/utils/ObjectUtils.ts

+ 9 - 1
src/stores/ProviderStore.ts

@@ -176,8 +176,15 @@ class ProviderStore {
     regionsField.enum = [...regionStore.regions]
     regionsField.enum = [...regionStore.regions]
   }
   }
 
 
+  loadingForProvider: ProviderTypes | null = null
+
   @action async getConnectionInfoSchema(providerName: ProviderTypes): Promise<void> {
   @action async getConnectionInfoSchema(providerName: ProviderTypes): Promise<void> {
+    if (this.connectionSchemaLoading && this.loadingForProvider === providerName) {
+      return
+    }
+
     this.connectionSchemaLoading = true
     this.connectionSchemaLoading = true
+    this.loadingForProvider = providerName
 
 
     try {
     try {
       const fields: Field[] = await ProviderSource.getConnectionInfoSchema(providerName)
       const fields: Field[] = await ProviderSource.getConnectionInfoSchema(providerName)
@@ -330,7 +337,8 @@ class ProviderStore {
         isValid(),
         isValid(),
       )
       )
       return options
       return options
-    } catch (err) {
+    } catch (e) {
+      const err: any = e
       console.error(err)
       console.error(err)
       canceled = err ? err.canceled : false
       canceled = err ? err.canceled : false
       if (canceled) {
       if (canceled) {

+ 2 - 1
src/utils/ApiCaller.ts

@@ -116,7 +116,8 @@ class ApiCaller {
         cacher.save({ key: options.url, data: response.data })
         cacher.save({ key: options.url, data: response.data })
       }
       }
       return response
       return response
-    } catch (error) {
+    } catch (err) {
+      const error: any = err
       if (error.response) {
       if (error.response) {
         throw apiCallerHandlers.handleErrorResponse(error)
         throw apiCallerHandlers.handleErrorResponse(error)
       } else if (error.request) {
       } else if (error.request) {

+ 1 - 1
src/utils/ObjectUtils.ts

@@ -72,7 +72,7 @@ class ObjectUtils {
   }
   }
 
 
   static async wait(ms: number) {
   static async wait(ms: number) {
-    return new Promise(r => setTimeout(() => r(), ms))
+    return new Promise<void>(r => setTimeout(() => r(), ms))
   }
   }
 
 
   static async waitFor(
   static async waitFor(