Просмотр исходного кода

Enabled connection id endpoints for aws

jnfrati 4 лет назад
Родитель
Сommit
175c428694

+ 39 - 31
dashboard/src/main/home/onboarding/steps/ConnectRegistry/forms/_AWSRegistryForm.tsx

@@ -64,24 +64,28 @@ export const CredentialsForm: React.FC<{
       setButtonStatus(validation.error);
       setButtonStatus(validation.error);
       return;
       return;
     }
     }
+    try {
+      const res = await api.createAWSIntegration(
+        "token",
+        {
+          aws_region: awsRegion,
+          aws_access_key_id: accessId,
+          aws_secret_access_key: secretKey,
+        },
+        {
+          id: project.id,
+        }
+      );
+      
+      nextFormStep({
+        credentials: {
+          id: res.data?.id,
+        },
+      });
+    } catch (error) {
+      setButtonStatus("Something went wrong, please try again")
+    }
 
 
-    // const res = await api.createAWSIntegration(
-    //   "token",
-    //   {
-    //     aws_region: awsRegion,
-    //     aws_access_key_id: accessId,
-    //     aws_secret_access_key: secretKey,
-    //   },
-    //   {
-    //     id: project.id,
-    //   }
-    // );
-
-    nextFormStep({
-      credentials: {
-        id: "some_id",
-      },
-    });
   };
   };
 
 
   return (
   return (
@@ -158,21 +162,25 @@ export const SettingsForm: React.FC<{
       setButtonStatus(validation.error);
       setButtonStatus(validation.error);
       return;
       return;
     }
     }
+    try {
+      await api.connectECRRegistry(
+        "<token>",
+        {
+          name: registryName,
+          aws_integration_id: snap.StateHandler.connected_registry.credentials.id,
+        },
+        { id: project.id }
+      );
+      
+      nextFormStep({
+        settings: {
+          registry_name: registryName,
+        },
+      });
+    } catch (error) {
+      setButtonStatus("Couldn't connect registry.")
+    }
 
 
-    // await api.connectECRRegistry(
-    //   "<token>",
-    //   {
-    //     name: registryName,
-    //     aws_integration_id: snap.StateHandler.connected_registry.credentials.id,
-    //   },
-    //   { id: project.id }
-    // );
-
-    nextFormStep({
-      settings: {
-        registry_name: registryName,
-      },
-    });
   };
   };
 
 
   return (
   return (

+ 21 - 17
dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/_AWSProvsionerForm.tsx

@@ -69,23 +69,27 @@ export const CredentialsForm: React.FC<{
       return;
       return;
     }
     }
 
 
-    // const res = await api.createAWSIntegration(
-    //   "token",
-    //   {
-    //     aws_region: awsRegion,
-    //     aws_access_key_id: accessId,
-    //     aws_secret_access_key: secretKey,
-    //   },
-    //   {
-    //     id: project.id,
-    //   }
-    // );
-
-    nextFormStep({
-      credentials: {
-        id: "res.data.id",
-      },
-    });
+    try {
+      const res = await api.createAWSIntegration(
+        "token",
+        {
+          aws_region: awsRegion,
+          aws_access_key_id: accessId,
+          aws_secret_access_key: secretKey,
+        },
+        {
+          id: project.id,
+        }
+      );
+      
+      nextFormStep({
+        credentials: {
+          id: res.data?.id,
+        },
+      });
+    } catch (error) {
+      setButtonStatus("Something went wrong, please try again")
+    }    
   };
   };
 
 
   return (
   return (