Procházet zdrojové kódy

Connect registry working

jnfrati před 4 roky
rodič
revize
673c9c6d7e

+ 1 - 1
dashboard/src/main/home/onboarding/steps/ConnectRegistry/ConnectRegistryWrapper.tsx

@@ -7,7 +7,7 @@ const ConnectRegistryWrapper = () => {
   const snap = useSnapshot(OFState);
   return (
     <ConnectRegistry
-      provider={snap.StateHandler.connected_registry.provider}
+      provider={snap.StateHandler.connected_registry?.provider}
       project={snap.StateHandler.project}
       onSelectProvider={(provider) =>
         OFState.actions.nextStep("continue", provider)

+ 22 - 23
dashboard/src/main/home/onboarding/steps/ConnectRegistry/forms/_AWSRegistryForm.tsx

@@ -4,9 +4,8 @@ import SaveButton from "components/SaveButton";
 import { AWSRegistryConfig } from "main/home/onboarding/types";
 import React, { useState } from "react";
 import api from "shared/api";
-import { Context } from "shared/Context";
 import { useSnapshot } from "valtio";
-import { State } from "../ConnectRegistryState";
+import { OFState } from "../../../state/index";
 
 const regionOptions = [
   { value: "us-east-1", label: "US East (N. Virginia) us-east-1" },
@@ -66,21 +65,21 @@ export const CredentialsForm: React.FC<{
       return;
     }
 
-    const res = await api.createAWSIntegration(
-      "token",
-      {
-        aws_region: awsRegion,
-        aws_access_key_id: accessId,
-        aws_secret_access_key: secretKey,
-      },
-      {
-        id: project.id,
-      }
-    );
+    // 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,
+        id: "some_id",
       },
     });
   };
@@ -136,7 +135,7 @@ export const SettingsForm: React.FC<{
   nextFormStep: (data: Partial<AWSRegistryConfig>) => void;
   project: any;
 }> = ({ nextFormStep, project }) => {
-  const snap = useSnapshot(State);
+  const snap = useSnapshot(OFState);
   const [registryName, setRegistryName] = useState("");
 
   const [buttonStatus, setButtonStatus] = useState("");
@@ -160,14 +159,14 @@ export const SettingsForm: React.FC<{
       return;
     }
 
-    await api.connectECRRegistry(
-      "<token>",
-      {
-        name: registryName,
-        aws_integration_id: snap.config.credentials.id,
-      },
-      { id: project.id }
-    );
+    // await api.connectECRRegistry(
+    //   "<token>",
+    //   {
+    //     name: registryName,
+    //     aws_integration_id: snap.StateHandler.connected_registry.credentials.id,
+    //   },
+    //   { id: project.id }
+    // );
 
     nextFormStep({
       settings: {

+ 3 - 3
dashboard/src/main/home/onboarding/steps/ConnectRegistry/forms/_DORegistryForm.tsx

@@ -1,12 +1,12 @@
 import Helper from "components/form-components/Helper";
 import InputRow from "components/form-components/InputRow";
 import SaveButton from "components/SaveButton";
+import { OFState } from "main/home/onboarding/state";
 import { DORegistryConfig } from "main/home/onboarding/types";
 import React, { useEffect, useState } from "react";
 import api from "shared/api";
 import styled from "styled-components";
 import { useSnapshot } from "valtio";
-import { State } from "../ConnectRegistryState";
 
 /**
  * This will redirect to DO, and we should pass the redirection URI to be /onboarding/registry?provider=do
@@ -55,14 +55,14 @@ export const SettingsForm: React.FC<{
   const [registryUrl, setRegistryUrl] = useState("basic");
   const [registryName, setRegistryName] = useState("");
   const [buttonStatus] = useState("");
-  const snap = useSnapshot(State);
+  const snap = useSnapshot(OFState);
 
   const submit = async () => {
     await api.connectDORegistry(
       "<token>",
       {
         name: registryName,
-        do_integration_id: snap.config.credentials.id,
+        do_integration_id: snap.StateHandler.connected_registry.credentials.id,
         url: registryUrl,
       },
       { project_id: project.id }

+ 25 - 24
dashboard/src/main/home/onboarding/steps/ConnectRegistry/forms/_GCPRegistryForm.tsx

@@ -2,6 +2,7 @@ import Helper from "components/form-components/Helper";
 import InputRow from "components/form-components/InputRow";
 import UploadArea from "components/form-components/UploadArea";
 import SaveButton from "components/SaveButton";
+import { OFState } from "main/home/onboarding/state";
 import { GCPRegistryConfig } from "main/home/onboarding/types";
 import React, { useState } from "react";
 import api from "shared/api";
@@ -39,21 +40,21 @@ export const CredentialsForm: React.FC<{
       return;
     }
     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);
+    // 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,
+        id: "some_Id",
       },
     });
   };
@@ -100,7 +101,7 @@ export const SettingsForm: React.FC<{
   const [registryName, setRegistryName] = useState("");
   const [registryUrl, setRegistryUrl] = useState("");
   const [buttonStatus, setButtonStatus] = useState("");
-  const snap = useSnapshot(State);
+  const snap = useSnapshot(OFState);
 
   const validate = () => {
     if (!registryName) {
@@ -128,17 +129,17 @@ export const SettingsForm: React.FC<{
 
     setButtonStatus("loading");
 
-    await api.connectGCRRegistry(
-      "<token>",
-      {
-        name: registryName,
-        gcp_integration_id: snap.config.credentials.id,
-        url: registryUrl,
-      },
-      {
-        id: project.id,
-      }
-    );
+    // 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,