2022-01-07 08:59:14 -08:00
|
|
|
import React from 'react';
|
2022-04-22 14:33:13 +01:00
|
|
|
|
2020-04-01 17:36:08 +02:00
|
|
|
import { OrgRole } from '@grafana/data';
|
2020-04-21 10:42:57 +02:00
|
|
|
import { Select } from '@grafana/ui';
|
2020-04-01 17:36:08 +02:00
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
value: OrgRole;
|
2021-04-22 13:19:41 +03:00
|
|
|
disabled?: boolean;
|
2021-09-22 21:23:54 +01:00
|
|
|
'aria-label'?: string;
|
2021-11-02 15:27:07 +00:00
|
|
|
inputId?: string;
|
2020-04-01 17:36:08 +02:00
|
|
|
onChange: (role: OrgRole) => void;
|
2021-11-05 14:45:00 +00:00
|
|
|
autoFocus?: boolean;
|
2022-06-01 10:35:16 +03:00
|
|
|
width?: number | 'auto';
|
2020-04-01 17:36:08 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-20 07:59:48 +01:00
|
|
|
const options = Object.keys(OrgRole).map((key) => ({ label: key, value: key }));
|
2020-04-01 17:36:08 +02:00
|
|
|
|
2022-01-07 08:59:14 -08:00
|
|
|
export function OrgRolePicker({ value, onChange, 'aria-label': ariaLabel, inputId, autoFocus, ...restProps }: Props) {
|
2021-11-05 14:45:00 +00:00
|
|
|
return (
|
|
|
|
|
<Select
|
|
|
|
|
inputId={inputId}
|
|
|
|
|
value={value}
|
|
|
|
|
options={options}
|
|
|
|
|
onChange={(val) => onChange(val.value as OrgRole)}
|
|
|
|
|
placeholder="Choose role..."
|
|
|
|
|
aria-label={ariaLabel}
|
|
|
|
|
autoFocus={autoFocus}
|
|
|
|
|
{...restProps}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2022-01-07 08:59:14 -08:00
|
|
|
}
|