OrgRolePicker.tsx 750 B

123456789101112131415161718192021222324252627282930
  1. import React from 'react';
  2. import { OrgRole } from '@grafana/data';
  3. import { Select } from '@grafana/ui';
  4. interface Props {
  5. value: OrgRole;
  6. disabled?: boolean;
  7. 'aria-label'?: string;
  8. inputId?: string;
  9. onChange: (role: OrgRole) => void;
  10. autoFocus?: boolean;
  11. }
  12. const options = Object.keys(OrgRole).map((key) => ({ label: key, value: key }));
  13. export function OrgRolePicker({ value, onChange, 'aria-label': ariaLabel, inputId, autoFocus, ...restProps }: Props) {
  14. return (
  15. <Select
  16. inputId={inputId}
  17. value={value}
  18. options={options}
  19. onChange={(val) => onChange(val.value as OrgRole)}
  20. placeholder="Choose role..."
  21. aria-label={ariaLabel}
  22. autoFocus={autoFocus}
  23. {...restProps}
  24. />
  25. );
  26. }