LdapUserGroups.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, { FC } from 'react';
  2. import { Tooltip } 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>Organisation</th>
  18. <th>Role</th>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. {items.map((group, index) => {
  23. return (
  24. <tr key={`${group.orgId}-${index}`}>
  25. {showAttributeMapping && (
  26. <>
  27. <td>{group.groupDN}</td>
  28. {!group.orgRole && (
  29. <>
  30. <td />
  31. <td>
  32. <span className="text-warning">
  33. No match
  34. <Tooltip placement="top" content="No matching groups found" theme={'info'}>
  35. <span className="gf-form-help-icon">
  36. <i className="fa fa-info-circle" />
  37. </span>
  38. </Tooltip>
  39. </span>
  40. </td>
  41. </>
  42. )}
  43. </>
  44. )}
  45. {group.orgName && (
  46. <>
  47. <td>{group.orgName}</td>
  48. <td>{group.orgRole}</td>
  49. </>
  50. )}
  51. </tr>
  52. );
  53. })}
  54. </tbody>
  55. </table>
  56. </div>
  57. </div>
  58. );
  59. };