mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
For the permissions picker, pass in an extra class to decide if the description should be aligned left or right.
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
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;
|
|
className?: string;
|
|
}
|
|
|
|
export interface OptionWithDescription {
|
|
value: any;
|
|
label: string;
|
|
description: string;
|
|
}
|
|
|
|
class DescriptionPicker extends Component<IProps, any> {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {};
|
|
}
|
|
|
|
render() {
|
|
const { optionsWithDesc, handlePicked, value, disabled, className } = this.props;
|
|
|
|
return (
|
|
<div className="permissions-picker">
|
|
<Select
|
|
value={value}
|
|
valueKey="value"
|
|
multi={false}
|
|
clearable={false}
|
|
labelKey="label"
|
|
options={optionsWithDesc}
|
|
onChange={handlePicked}
|
|
className={`width-7 gf-form-input gf-form-input--form-dropdown ${className || ''}`}
|
|
optionComponent={DescriptionOption}
|
|
placeholder="Choose"
|
|
disabled={disabled}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default DescriptionPicker;
|