| 28 | } |
| 29 | |
| 30 | const DatasourceSelect = ({ value, onChange, allowTypes = [], variant = "unstyled",size="md" }: Props) => { |
| 31 | const datasources = useStore($datasources) |
| 32 | |
| 33 | const options = [] |
| 34 | datasources.forEach((ds) => { |
| 35 | if (allowTypes.length > 0 && !allowTypes.includes(ds.type)) { |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | options.push({ |
| 40 | label: ds.name, |
| 41 | value: ds.id, |
| 42 | icon: <Image width="30px" height="30px" mr="2" src={`/plugins/datasource/${ds.type}.svg`} /> |
| 43 | }) |
| 44 | }) |
| 45 | |
| 46 | |
| 47 | return ( |
| 48 | <InputSelect width="100%" isClearable value={value?.toString()} label={datasources.find(ds => ds.id == value)?.name} placeholder={"select datasource, support variable"} size="md" options={options} onChange={onChange} enableInput /> |
| 49 | // <ChakraSelect value={{ value: value, label: datasources.find(ds => ds.id == value)?.name }} placeholder="select datasource" variant={variant} size={size} options={options} |
| 50 | // onChange={onChange} |
| 51 | // components={customComponents} |
| 52 | // /> |
| 53 | ) |
| 54 | } |
| 55 | |
| 56 | export default DatasourceSelect |
| 57 | |