projectScoreCards.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  79. display: grid;
  80. grid-column-gap: ${space(2)};
  81. grid-template-columns: repeat(2, minmax(0, 1fr));
  82. }
  83. @media (min-width: 1600px) {
  84. grid-template-columns: repeat(4, minmax(0, 1fr));
  85. }
  86. `;
  87. export default ProjectScoreCards;