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

Enabled queries for registry and provisioner integration id

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

+ 45 - 34
dashboard/src/main/home/onboarding/steps/ConnectRegistry/forms/_GCPRegistryForm.tsx

@@ -39,24 +39,29 @@ export const CredentialsForm: React.FC<{
       return;
       return;
     }
     }
     setButtonStatus("loading");
     setButtonStatus("loading");
-    // const gcpIntegration = await api
-    //   .createGCPIntegration(
-    //     "<token>",
-    //     {
-    //       gcp_region: "",
-    //       gcp_key_data: serviceAccountKey,
-    //       gcp_project_id: projectId,
-    //     },
-    //     { project_id: project.id }
-    //   )
-    //   .then((res) => res.data);
-
-    nextFormStep({
-      credentials: {
-        id: "some_Id",
-      },
-    });
+    try {
+      const gcpIntegration = await api
+        .createGCPIntegration(
+          "<token>",
+          {
+            gcp_region: "",
+            gcp_key_data: serviceAccountKey,
+            gcp_project_id: projectId,
+          },
+          { project_id: project.id }
+        )
+        .then((res) => res.data);
+
+      nextFormStep({
+        credentials: {
+          id: gcpIntegration?.id,
+        },
+      });
+    } catch (error) {
+      setButtonStatus("Something went wrong, please try again");
+    }
   };
   };
+
   return (
   return (
     <>
     <>
       <InputRow
       <InputRow
@@ -128,23 +133,29 @@ export const SettingsForm: React.FC<{
 
 
     setButtonStatus("loading");
     setButtonStatus("loading");
 
 
-    // await api.connectGCRRegistry(
-    //   "<token>",
-    //   {
-    //     name: registryName,
-    //     gcp_integration_id: snap.StateHandler.connected_registry.credentials.id,
-    //     url: registryUrl,
-    //   },
-    //   {
-    //     id: project.id,
-    //   }
-    // );
-    nextFormStep({
-      settings: {
-        gcr_url: registryUrl,
-        registry_name: registryName,
-      },
-    });
+    try {
+      await api.connectGCRRegistry(
+        "<token>",
+        {
+          name: registryName,
+          gcp_integration_id:
+            snap.StateHandler.connected_registry.credentials.id,
+          url: registryUrl,
+        },
+        {
+          id: project.id,
+        }
+      );
+
+      nextFormStep({
+        settings: {
+          gcr_url: registryUrl,
+          registry_name: registryName,
+        },
+      });
+    } catch (error) {
+      setButtonStatus("Couldn't connect registry.");
+    }
   };
   };
   return (
   return (
     <>
     <>

+ 20 - 16
dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/_GCPProvisionerForm.tsx

@@ -71,23 +71,27 @@ export const CredentialsForm: React.FC<{
       return;
       return;
     }
     }
     setButtonStatus("loading");
     setButtonStatus("loading");
-    // const gcpIntegration = await api
-    //   .createGCPIntegration(
-    //     "<token>",
-    //     {
-    //       gcp_region: "",
-    //       gcp_key_data: serviceAccountKey,
-    //       gcp_project_id: projectId,
-    //     },
-    //     { project_id: project.id }
-    //   )
-    //   .then((res) => res.data);
+    try {
+      const gcpIntegration = await api
+        .createGCPIntegration(
+          "<token>",
+          {
+            gcp_region: region,
+            gcp_key_data: serviceAccountKey,
+            gcp_project_id: projectId,
+          },
+          { project_id: project.id }
+        )
+        .then((res) => res.data);
 
 
-    nextFormStep({
-      credentials: {
-        id: "gcpIntegration.id",
-      },
-    });
+      nextFormStep({
+        credentials: {
+          id: gcpIntegration?.id,
+        },
+      });
+    } catch (error) {
+      setButtonStatus("Something went wrong, please try again");
+    }
   };
   };
   return (
   return (
     <>
     <>