mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Handle DescriptionPicker's initial state #13425
This commit is contained in:
parent
a42227cdff
commit
7689e9bbf2
@ -28,6 +28,7 @@ export default class DisabledPermissionListItem extends Component<Props, any> {
|
|||||||
onSelected={() => {}}
|
onSelected={() => {}}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
className={'gf-form-select-box__control--menu-right'}
|
className={'gf-form-select-box__control--menu-right'}
|
||||||
|
value={item.permission}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -79,6 +79,7 @@ export default class PermissionsListItem extends PureComponent<Props> {
|
|||||||
onSelected={this.onPermissionChanged}
|
onSelected={this.onPermissionChanged}
|
||||||
disabled={item.inherited}
|
disabled={item.inherited}
|
||||||
className={'gf-form-select-box__control--menu-right'}
|
className={'gf-form-select-box__control--menu-right'}
|
||||||
|
value={item.permission}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -16,15 +16,19 @@ export interface Props {
|
|||||||
onSelected: (permission) => void;
|
onSelected: (permission) => void;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getSelectedOption = (optionsWithDesc, value) => optionsWithDesc.find(option => option.value === value);
|
||||||
|
|
||||||
class DescriptionPicker extends Component<Props, any> {
|
class DescriptionPicker extends Component<Props, any> {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { optionsWithDesc, onSelected, disabled, className } = this.props;
|
const { optionsWithDesc, onSelected, disabled, className, value } = this.props;
|
||||||
|
const selectedOption = getSelectedOption(optionsWithDesc, value);
|
||||||
return (
|
return (
|
||||||
<div className="permissions-picker">
|
<div className="permissions-picker">
|
||||||
<Select
|
<Select
|
||||||
@ -42,6 +46,7 @@ class DescriptionPicker extends Component<Props, any> {
|
|||||||
onChange={onSelected}
|
onChange={onSelected}
|
||||||
getOptionValue={i => i.value}
|
getOptionValue={i => i.value}
|
||||||
getOptionLabel={i => i.label}
|
getOptionLabel={i => i.label}
|
||||||
|
value={selectedOption}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user