LdapUserTeams.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React, { FC } from 'react';
  2. import { css } from 'emotion';
  3. import { Tooltip } from '@grafana/ui';
  4. import { LdapTeam } from 'app/types';
  5. interface Props {
  6. teams: LdapTeam[];
  7. showAttributeMapping?: boolean;
  8. }
  9. export const LdapUserTeams: FC<Props> = ({ teams, showAttributeMapping }) => {
  10. const items = showAttributeMapping ? teams : teams.filter(item => item.teamName);
  11. const teamColumnClass = showAttributeMapping && 'width-14';
  12. const noMatchPlaceholderStyle = css`
  13. display: flex;
  14. `;
  15. return (
  16. <div className="gf-form-group">
  17. <div className="gf-form">
  18. <table className="filter-table form-inline">
  19. <thead>
  20. <tr>
  21. <th>Organisation</th>
  22. <th>Team</th>
  23. {showAttributeMapping && <th>LDAP</th>}
  24. </tr>
  25. </thead>
  26. <tbody>
  27. {items.map((team, index) => {
  28. return (
  29. <tr key={`${team.teamName}-${index}`}>
  30. <td className="width-16">
  31. {team.orgName || (
  32. <div className={`text-warning ${noMatchPlaceholderStyle}`}>
  33. No match
  34. <Tooltip placement="top" content="No matching teams found" theme={'info'}>
  35. <div className="gf-form-help-icon gf-form-help-icon--right-normal">
  36. <i className="fa fa-info-circle" />
  37. </div>
  38. </Tooltip>
  39. </div>
  40. )}
  41. </td>
  42. <td className={teamColumnClass}>{team.teamName}</td>
  43. {showAttributeMapping && <td>{team.groupDN}</td>}
  44. </tr>
  45. );
  46. })}
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. );
  52. };