releasesDropdown.tsx 798 B

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