Using IAM Role
diff --git a/ui/components/providers/workflow/forms/select-via-aws/index.ts b/ui/components/providers/workflow/forms/select-via-aws/index.ts
new file mode 100644
index 0000000000..8dd9822258
--- /dev/null
+++ b/ui/components/providers/workflow/forms/select-via-aws/index.ts
@@ -0,0 +1 @@
+export * from "./select-via-aws";
diff --git a/ui/components/providers/workflow/forms/select-via-aws/select-via-aws.tsx b/ui/components/providers/workflow/forms/select-via-aws/select-via-aws.tsx
new file mode 100644
index 0000000000..59197bb40e
--- /dev/null
+++ b/ui/components/providers/workflow/forms/select-via-aws/select-via-aws.tsx
@@ -0,0 +1,38 @@
+"use client";
+
+import { useRouter } from "next/navigation";
+import { useForm } from "react-hook-form";
+
+import { Form } from "@/components/ui/form";
+
+import { RadioGroupAWSViaCredentialsForm } from "../radio-group-aws-via-credentials-form";
+
+interface SelectViaAWSProps {
+ initialVia?: string;
+}
+
+export const SelectViaAWS = ({ initialVia }: SelectViaAWSProps) => {
+ const router = useRouter();
+ const form = useForm({
+ defaultValues: {
+ awsCredentialsType: initialVia || "",
+ },
+ });
+
+ const handleSelectionChange = (value: string) => {
+ const url = new URL(window.location.href);
+ url.searchParams.set("via", value);
+ router.push(url.toString());
+ };
+
+ return (
+
+ );
+};
diff --git a/ui/components/providers/workflow/forms/via-credentials-form.tsx b/ui/components/providers/workflow/forms/via-credentials-form.tsx
index 3ecb11da41..6c0bd0fe37 100644
--- a/ui/components/providers/workflow/forms/via-credentials-form.tsx
+++ b/ui/components/providers/workflow/forms/via-credentials-form.tsx
@@ -1,8 +1,8 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
-import { ChevronRightIcon } from "lucide-react";
-import { useRouter } from "next/navigation";
+import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
+import { useRouter, useSearchParams } from "next/navigation";
import { Control, useForm } from "react-hook-form";
import * as z from "zod";
@@ -46,6 +46,15 @@ export const ViaCredentialsForm = ({
const router = useRouter();
const { toast } = useToast();
+ const searchParamsObj = useSearchParams();
+
+ // Handler for back button
+ const handleBackStep = () => {
+ const currentParams = new URLSearchParams(window.location.search);
+ currentParams.delete("via");
+ router.push(`?${currentParams.toString()}`);
+ };
+
const providerType = searchParams.type;
const providerId = searchParams.id;
const formSchema = addCredentialsFormSchema(providerType);
@@ -199,6 +208,21 @@ export const ViaCredentialsForm = ({
)}
+ {searchParamsObj.get("via") === "credentials" && (
+
}
+ isDisabled={isLoading}
+ >
+
Back
+
+ )}
{
+ const currentParams = new URLSearchParams(window.location.search);
+ currentParams.delete("via");
+ router.push(`?${currentParams.toString()}`);
+ };
+
const providerType = searchParams.type;
const providerId = searchParams.id;
@@ -54,7 +63,6 @@ export const ViaRoleForm = ({
const isLoading = form.formState.isSubmitting;
const onSubmitClient = async (values: FormSchemaType) => {
- console.log("via ROLE form", values);
const formData = new FormData();
Object.entries(values).forEach(
@@ -106,6 +114,21 @@ export const ViaRoleForm = ({
)}
+ {searchParamsObj.get("via") === "role" && (
+ }
+ isDisabled={isLoading}
+ >
+ Back
+
+ )}
}
+ endContent={!isLoading && }
>
- {isLoading ? <>Loading> : Save}
+ {isLoading ? <>Loading> : Next}
diff --git a/ui/types/formSchemas.ts b/ui/types/formSchemas.ts
index 4238df3ef2..cc0221add7 100644
--- a/ui/types/formSchemas.ts
+++ b/ui/types/formSchemas.ts
@@ -31,6 +31,12 @@ export const scheduleScanFormSchema = () =>
scheduleDate: z.string(),
});
+export const awsCredentialsTypeSchema = z.object({
+ awsCredentialsType: z.string().min(1, {
+ message: "Please select the type of credentials you want to use",
+ }),
+});
+
export const addProviderFormSchema = z
.object({
providerType: z.enum(["aws", "azure", "gcp", "kubernetes"], {
@@ -43,9 +49,6 @@ export const addProviderFormSchema = z
providerType: z.literal("aws"),
providerAlias: z.string(),
providerUid: z.string(),
- awsCredentialsType: z.string().min(1, {
- message: "Please select the type of credentials you want to use",
- }),
}),
z.object({
providerType: z.literal("azure"),