allTeamsList.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {openCreateTeamModal} from 'sentry/actionCreators/modal';
  4. import Button from 'sentry/components/button';
  5. import {t, tct} from 'sentry/locale';
  6. import {Organization, Team} from 'sentry/types';
  7. import EmptyMessage from 'sentry/views/settings/components/emptyMessage';
  8. import TextBlock from 'sentry/views/settings/components/text/textBlock';
  9. import AllTeamsRow from './allTeamsRow';
  10. type Props = {
  11. access: Record<string, any>;
  12. openMembership: boolean;
  13. organization: Organization;
  14. teamList: Array<Team>;
  15. urlPrefix: string;
  16. };
  17. function AllTeamsList({
  18. organization,
  19. urlPrefix,
  20. openMembership,
  21. teamList,
  22. access,
  23. }: Props) {
  24. const teamNodes = teamList.map(team => (
  25. <AllTeamsRow
  26. urlPrefix={urlPrefix}
  27. team={team}
  28. organization={organization}
  29. openMembership={openMembership}
  30. key={team.slug}
  31. />
  32. ));
  33. if (!teamNodes.length) {
  34. const canCreateTeam = access.has('project:admin');
  35. return (
  36. <EmptyMessage>
  37. {tct('No teams here. [teamCreate]', {
  38. root: <TextBlock noMargin />,
  39. teamCreate: canCreateTeam
  40. ? tct('You can always [link:create one].', {
  41. link: (
  42. <StyledButton
  43. priority="link"
  44. onClick={() =>
  45. openCreateTeamModal({
  46. organization,
  47. })
  48. }
  49. aria-label={t('Create team')}
  50. />
  51. ),
  52. })
  53. : null,
  54. })}
  55. </EmptyMessage>
  56. );
  57. }
  58. return <Fragment>{teamNodes}</Fragment>;
  59. }
  60. export default AllTeamsList;
  61. const StyledButton = styled(Button)`
  62. font-size: ${p => p.theme.fontSizeLarge};
  63. `;