Skip to content

Commit

Permalink
🐛 Add provider to custom target form
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Nov 6, 2023
1 parent aae9115 commit ed54045
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface CustomTargetFormValues {
branch?: string;
rootPath?: string;
associatedCredentials?: string;
provider?: string;
}

export const CustomTargetForm: React.FC<CustomTargetFormProps> = ({
Expand Down Expand Up @@ -88,6 +89,17 @@ export const CustomTargetForm: React.FC<CustomTargetFormProps> = ({
},
];

const providerOptions: OptionWithValue<string>[] = [
{
value: "Java",
toString: () => `Java`,
},
{
value: "Go",
toString: () => `Go`,
},
];

const { identities } = useFetchIdentities();

const sourceIdentityOptions = identities
Expand All @@ -105,6 +117,7 @@ export const CustomTargetForm: React.FC<CustomTargetFormProps> = ({
.object()
.shape({
id: yup.number().defined(),
provider: yup.string().defined(),
name: yup
.string()
.trim()
Expand Down Expand Up @@ -298,6 +311,7 @@ export const CustomTargetForm: React.FC<CustomTargetFormProps> = ({
},
}),
},
provider: formValues.provider || "Java",
};

if (target) {
Expand Down Expand Up @@ -391,6 +405,28 @@ export const CustomTargetForm: React.FC<CustomTargetFormProps> = ({

return (
<Form onSubmit={handleSubmit(onSubmit)}>
<HookFormPFGroupController
control={control}
name="provider"
label="Provider "
fieldId="provider-select"
isRequired
renderInput={({ field: { value, name, onChange } }) => (
<SimpleSelect
id="provider-select"
toggleId="provider-select-toggle"
toggleAriaLabel="Provider select dropdown toggle"
aria-label={name}
value={value ? toOptionLike(value, providerOptions) : undefined}
options={providerOptions}
onChange={(selection) => {
const selectionValue = selection as OptionWithValue<string>;
onChange(selectionValue.value);
}}
/>
)}
/>

<HookFormPFTextInput
control={control}
name="name"
Expand Down

0 comments on commit ed54045

Please sign in to comment.