2026-04-09 15:22:14 +02:00
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
import { Select } from '@cameleer/design-system';
|
2026-04-04 15:42:26 +02:00
|
|
|
import styles from './EnvironmentSelector.module.css';
|
|
|
|
|
|
|
|
|
|
interface EnvironmentSelectorProps {
|
|
|
|
|
environments: string[];
|
|
|
|
|
value: string | undefined;
|
|
|
|
|
onChange: (env: string | undefined) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function EnvironmentSelector({ environments, value, onChange }: EnvironmentSelectorProps) {
|
|
|
|
|
if (environments.length === 0) return null;
|
|
|
|
|
|
2026-04-09 15:22:14 +02:00
|
|
|
const options = useMemo(
|
|
|
|
|
() => [
|
|
|
|
|
{ value: '', label: 'All Envs' },
|
|
|
|
|
...environments.map((env) => ({ value: env, label: env })),
|
|
|
|
|
],
|
|
|
|
|
[environments],
|
|
|
|
|
);
|
|
|
|
|
|
2026-04-04 15:42:26 +02:00
|
|
|
return (
|
2026-04-09 15:22:14 +02:00
|
|
|
<Select
|
2026-04-04 15:42:26 +02:00
|
|
|
className={styles.select}
|
2026-04-09 15:22:14 +02:00
|
|
|
options={options}
|
2026-04-04 15:42:26 +02:00
|
|
|
value={value ?? ''}
|
|
|
|
|
onChange={(e) => onChange(e.target.value || undefined)}
|
2026-04-09 15:22:14 +02:00
|
|
|
/>
|
2026-04-04 15:42:26 +02:00
|
|
|
);
|
|
|
|
|
}
|