noRowRenderer.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {ReactNode} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Button} from 'sentry/components/button';
  4. import EmptyStateWarning from 'sentry/components/emptyStateWarning';
  5. import {IconClose} from 'sentry/icons';
  6. import {t} from 'sentry/locale';
  7. type Props = {
  8. children: ReactNode;
  9. clearSearchTerm: () => void;
  10. unfilteredItems: unknown[];
  11. };
  12. function NoRowRenderer({children, unfilteredItems, clearSearchTerm}: Props) {
  13. return unfilteredItems.length === 0 ? (
  14. <StyledEmptyStateWarning>
  15. <p>{children}</p>
  16. </StyledEmptyStateWarning>
  17. ) : (
  18. <StyledEmptyStateWarning>
  19. <p>{t('No results found')}</p>
  20. <Button
  21. icon={<IconClose color="gray500" size="sm" isCircled />}
  22. onClick={clearSearchTerm}
  23. size="md"
  24. >
  25. {t('Clear filters')}
  26. </Button>
  27. </StyledEmptyStateWarning>
  28. );
  29. }
  30. const StyledEmptyStateWarning = styled(EmptyStateWarning)`
  31. height: 100%;
  32. width: 100%;
  33. display: flex;
  34. flex-direction: column;
  35. align-items: center;
  36. justify-content: center;
  37. `;
  38. export default NoRowRenderer;