releasesDropdown.tsx 717 B

123456789101112131415161718192021222324252627282930
  1. import {CompactSelect, SelectOption} from 'sentry/components/compactSelect';
  2. type Props = {
  3. label: string;
  4. onSelect: (key: string) => void;
  5. options: Record<string, Omit<SelectOption<string>, 'value'>>;
  6. selected: string;
  7. };
  8. function ReleasesDropdown({label: prefix, options, selected, onSelect}: Props) {
  9. const mappedOptions = Object.entries(options).map(
  10. ([key, {label, tooltip, disabled}]) => ({
  11. value: key,
  12. label,
  13. tooltip,
  14. disabled,
  15. })
  16. );
  17. return (
  18. <CompactSelect
  19. options={mappedOptions}
  20. onChange={opt => onSelect(opt.value)}
  21. value={selected}
  22. triggerProps={{prefix, style: {width: '100%'}}}
  23. />
  24. );
  25. }
  26. export default ReleasesDropdown;