DescriptionPicker.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. constructor(props) {
  18. super(props);
  19. this.state = {};
  20. }
  21. render() {
  22. const { optionsWithDesc, onSelected, value, disabled, className } = this.props;
  23. return (
  24. <div className="permissions-picker">
  25. <Select
  26. value={value}
  27. valueKey="value"
  28. multi={false}
  29. clearable={false}
  30. labelKey="label"
  31. options={optionsWithDesc}
  32. onChange={onSelected}
  33. className={`width-7 gf-form-input gf-form-input--form-dropdown ${className || ''}`}
  34. optionComponent={DescriptionOption}
  35. placeholder="Choose"
  36. disabled={disabled}
  37. />
  38. </div>
  39. );
  40. }
  41. }
  42. export default DescriptionPicker;