fix(ui): auto-populate OCI tenancy from provider UID in credentials form (#9074)

Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com>
This commit is contained in:
Sergio Garcia
2025-10-30 09:47:15 -04:00
committed by GitHub
parent f15ef0d16c
commit 98056b7c85
6 changed files with 17 additions and 3 deletions
@@ -30,8 +30,8 @@ export default async function AddCredentialsPage({ searchParams }: Props) {
const formData = new FormData();
formData.append("id", providerId);
const providerResponse = await getProvider(formData);
if (providerResponse.success && providerResponse.data) {
providerUid = providerResponse.data.attributes?.uid;
if (providerResponse?.data?.attributes?.uid) {
providerUid = providerResponse.data.attributes.uid;
}
}
@@ -66,6 +66,7 @@ export const BaseCredentialsForm = ({
} = useCredentialsForm({
providerType,
providerId,
providerUid,
onSubmit,
successNavigationUrl,
});
@@ -1,4 +1,4 @@
import { Control } from "react-hook-form";
import { Control, Controller } from "react-hook-form";
import { CustomInput, CustomTextarea } from "@/components/ui/custom";
import { ProviderCredentialFields } from "@/lib/provider-credentials/provider-credential-fields";
@@ -19,6 +19,12 @@ export const OracleCloudCredentialsForm = ({
Please provide your Oracle Cloud Infrastructure API key credentials.
</div>
</div>
{/* Hidden input for tenancy - auto-populated from provider UID */}
<Controller
control={control}
name={ProviderCredentialFields.OCI_TENANCY}
render={({ field }) => <input type="hidden" {...field} />}
/>
<CustomInput
control={control}
name={ProviderCredentialFields.OCI_USER}
+3
View File
@@ -17,6 +17,7 @@ import {
type UseCredentialsFormProps = {
providerType: ProviderType;
providerId: string;
providerUid?: string;
onSubmit: (formData: FormData) => Promise<any>;
successNavigationUrl: string;
};
@@ -24,6 +25,7 @@ type UseCredentialsFormProps = {
export const useCredentialsForm = ({
providerType,
providerId,
providerUid,
onSubmit,
successNavigationUrl,
}: UseCredentialsFormProps) => {
@@ -161,6 +163,7 @@ export const useCredentialsForm = ({
[ProviderCredentialFields.OCI_USER]: "",
[ProviderCredentialFields.OCI_FINGERPRINT]: "",
[ProviderCredentialFields.OCI_KEY_CONTENT]: "",
[ProviderCredentialFields.OCI_TENANCY]: providerUid || "",
[ProviderCredentialFields.OCI_REGION]: "",
[ProviderCredentialFields.OCI_PASS_PHRASE]: "",
};
+1
View File
@@ -252,6 +252,7 @@ export type OCICredentials = {
[ProviderCredentialFields.OCI_USER]: string;
[ProviderCredentialFields.OCI_FINGERPRINT]: string;
[ProviderCredentialFields.OCI_KEY_CONTENT]: string;
[ProviderCredentialFields.OCI_TENANCY]: string;
[ProviderCredentialFields.OCI_REGION]: string;
[ProviderCredentialFields.OCI_PASS_PHRASE]?: string;
[ProviderCredentialFields.PROVIDER_ID]: string;
+3
View File
@@ -207,6 +207,9 @@ export const addCredentialsFormSchema = (
[ProviderCredentialFields.OCI_KEY_CONTENT]: z
.string()
.min(1, "Private Key Content is required"),
[ProviderCredentialFields.OCI_TENANCY]: z
.string()
.min(1, "Tenancy OCID is required"),
[ProviderCredentialFields.OCI_REGION]: z
.string()
.min(1, "Region is required"),