projectScoreCards.tsx 2.7 KB

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