123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import {Fragment} from 'react';
- import styled from '@emotion/styled';
- import {openCreateTeamModal} from 'sentry/actionCreators/modal';
- import Button from 'sentry/components/button';
- import {t, tct} from 'sentry/locale';
- import {Organization, Team} from 'sentry/types';
- import EmptyMessage from 'sentry/views/settings/components/emptyMessage';
- import TextBlock from 'sentry/views/settings/components/text/textBlock';
- import AllTeamsRow from './allTeamsRow';
- type Props = {
- access: Record<string, any>;
- openMembership: boolean;
- organization: Organization;
- teamList: Array<Team>;
- urlPrefix: string;
- };
- function AllTeamsList({
- organization,
- urlPrefix,
- openMembership,
- teamList,
- access,
- }: Props) {
- const teamNodes = teamList.map(team => (
- <AllTeamsRow
- urlPrefix={urlPrefix}
- team={team}
- organization={organization}
- openMembership={openMembership}
- key={team.slug}
- />
- ));
- if (!teamNodes.length) {
- const canCreateTeam = access.has('project:admin');
- return (
- <EmptyMessage>
- {tct('No teams here. [teamCreate]', {
- root: <TextBlock noMargin />,
- teamCreate: canCreateTeam
- ? tct('You can always [link:create one].', {
- link: (
- <StyledButton
- priority="link"
- onClick={() =>
- openCreateTeamModal({
- organization,
- })
- }
- aria-label={t('Create team')}
- />
- ),
- })
- : null,
- })}
- </EmptyMessage>
- );
- }
- return <Fragment>{teamNodes}</Fragment>;
- }
- export default AllTeamsList;
- const StyledButton = styled(Button)`
- font-size: ${p => p.theme.fontSizeLarge};
- `;
|