LdapUserGroups.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. const roleColumnClass = showAttributeMapping && 'width-14';
  11. return (
  12. <div className="gf-form-group">
  13. <div className="gf-form">
  14. <table className="filter-table form-inline">
  15. <thead>
  16. <tr>
  17. <th>Organisation</th>
  18. <th>Role</th>
  19. {showAttributeMapping && <th colSpan={2}>LDAP Group</th>}
  20. </tr>
  21. </thead>
  22. <tbody>
  23. {items.map((group, index) => {
  24. return (
  25. <tr key={`${group.orgId}-${index}`}>
  26. <td className="width-16">{group.orgName}</td>
  27. <td className={roleColumnClass}>{group.orgRole}</td>
  28. {showAttributeMapping && (
  29. <>
  30. <td>{group.groupDN}</td>
  31. <td>
  32. {!group.orgRole && (
  33. <span className="text-warning pull-right">
  34. No match
  35. <Tooltip placement="top" content="No matching groups found" theme={'info'}>
  36. <div className="gf-form-help-icon gf-form-help-icon--right-normal">
  37. <i className="fa fa-info-circle" />
  38. </div>
  39. </Tooltip>
  40. </span>
  41. )}
  42. </td>
  43. </>
  44. )}
  45. </tr>
  46. );
  47. })}
  48. </tbody>
  49. </table>
  50. </div>
  51. </div>
  52. );
  53. };