1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-30 10:49:40 +02:00
portainer/app/react/docker/app-templates/TemplateListDropdown/TemplateListDropdown.tsx

32 lines
676 B
TypeScript

import { Select } from '@@/form-components/ReactSelect';
interface Filter {
label?: string;
}
interface Props {
options: string[];
onChange: (value: string | null) => void;
placeholder?: string;
value: string;
}
export function TemplateListDropdown({
options,
onChange,
placeholder,
value,
}: Props) {
const filterOptions: Filter[] = options.map((value) => ({ label: value }));
const filterValue: Filter | null = value ? { label: value } : null;
return (
<Select
placeholder={placeholder}
options={filterOptions}
value={filterValue}
isClearable
onChange={(option) => onChange(option?.label ?? null)}
/>
);
}