customerProjects.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import styled from '@emotion/styled';
  2. import moment from 'moment-timezone';
  3. import {PlatformIcon} from 'platformicons';
  4. import {LinkButton} from 'sentry/components/core/button';
  5. import Link from 'sentry/components/links/link';
  6. import {IconProject} from 'sentry/icons';
  7. import {t} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import ResultGrid from 'admin/components/resultGrid';
  10. type Props = {
  11. orgId: string;
  12. };
  13. function CustomerProjects({orgId}: Props) {
  14. return (
  15. <ResultGrid
  16. inPanel
  17. panelTitle="Projects"
  18. path={`/_admin/customers/${orgId}/`}
  19. endpoint={`/organizations/${orgId}/projects/?statsPeriod=30d`}
  20. method="GET"
  21. defaultParams={{per_page: 10}}
  22. hasSearch
  23. columns={[
  24. <th key="name">Project</th>,
  25. <th key="status" style={{width: 150, textAlign: 'center'}}>
  26. Status
  27. </th>,
  28. <th key="events" style={{width: 120, textAlign: 'center'}}>
  29. Events (30d)
  30. </th>,
  31. <th key="created" style={{width: 150, textAlign: 'right'}}>
  32. Created
  33. </th>,
  34. ]}
  35. columnsForRow={(row: any) => [
  36. <td key="name">
  37. <ProjectName>
  38. <PlatformIcon size={16} platform={row.platform ?? 'other'} />
  39. <LinkButton
  40. external
  41. priority="link"
  42. href={`/${orgId}/${row.slug}/`}
  43. icon={<IconProject size="xs" />}
  44. title="View in Sentry"
  45. aria-label={t('View in Sentry')}
  46. />
  47. <Link to={`/_admin/customers/${orgId}/projects/${row.slug}/`}>
  48. {row.slug}
  49. </Link>
  50. </ProjectName>
  51. </td>,
  52. <td key="status" style={{textAlign: 'center'}}>
  53. {row.status}
  54. </td>,
  55. <td key="events" style={{textAlign: 'center'}}>
  56. {row.stats.reduce((a: number, b: any) => a + b[1], 0).toLocaleString()}
  57. </td>,
  58. <td key="created" style={{textAlign: 'right'}}>
  59. {moment(row.dateCreated).fromNow()}
  60. </td>,
  61. ]}
  62. />
  63. );
  64. }
  65. const ProjectName = styled('div')`
  66. display: flex;
  67. gap: ${space(1)};
  68. align-items: center;
  69. `;
  70. export default CustomerProjects;