From 5e0463abcec69d8277e7b6cc8bbdbeabd3e788db Mon Sep 17 00:00:00 2001 From: pedrooot Date: Thu, 11 Dec 2025 12:03:55 +0100 Subject: [PATCH] feat(ui): add search bar inside Connect a Cloud Provider --- .../providers/radio-group-provider.tsx | 189 ++++++++++++------ 1 file changed, 123 insertions(+), 66 deletions(-) diff --git a/ui/components/providers/radio-group-provider.tsx b/ui/components/providers/radio-group-provider.tsx index 6bd4adacff..9b85023404 100644 --- a/ui/components/providers/radio-group-provider.tsx +++ b/ui/components/providers/radio-group-provider.tsx @@ -1,7 +1,9 @@ "use client"; +import { Input } from "@heroui/input"; import { RadioGroup } from "@heroui/radio"; -import { FC } from "react"; +import { SearchIcon, XCircle } from "lucide-react"; +import { FC, useState } from "react"; import { Control, Controller } from "react-hook-form"; import { z } from "zod"; @@ -22,6 +24,59 @@ import { import { CustomRadio } from "../ui/custom"; import { FormMessage } from "../ui/form"; +const PROVIDERS = [ + { + value: "aws", + label: "Amazon Web Services", + badge: AWSProviderBadge, + }, + { + value: "gcp", + label: "Google Cloud Platform", + badge: GCPProviderBadge, + }, + { + value: "azure", + label: "Microsoft Azure", + badge: AzureProviderBadge, + }, + { + value: "m365", + label: "Microsoft 365", + badge: M365ProviderBadge, + }, + { + value: "mongodbatlas", + label: "MongoDB Atlas", + badge: MongoDBAtlasProviderBadge, + }, + { + value: "kubernetes", + label: "Kubernetes", + badge: KS8ProviderBadge, + }, + { + value: "github", + label: "GitHub", + badge: GitHubProviderBadge, + }, + { + value: "iac", + label: "Infrastructure as Code", + badge: IacProviderBadge, + }, + { + value: "oraclecloud", + label: "Oracle Cloud Infrastructure", + badge: OracleCloudProviderBadge, + }, + { + value: "alibabacloud", + label: "Alibaba Cloud", + badge: AlibabaCloudProviderBadge, + }, +] as const; + interface RadioGroupProviderProps { control: Control>; isInvalid: boolean; @@ -33,12 +88,55 @@ export const RadioGroupProvider: FC = ({ isInvalid, errorMessage, }) => { + const [searchTerm, setSearchTerm] = useState(""); + + const lowerSearch = searchTerm.trim().toLowerCase(); + const filteredProviders = lowerSearch + ? PROVIDERS.filter( + (provider) => + provider.label.toLowerCase().includes(lowerSearch) || + provider.value.toLowerCase().includes(lowerSearch), + ) + : PROVIDERS; + return ( ( - <> +
+ setSearchTerm(e.target.value)} + startContent={ + + } + endContent={ + searchTerm && ( + + ) + } + classNames={{ + base: "w-full", + input: + "text-bg-button-secondary placeholder:text-bg-button-secondary text-sm", + inputWrapper: + "!border-border-input-primary !bg-bg-input-primary dark:!bg-input/30 dark:hover:!bg-input/50 hover:!bg-bg-neutral-secondary !border !rounded-lg !shadow-xs !transition-[color,box-shadow] focus-within:!border-border-input-primary-press focus-within:!ring-1 focus-within:!ring-border-input-primary-press focus-within:!ring-offset-1 !h-10 !px-4 !py-3 !outline-none", + }} + /> + = ({ value={field.value || ""} >
- -
- - Amazon Web Services -
-
- -
- - Google Cloud Platform -
-
- -
- - Microsoft Azure -
-
- -
- - Microsoft 365 -
-
- -
- - MongoDB Atlas -
-
- -
- - Kubernetes -
-
- -
- - GitHub -
-
- -
- - Infrastructure as Code -
-
- -
- - Oracle Cloud Infrastructure -
-
- -
- - Alibaba Cloud -
-
+ {filteredProviders.length > 0 ? ( + filteredProviders.map((provider) => { + const BadgeComponent = provider.badge; + return ( + +
+ + {provider.label} +
+
+ ); + }) + ) : ( +

+ No providers found matching "{searchTerm}" +

+ )}
+ {errorMessage && ( {errorMessage} )} - +
)} /> );