2018-01-29 13:56:12 +01:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import Select from 'react-select';
|
|
|
|
|
import DescriptionOption from './DescriptionOption';
|
|
|
|
|
|
|
|
|
|
export interface IProps {
|
|
|
|
|
optionsWithDesc: OptionWithDescription[];
|
|
|
|
|
handlePicked: (permission) => void;
|
|
|
|
|
value: number;
|
|
|
|
|
disabled: boolean;
|
2018-01-29 14:30:01 +01:00
|
|
|
className?: string;
|
2018-01-29 13:56:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface OptionWithDescription {
|
|
|
|
|
value: any;
|
|
|
|
|
label: string;
|
|
|
|
|
description: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DescriptionPicker extends Component<IProps, any> {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2018-01-29 14:30:01 +01:00
|
|
|
const { optionsWithDesc, handlePicked, value, disabled, className } = this.props;
|
2018-01-29 13:56:12 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="permissions-picker">
|
|
|
|
|
<Select
|
|
|
|
|
value={value}
|
|
|
|
|
valueKey="value"
|
|
|
|
|
multi={false}
|
|
|
|
|
clearable={false}
|
|
|
|
|
labelKey="label"
|
|
|
|
|
options={optionsWithDesc}
|
|
|
|
|
onChange={handlePicked}
|
2018-01-29 14:30:01 +01:00
|
|
|
className={`width-7 gf-form-input gf-form-input--form-dropdown ${className || ''}`}
|
2018-01-29 13:56:12 +01:00
|
|
|
optionComponent={DescriptionOption}
|
|
|
|
|
placeholder="Choose"
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DescriptionPicker;
|