releasesDropdown.tsx 770 B

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