mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-05-06 08:47:18 +00:00
d23c2f3b53
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
101 lines
3.0 KiB
TypeScript
101 lines
3.0 KiB
TypeScript
"use client";
|
|
|
|
import { Control, FieldPath, FieldValues } from "react-hook-form";
|
|
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/components/shadcn";
|
|
import { EntityInfo } from "@/components/ui/entities";
|
|
import { FormControl, FormField, FormMessage } from "@/components/ui/form";
|
|
|
|
interface SelectScanProviderProps<
|
|
TFieldValues extends FieldValues = FieldValues,
|
|
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
> {
|
|
providers: {
|
|
providerId: string;
|
|
alias: string;
|
|
providerType: string;
|
|
uid: string;
|
|
connected: boolean;
|
|
}[];
|
|
control: Control<TFieldValues>;
|
|
name: TName;
|
|
}
|
|
|
|
export const SelectScanProvider = <
|
|
TFieldValues extends FieldValues = FieldValues,
|
|
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
>({
|
|
providers,
|
|
control,
|
|
name,
|
|
}: SelectScanProviderProps<TFieldValues, TName>) => {
|
|
return (
|
|
<FormField
|
|
control={control}
|
|
name={name}
|
|
render={({ field }) => {
|
|
const selectedItem = providers.find(
|
|
(item) => item.providerId === field.value,
|
|
);
|
|
|
|
return (
|
|
<div className="flex flex-col gap-2">
|
|
<span className="text-text-neutral-primary text-sm font-medium">
|
|
Select a provider to launch a scan
|
|
</span>
|
|
<FormControl>
|
|
<Select value={field.value} onValueChange={field.onChange}>
|
|
<SelectTrigger>
|
|
<SelectValue placeholder="Choose a provider">
|
|
{selectedItem ? (
|
|
<EntityInfo
|
|
cloudProvider={
|
|
selectedItem.providerType as
|
|
| "aws"
|
|
| "azure"
|
|
| "gcp"
|
|
| "kubernetes"
|
|
}
|
|
entityAlias={selectedItem.alias}
|
|
entityId={selectedItem.uid}
|
|
showCopyAction={false}
|
|
/>
|
|
) : (
|
|
"Choose a provider"
|
|
)}
|
|
</SelectValue>
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{providers.map((item) => (
|
|
<SelectItem key={item.providerId} value={item.providerId}>
|
|
<EntityInfo
|
|
cloudProvider={
|
|
item.providerType as
|
|
| "aws"
|
|
| "azure"
|
|
| "gcp"
|
|
| "kubernetes"
|
|
}
|
|
entityAlias={item.alias}
|
|
entityId={item.uid}
|
|
showCopyAction={false}
|
|
/>
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</FormControl>
|
|
<FormMessage className="text-sm text-red-600 dark:text-red-400" />
|
|
</div>
|
|
);
|
|
}}
|
|
/>
|
|
);
|
|
};
|