Skip to content

Commit bec4617

Browse files
fix(providers): update the label and placeholder based on the cloud provider (#6582)
Co-authored-by: Pablo Lara <[email protected]>
1 parent 94916f8 commit bec4617

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

ui/components/providers/workflow/forms/connect-account-form.tsx

+41-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,37 @@ import { RadioGroupProvider } from "../../radio-group-provider";
2222

2323
export type FormValues = z.infer<typeof addProviderFormSchema>;
2424

25+
// Helper function for labels and placeholders
26+
const getProviderFieldDetails = (providerType?: string) => {
27+
switch (providerType) {
28+
case "aws":
29+
return {
30+
label: "Account ID",
31+
placeholder: "123456...",
32+
};
33+
case "gcp":
34+
return {
35+
label: "Project ID",
36+
placeholder: "project_id...",
37+
};
38+
case "azure":
39+
return {
40+
label: "Subscription ID",
41+
placeholder: "fc94207a-d396-4a14-a7fd-12a...",
42+
};
43+
case "kubernetes":
44+
return {
45+
label: "Kubernetes Context",
46+
placeholder: "context_name....",
47+
};
48+
default:
49+
return {
50+
label: "Provider UID",
51+
placeholder: "Enter the provider UID",
52+
};
53+
}
54+
};
55+
2556
export const ConnectAccountForm = () => {
2657
const { toast } = useToast();
2758
const [prevStep, setPrevStep] = useState(1);
@@ -39,6 +70,8 @@ export const ConnectAccountForm = () => {
3970
});
4071

4172
const providerType = form.watch("providerType");
73+
const providerFieldDetails = getProviderFieldDetails(providerType);
74+
4275
const isLoading = form.formState.isSubmitting;
4376

4477
const onSubmitClient = async (values: FormValues) => {
@@ -107,7 +140,12 @@ export const ConnectAccountForm = () => {
107140
}
108141
};
109142

110-
const handleBackStep = () => setPrevStep((prev) => prev - 1);
143+
const handleBackStep = () => {
144+
setPrevStep((prev) => prev - 1);
145+
// Reset the providerUid and providerAlias fields when going back
146+
form.setValue("providerUid", "");
147+
form.setValue("providerAlias", "");
148+
};
111149

112150
useEffect(() => {
113151
if (providerType) {
@@ -144,9 +182,9 @@ export const ConnectAccountForm = () => {
144182
control={form.control}
145183
name="providerUid"
146184
type="text"
147-
label="Provider UID"
185+
label={providerFieldDetails.label}
148186
labelPlacement="inside"
149-
placeholder="Enter the provider UID"
187+
placeholder={providerFieldDetails.placeholder}
150188
variant="bordered"
151189
isRequired
152190
isInvalid={!!form.formState.errors.providerUid}

0 commit comments

Comments
 (0)