projectScoreCards.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import styled from '@emotion/styled';
  2. import type {Location} from 'history';
  3. import {space} from 'sentry/styles/space';
  4. import type {Organization, PageFilters, Project} from 'sentry/types';
  5. import {SessionFieldWithOperation} from 'sentry/types';
  6. import {isPlatformANRCompatible} from 'sentry/views/projectDetail/utils';
  7. import {ProjectAnrScoreCard} from './projectAnrScoreCard';
  8. import ProjectApdexScoreCard from './projectApdexScoreCard';
  9. import ProjectStabilityScoreCard from './projectStabilityScoreCard';
  10. import ProjectVelocityScoreCard from './projectVelocityScoreCard';
  11. type Props = {
  12. hasSessions: boolean | null;
  13. isProjectStabilized: boolean;
  14. location: Location;
  15. organization: Organization;
  16. selection: PageFilters;
  17. hasTransactions?: boolean;
  18. project?: Project;
  19. query?: string;
  20. };
  21. function ProjectScoreCards({
  22. organization,
  23. selection,
  24. isProjectStabilized,
  25. hasSessions,
  26. hasTransactions,
  27. query,
  28. location,
  29. project,
  30. }: Props) {
  31. return (
  32. <CardWrapper>
  33. <ProjectStabilityScoreCard
  34. selection={selection}
  35. isProjectStabilized={isProjectStabilized}
  36. hasSessions={hasSessions}
  37. query={query}
  38. field={SessionFieldWithOperation.CRASH_FREE_RATE_SESSIONS}
  39. project={project}
  40. />
  41. <ProjectStabilityScoreCard
  42. selection={selection}
  43. isProjectStabilized={isProjectStabilized}
  44. hasSessions={hasSessions}
  45. query={query}
  46. field={SessionFieldWithOperation.CRASH_FREE_RATE_USERS}
  47. project={project}
  48. />
  49. <ProjectVelocityScoreCard
  50. organization={organization}
  51. selection={selection}
  52. isProjectStabilized={isProjectStabilized}
  53. query={query}
  54. />
  55. {isPlatformANRCompatible(project?.platform) ? (
  56. <ProjectAnrScoreCard
  57. organization={organization}
  58. selection={selection}
  59. isProjectStabilized={isProjectStabilized}
  60. query={query}
  61. location={location}
  62. />
  63. ) : (
  64. <ProjectApdexScoreCard
  65. organization={organization}
  66. selection={selection}
  67. isProjectStabilized={isProjectStabilized}
  68. hasTransactions={hasTransactions}
  69. query={query}
  70. />
  71. )}
  72. </CardWrapper>
  73. );
  74. }
  75. const CardWrapper = styled('div')`
  76. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  77. display: grid;
  78. grid-column-gap: ${space(2)};
  79. grid-template-columns: repeat(2, minmax(0, 1fr));
  80. }
  81. @media (min-width: 1600px) {
  82. grid-template-columns: repeat(4, minmax(0, 1fr));
  83. }
  84. `;
  85. export default ProjectScoreCards;