LdapUserGroups.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React, { FC } from 'react';
  2. import { Tooltip, Icon } from '@grafana/ui';
  3. import { LdapRole } from 'app/types';
  4. interface Props {
  5. groups: LdapRole[];
  6. showAttributeMapping?: boolean;
  7. }
  8. export const LdapUserGroups: FC<Props> = ({ groups, showAttributeMapping }) => {
  9. const items = showAttributeMapping ? groups : groups.filter((item) => item.orgRole);
  10. return (
  11. <div className="gf-form-group">
  12. <div className="gf-form">
  13. <table className="filter-table form-inline">
  14. <thead>
  15. <tr>
  16. {showAttributeMapping && <th>LDAP Group</th>}
  17. <th>
  18. Organization
  19. <Tooltip placement="top" content="Only the first match for an Organization will be used" theme={'info'}>
  20. <span className="gf-form-help-icon">
  21. <Icon name="info-circle" />
  22. </span>
  23. </Tooltip>
  24. </th>
  25. <th>Role</th>
  26. </tr>
  27. </thead>
  28. <tbody>
  29. {items.map((group, index) => {
  30. return (
  31. <tr key={`${group.orgId}-${index}`}>
  32. {showAttributeMapping && <td>{group.groupDN}</td>}
  33. {group.orgName && group.orgRole ? <td>{group.orgName}</td> : <td />}
  34. {group.orgRole ? (
  35. <td>{group.orgRole}</td>
  36. ) : (
  37. <td>
  38. <span className="text-warning">
  39. No match
  40. <Tooltip placement="top" content="No matching groups found" theme={'info'}>
  41. <span className="gf-form-help-icon">
  42. <Icon name="info-circle" />
  43. </span>
  44. </Tooltip>
  45. </span>
  46. </td>
  47. )}
  48. </tr>
  49. );
  50. })}
  51. </tbody>
  52. </table>
  53. </div>
  54. </div>
  55. );
  56. };