DescriptionPicker.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React, { Component } from 'react';
  2. import Select from 'react-select';
  3. import DescriptionOption from './DescriptionOption';
  4. export interface Props {
  5. optionsWithDesc: OptionWithDescription[];
  6. onSelected: (permission) => void;
  7. value: number;
  8. disabled: boolean;
  9. className?: string;
  10. }
  11. export interface OptionWithDescription {
  12. value: any;
  13. label: string;
  14. description: string;
  15. }
  16. class DescriptionPicker extends Component<Props, any> {
  17. render() {
  18. const { optionsWithDesc, onSelected, value, disabled, className } = this.props;
  19. return (
  20. <div className="permissions-picker">
  21. <Select
  22. value={value}
  23. valueKey="value"
  24. multi={false}
  25. clearable={false}
  26. labelKey="label"
  27. options={optionsWithDesc}
  28. onChange={onSelected}
  29. className={`width-7 gf-form-input gf-form-input--form-dropdown ${className || ''}`}
  30. optionComponent={DescriptionOption}
  31. placeholder="Choose"
  32. disabled={disabled}
  33. />
  34. </div>
  35. );
  36. }
  37. }
  38. export default DescriptionPicker;