mirror of https://github.com/portainer/portainer
33 lines
676 B
TypeScript
33 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)}
|
|
/>
|
|
);
|
|
}
|