Files
grafana/public/app/features/admin/OrgRolePicker.tsx
T

32 lines
777 B
TypeScript
Raw Normal View History

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;
disabled?: boolean;
'aria-label'?: string;
inputId?: string;
2020-04-01 17:36:08 +02:00
onChange: (role: OrgRole) => void;
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
export function OrgRolePicker({ value, onChange, 'aria-label': ariaLabel, inputId, autoFocus, ...restProps }: Props) {
return (
<Select
inputId={inputId}
value={value}
options={options}
onChange={(val) => onChange(val.value as OrgRole)}
placeholder="Choose role..."
aria-label={ariaLabel}
autoFocus={autoFocus}
{...restProps}
/>
);
}